Browse Source

check disposed in encryption #46 #42

tags/2.3
clowwindy 10 years ago
parent
commit
1297af77fc
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      shadowsocks-csharp/Encrypt/PolarSSLEncryptor.cs

+ 16
- 2
shadowsocks-csharp/Encrypt/PolarSSLEncryptor.cs View File

@@ -175,6 +175,10 @@ namespace Shadowsocks.Encrypt
// C# could be multi-threaded
lock (_encryptCtx)
{
if (_disposed)
{
throw new ObjectDisposedException(this.ToString());
}
switch (_cipher)
{
case CIPHER_AES:
@@ -197,6 +201,10 @@ namespace Shadowsocks.Encrypt
outlength = length;
lock (_encryptCtx)
{
if (_disposed)
{
throw new ObjectDisposedException(this.ToString());
}
switch (_cipher)
{
case CIPHER_AES:
@@ -225,6 +233,10 @@ namespace Shadowsocks.Encrypt
Buffer.BlockCopy(buf, ivLen, tempbuf, 0, length - ivLen);
lock (_decryptCtx)
{
if (_disposed)
{
throw new ObjectDisposedException(this.ToString());
}
switch (_cipher)
{
case CIPHER_AES:
@@ -245,6 +257,10 @@ namespace Shadowsocks.Encrypt
outlength = length;
lock (_decryptCtx)
{
if (_disposed)
{
throw new ObjectDisposedException(this.ToString());
}
switch (_cipher)
{
case CIPHER_AES:
@@ -304,7 +320,6 @@ namespace Shadowsocks.Encrypt
PolarSSL.arc4_free(_encryptCtx);
break;
}
_encryptCtx = null;
}
}
if (_decryptCtx != null)
@@ -323,7 +338,6 @@ namespace Shadowsocks.Encrypt
PolarSSL.arc4_free(_decryptCtx);
break;
}
_decryptCtx = null;
}
}
}


Loading…
Cancel
Save