Thread: [Dnsmail-cvs] dnsmail/DnsMail OpenSslStream.cs,1.1,1.1.4.1
Brought to you by:
ethem
From: Ethem E. <et...@us...> - 2006-05-15 14:26:35
|
Update of /cvsroot/dnsmail/dnsmail/DnsMail In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13962/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 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** OpenSslStream.cs 6 Mar 2006 15:47:40 -0000 1.1 --- OpenSslStream.cs 15 May 2006 14:26:32 -0000 1.1.4.1 *************** *** 37,45 **** static OpenSslStream() { UnsafeOpenSsl.SSL_load_error_strings(); UnsafeOpenSsl.SSL_library_init(); String version = ""; ! IntPtr ctx = UnsafeOpenSsl.SSL_CTX_new(UnsafeOpenSsl.TLSv1_method()); ! if (ctx != IntPtr.Zero) { try --- 37,47 ---- static OpenSslStream() { + // Load OpenSsl libraries UnsafeOpenSsl.SSL_load_error_strings(); UnsafeOpenSsl.SSL_library_init(); + String version = ""; ! IntPtr tmpctx = UnsafeOpenSsl.SSL_CTX_new(UnsafeOpenSsl.TLSv1_method()); ! if (tmpctx != IntPtr.Zero) { try *************** *** 50,54 **** finally { ! UnsafeOpenSsl.SSL_CTX_free(ctx); } } --- 52,56 ---- finally { ! UnsafeOpenSsl.SSL_CTX_free(tmpctx); } } *************** *** 368,372 **** } ! fixed(byte* ptr = buffer) { while (count > 0) --- 370,374 ---- } ! fixed(byte* ptr = &buffer[offset]) { while (count > 0) |
From: Ethem E. <et...@us...> - 2006-05-22 10:39:39
|
Update of /cvsroot/dnsmail/dnsmail/DnsMail In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15151/dnsmail/DnsMail Modified Files: Tag: DNSMAIL_02 OpenSslStream.cs Log Message: PAramater validation. Index: OpenSslStream.cs =================================================================== RCS file: /cvsroot/dnsmail/dnsmail/DnsMail/OpenSslStream.cs,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** OpenSslStream.cs 6 Mar 2006 15:47:40 -0000 1.1 --- OpenSslStream.cs 22 May 2006 10:39:28 -0000 1.1.4.1 *************** *** 37,45 **** static OpenSslStream() { UnsafeOpenSsl.SSL_load_error_strings(); UnsafeOpenSsl.SSL_library_init(); String version = ""; ! IntPtr ctx = UnsafeOpenSsl.SSL_CTX_new(UnsafeOpenSsl.TLSv1_method()); ! if (ctx != IntPtr.Zero) { try --- 37,47 ---- static OpenSslStream() { + // Load OpenSsl libraries UnsafeOpenSsl.SSL_load_error_strings(); UnsafeOpenSsl.SSL_library_init(); + String version = ""; ! IntPtr tmpctx = UnsafeOpenSsl.SSL_CTX_new(UnsafeOpenSsl.TLSv1_method()); ! if (tmpctx != IntPtr.Zero) { try *************** *** 50,54 **** finally { ! UnsafeOpenSsl.SSL_CTX_free(ctx); } } --- 52,56 ---- finally { ! UnsafeOpenSsl.SSL_CTX_free(tmpctx); } } *************** *** 340,353 **** } ! 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; } *************** *** 359,384 **** } ! 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) { ! 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; } } |