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:56:34 +0000 (11:56 +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 d1fc716d5c5c1468cf8f22d86dc32718c0eafe13..5d26c949265ffd018155d85f77c88068eb86eacd 100644 (file)
@@ -1459,6 +1459,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 0e7a262a0d0bd9ceaa813118b09e60e10ee73aa1..0bf0ea53639c931815d5af7a8b78b66a3c697af5 100644 (file)
@@ -3858,6 +3858,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 */