[Dnsmail-cvs] dnsmail SmtpStream.cs,1.1,1.2
Brought to you by:
ethem
From: Ethem E. <et...@us...> - 2006-08-04 13:35:24
|
Update of /cvsroot/dnsmail/dnsmail In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv15791/dnsmail Modified Files: SmtpStream.cs Log Message: Some debug information removed and paramater validation added. Index: SmtpStream.cs =================================================================== RCS file: /cvsroot/dnsmail/dnsmail/SmtpStream.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SmtpStream.cs 4 Aug 2006 12:59:04 -0000 1.1 --- SmtpStream.cs 4 Aug 2006 13:35:21 -0000 1.2 *************** *** 157,165 **** #region Handshake - public static void write(string x) - { - System.Web.HttpContext.Current.Response.Write(x + "<br />"); - } - private bool handshake = false; public bool Handshake(bool cerrequest) --- 157,160 ---- *************** *** 174,178 **** const int SSL_OP_ALL = 0x00000FFF; ! //UnsafeOpenSsl.SSL_set_quiet_shutdown(sslSession, 1); UnsafeOpenSsl.SSL_ctrl(sslSession, SSL_CTRL_OPTIONS, SSL_OP_ALL, IntPtr.Zero); UnsafeOpenSsl.SSL_set_fd(sslSession, Socket.Handle); --- 169,173 ---- const int SSL_OP_ALL = 0x00000FFF; ! UnsafeOpenSsl.SSL_set_quiet_shutdown(sslSession, 1); UnsafeOpenSsl.SSL_ctrl(sslSession, SSL_CTRL_OPTIONS, SSL_OP_ALL, IntPtr.Zero); UnsafeOpenSsl.SSL_set_fd(sslSession, Socket.Handle); *************** *** 183,192 **** Socket.Blocking = false; ! int err, cnt = 0; ! while (((err=UnsafeOpenSsl.SSL_connect(sslSession)) <= 0) && handle_ssl_error(err, errors)) ! cnt++; if (Socket.Blocking != oldblock) ! Socket.Blocking = oldblock; if (err <= 0) --- 178,186 ---- Socket.Blocking = false; ! int err; ! while (((err=UnsafeOpenSsl.SSL_connect(sslSession)) <= 0) && handle_ssl_error(err, errors)); if (Socket.Blocking != oldblock) ! Socket.Blocking = oldblock; if (err <= 0) *************** *** 194,200 **** try { ! if (errors.Length > 0) throw new Exception(errors.ToString()); ! else if (err == 0) throw new Exception("Connection closed"); ! else throw new Exception("Unknown SSL exception"); } finally --- 188,200 ---- try { ! if (errors.Length > 0) ! { ! throw new Exception(errors.ToString()); ! } ! if (err == 0) ! { ! throw new Exception("Connection closed"); ! } ! throw new Exception("Unknown SSL exception"); } finally *************** *** 334,337 **** --- 334,349 ---- if (handshake) { + if (buffer == null) + { + throw new ArgumentNullException("buffer"); + } + if (offset < 0 || offset > buffer.Length) + { + throw new ArgumentOutOfRangeException("offset"); + } + if (count < 0 || count > buffer.Length-offset) + { + throw new ArgumentOutOfRangeException("count"); + } fixed(byte* ptr = &buffer[offset]) { *************** *** 357,360 **** --- 369,384 ---- if (handshake) { + if (buffer == null) + { + throw new ArgumentNullException("buffer"); + } + if (offset < 0 || offset > buffer.Length) + { + throw new ArgumentOutOfRangeException("offset"); + } + if (count < 0 || count > buffer.Length-offset) + { + throw new ArgumentOutOfRangeException("count"); + } fixed(byte* ptr = &buffer[offset]) { |