In ssl3_read_n, set rwstate to SSL_NOTHING when the requested
[openssl.git] / ssl / s3_pkt.c
index 38063b50d58d1472195931283f0ce1442d1aecd6..ae8b981eee19a1a014eb44856227b254217f9dbb 100644 (file)
@@ -167,6 +167,11 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
                if (max > max_max)
                        max = max_max;
        }
+       if (n > max) /* does not happen */
+               {
+               SSLerr(SSL_F_SSL3_READ_N,SSL_R_INTERNAL_ERROR);
+               return -1;
+               }
 
        off = s->packet_length;
        newb = s->s3->rbuf.left;
@@ -209,6 +214,7 @@ static int ssl3_read_n(SSL *s, int n, int max, int extend)
        s->s3->rbuf.offset = off + n;
        s->s3->rbuf.left = newb - n;
        s->packet_length += n;
+       s->rwstate=SSL_NOTHING;
        return(n);
        }
 
@@ -293,7 +299,7 @@ again:
                        goto f_err;
                        }
 
-               s->rstate=SSL_ST_READ_BODY;
+               /* now s->rstate == SSL_ST_READ_BODY; */
                }
 
        /* get and decode the data */