[openssl-commits] [openssl] master update

Matt Caswell matt at openssl.org
Fri Mar 3 23:52:54 UTC 2017


The branch master has been updated
       via  d08086645f72ab890c6ef996bb513076752431f0 (commit)
      from  8336ca13b1be5358621da075eac7a0ab5dc2bd10 (commit)


- Log -----------------------------------------------------------------
commit d08086645f72ab890c6ef996bb513076752431f0
Author: Matt Caswell <matt at openssl.org>
Date:   Fri Mar 3 08:56:25 2017 +0000

    Ensure we don't call memcpy with a NULL pointer
    
    Commit d5aa14dd simplified the bn_expand_internal() and BN_copy() functions.
    Unfortunately it also removed some checks which are still required,
    otherwise we call memcpy passing in NULL which is not allowed.
    
    Reviewed-by: Tim Hudson <tjh at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/2836)

-----------------------------------------------------------------------

Summary of changes:
 crypto/bn/bn_lib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index e61c870..9917923 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -267,7 +267,8 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
     }
 
     assert(b->top <= words);
-    memcpy(a, b->d, sizeof(*a) * b->top);
+    if (b->top > 0)
+        memcpy(a, b->d, sizeof(*a) * b->top);
 
     return a;
 }
@@ -328,7 +329,8 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
     if (bn_wexpand(a, b->top) == NULL)
         return NULL;
 
-    memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
+    if (b->top > 0)
+        memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
 
     a->top = b->top;
     a->neg = b->neg;


More information about the openssl-commits mailing list