]> granicus.if.org Git - openssl/commitdiff
Replace memset with OPENSSL_clear_free()
authorMatt Caswell <matt@openssl.org>
Thu, 30 Apr 2015 13:04:30 +0000 (14:04 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 10 Jun 2015 09:09:57 +0000 (10:09 +0100)
BUF_MEM_free() attempts to cleanse memory using memset immediately prior
to a free. This is at risk of being optimised away by the compiler, so
replace with a call to OPENSSL_clear_free() instead.

With thanks to the Open Crypto Audit Project for reporting this issue.

Reviewed-by: Stephen Henson <steve@openssl.org>
crypto/buffer/buffer.c

index 37e5484dbd9296f461c59270fc7bf45dd546de20..2beacce6d731752b8587fd0256016df2b989790d 100644 (file)
@@ -88,8 +88,7 @@ void BUF_MEM_free(BUF_MEM *a)
         return;
 
     if (a->data != NULL) {
-        memset(a->data, 0, (unsigned int)a->max);
-        OPENSSL_free(a->data);
+        OPENSSL_clear_free(a->data, a->max);
     }
     OPENSSL_free(a);
 }