make code a little more similar to what it looked like before the fixes,
authorBodo Möller <bodo@openssl.org>
Sat, 10 Nov 2001 10:44:15 +0000 (10:44 +0000)
committerBodo Möller <bodo@openssl.org>
Sat, 10 Nov 2001 10:44:15 +0000 (10:44 +0000)
call ssl2_part_read again to parse error message

CHANGES
ssl/s2_clnt.c
ssl/s2_srvr.c

diff --git a/CHANGES b/CHANGES
index 437c07e..0eec6b3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 
   *) Change ssl/s2_clnt.c and ssl/s3_srvr.c so that received handshake
      messages are stored in a single piece (fixed-length part and
-     variable-length part) and fix various bugs found on the way.
+     variable-length part combined) and fix various bugs found on the way.
      [Bodo Moeller]
 
   *) In ssl3_get_client_hello (ssl/s3_srvr.c), generate a fatal alert
index 3a990e4..868a975 100644 (file)
@@ -873,8 +873,8 @@ static int get_server_verify(SSL *s)
        p=(unsigned char *)s->init_buf->data;
        if (s->state == SSL2_ST_GET_SERVER_VERIFY_A)
                {
-               i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
-               if (i < (3-s->init_num)) 
+               i=ssl2_read(s,(char *)&(p[s->init_num]),1-s->init_num);
+               if (i < (1-s->init_num)) 
                        return(ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i));
                s->init_num += i;
 
@@ -888,8 +888,12 @@ static int get_server_verify(SSL *s)
                                        SSL_R_READ_WRONG_PACKET_TYPE);
                                }
                        else
-                               SSLerr(SSL_F_GET_SERVER_VERIFY,
-                                       SSL_R_PEER_ERROR);
+                               {
+                               SSLerr(SSL_F_GET_SERVER_VERIFY,SSL_R_PEER_ERROR);
+                               /* try to read the error message */
+                               i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
+                               return ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i);
+                               }
                        return(-1);
                        }
                }
@@ -923,8 +927,8 @@ static int get_server_finished(SSL *s)
        p=buf;
        if (s->state == SSL2_ST_GET_SERVER_FINISHED_A)
                {
-               i=ssl2_read(s,(char *)&(buf[s->init_num]),3-s->init_num);
-               if (i < (3-s->init_num))
+               i=ssl2_read(s,(char *)&(buf[s->init_num]),1-s->init_num);
+               if (i < (1-s->init_num))
                        return(ssl2_part_read(s,SSL_F_GET_SERVER_FINISHED,i));
                s->init_num += i;
 
@@ -941,7 +945,12 @@ static int get_server_finished(SSL *s)
                                SSLerr(SSL_F_GET_SERVER_FINISHED,SSL_R_READ_WRONG_PACKET_TYPE);
                                }
                        else
+                               {
                                SSLerr(SSL_F_GET_SERVER_FINISHED,SSL_R_PEER_ERROR);
+                               /* try to read the error message */
+                               i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
+                               return ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i);
+                               }
                        return(-1);
                        }
                s->state=SSL2_ST_GET_SERVER_FINISHED_B;
index ea07852..58ee389 100644 (file)
@@ -801,10 +801,10 @@ static int get_client_finished(SSL *s)
        p=(unsigned char *)s->init_buf->data;
        if (s->state == SSL2_ST_GET_CLIENT_FINISHED_A)
                {
-               i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
-               if (i < 3-s->init_num)
+               i=ssl2_read(s,(char *)&(p[s->init_num]),1-s->init_num);
+               if (i < 1-s->init_num)
                        return(ssl2_part_read(s,SSL_F_GET_CLIENT_FINISHED,i));
-               s->init_num = 3;
+               s->init_num += i;
 
                if (*p != SSL2_MT_CLIENT_FINISHED)
                        {
@@ -814,7 +814,12 @@ static int get_client_finished(SSL *s)
                                SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_READ_WRONG_PACKET_TYPE);
                                }
                        else
+                               {
                                SSLerr(SSL_F_GET_CLIENT_FINISHED,SSL_R_PEER_ERROR);
+                               /* try to read the error message */
+                               i=ssl2_read(s,(char *)&(p[s->init_num]),3-s->init_num);
+                               return ssl2_part_read(s,SSL_F_GET_SERVER_VERIFY,i);
+                               }
                        return(-1);
                        }
                s->state=SSL2_ST_GET_CLIENT_FINISHED_B;