Update of /cvsroot/dnsmail/dnsmail/DnsMail
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv17965/dnsmail/DnsMail
Modified Files:
Tag: DNSMAIL_02
OpenSslStream.cs
Log Message:
Branch fix.
Index: OpenSslStream.cs
===================================================================
RCS file: /cvsroot/dnsmail/dnsmail/DnsMail/OpenSslStream.cs,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -C2 -d -r1.1.4.1 -r1.1.4.2
*** OpenSslStream.cs 15 May 2006 14:26:32 -0000 1.1.4.1
--- OpenSslStream.cs 15 May 2006 14:38:37 -0000 1.1.4.2
***************
*** 342,355 ****
}
! unsafe public override int Read(byte[] buffer, int offset, int count)
{
if (!CanRead)
return -1;
fixed(byte* ptr = &buffer[offset])
{
try
{
! int read = UnsafeOpenSsl.SSL_read(sslSession, ptr, count);
return read;
}
--- 342,369 ----
}
! unsafe public override int Read(byte[] buffer, int offset, int size)
{
if (!CanRead)
return -1;
+ // param validation
+ if (buffer == null)
+ {
+ throw new ArgumentNullException("buffer");
+ }
+ if (offset < 0 || offset > buffer.Length)
+ {
+ throw new ArgumentOutOfRangeException("offset");
+ }
+ if (size < 0 || size > buffer.Length-offset)
+ {
+ throw new ArgumentOutOfRangeException("size");
+ }
+
fixed(byte* ptr = &buffer[offset])
{
try
{
! int read = UnsafeOpenSsl.SSL_read(sslSession, ptr, size);
return read;
}
***************
*** 361,386 ****
}
! unsafe public override void Write(byte[] buffer, int offset, int count)
{
- Exception exp;
if (!CanWrite)
{
! exp = new Exception("ERR:SSL_write::handshake is not ok or connection closed");
! throw exp;
}
fixed(byte* ptr = &buffer[offset])
{
! while (count > 0)
{
! int sent = UnsafeOpenSsl.SSL_write(sslSession, &ptr[offset], count);
if (sent <= 0)
{
! exp = new Exception("ERR::SSL_write::memory{0x" + ((int)ptr).ToString("x") + "} index[" + offset + "]");
! throw exp;
}
-
offset += sent;
! count -= sent;
}
}
--- 375,410 ----
}
! unsafe public override void Write(byte[] buffer, int offset, int size)
{
if (!CanWrite)
+ {
+ throw new Exception("ERR:SSL_write::handshake is not ok or connection closed");;
+ }
+
+ // param validation
+ if (buffer == null)
{
! throw new ArgumentNullException("buffer");
! }
! if (offset < 0 || offset > buffer.Length)
! {
! throw new ArgumentOutOfRangeException("offset");
! }
! if (size < 0 || size > buffer.Length-offset)
! {
! throw new ArgumentOutOfRangeException("size");
}
fixed(byte* ptr = &buffer[offset])
{
! while (size > 0)
{
! int sent = UnsafeOpenSsl.SSL_write(sslSession, &ptr[offset], size);
if (sent <= 0)
{
! throw new Exception("ERR::SSL_write::memory{0x" + ((int)ptr).ToString("x") + "} index[" + offset + "]");
}
offset += sent;
! size -= sent;
}
}
|