add check for internal error
diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c
index 7728284..93d1461 100644
--- a/ssl/s3_pkt.c
+++ b/ssl/s3_pkt.c
@@ -167,6 +167,11 @@
 		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;