[openssl-commits] [openssl] master update

Kurt Roeckx kurt at openssl.org
Fri May 27 19:05:17 UTC 2016


The branch master has been updated
       via  369e93398b68b8a328e6c1d766222b2d281ef016 (commit)
      from  4379d5ce782d4cc83840db7b7b66e18d325dfd3e (commit)


- Log -----------------------------------------------------------------
commit 369e93398b68b8a328e6c1d766222b2d281ef016
Author: Kurt Roeckx <kurt at roeckx.be>
Date:   Thu May 26 18:40:32 2016 +0200

    Avoid calling memcpy with lenght of 0
    
    We can call memcpy() with a pointer 1 past the last allocated byte and length
    of 0 and you can argue that that's undefined behaviour.
    
    Reported by tis-interpreter
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    
    GH: #1132

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

Summary of changes:
 crypto/asn1/a_bitstr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c
index 2f0d8f8..33be907 100644
--- a/crypto/asn1/a_bitstr.c
+++ b/crypto/asn1/a_bitstr.c
@@ -66,10 +66,11 @@ int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
 
     *(p++) = (unsigned char)bits;
     d = a->data;
-    memcpy(p, d, len);
-    p += len;
-    if (len > 0)
+    if (len > 0) {
+        memcpy(p, d, len);
+        p += len;
         p[-1] &= (0xff << bits);
+    }
     *pp = p;
     return (ret);
 }


More information about the openssl-commits mailing list