Add sanity check to ssl_get_prev_session
authorMatt Caswell <matt@openssl.org>
Tue, 28 Apr 2015 14:28:23 +0000 (15:28 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 30 Apr 2015 22:27:07 +0000 (23:27 +0100)
Sanity check the |len| parameter to ensure it is positive. Thanks to Kevin
Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for
reporting this issue.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit cb0f400b0cea2d2943f99b1e89c04ff6ed748cd5)

ssl/ssl_sess.c

index 4c7f5d8b4e32d3e09690e8f313d62ddd08cbc95b..eb7936b4e1d390d86d0e23e854dfc987aee51cb6 100644 (file)
@@ -478,7 +478,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len,
     int r;
 #endif
 
-    if (len > SSL_MAX_SSL_SESSION_ID_LENGTH)
+    if (len < 0 || len > SSL_MAX_SSL_SESSION_ID_LENGTH)
         goto err;
 
     if (session_id + len > limit) {