Add a check for a failed malloc
authorMatt Caswell <matt@openssl.org>
Tue, 15 Mar 2016 11:51:48 +0000 (11:51 +0000)
committerMatt Caswell <matt@openssl.org>
Fri, 18 Mar 2016 11:59:11 +0000 (11:59 +0000)
Ensure we check for a NULL return from OPENSSL_malloc

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/d1_both.c
ssl/t1_lib.c

index aaa18677ceef0c7f7f9afd5bf5c2deb3129227b0..19c3da61612233f043fa12697a4b96a9c280fcc9 100644 (file)
@@ -1579,6 +1579,8 @@ int dtls1_process_heartbeat(SSL *s)
          * plus 2 bytes payload length, plus payload, plus padding
          */
         buffer = OPENSSL_malloc(write_length);
+        if (buffer == NULL)
+            return -1;
         bp = buffer;
 
         /* Enter response type, length and copy payload */
index 090f93ef62cc033ea6fd1a6c03986fa90a4a5fac..0bdb77d49fc311a9434e731e22bb1b3d913ab6d2 100644 (file)
@@ -2581,6 +2581,8 @@ int tls1_process_heartbeat(SSL *s)
          * plus 2 bytes payload length, plus payload, plus padding
          */
         buffer = OPENSSL_malloc(1 + 2 + payload + padding);
+        if (buffer == NULL)
+            return -1;
         bp = buffer;
 
         /* Enter response type, length and copy payload */