[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Mon Feb 8 16:09:32 UTC 2016


The branch master has been updated
       via  43ecb9c35caed8623cfd83e7d893b8b67725feb7 (commit)
      from  4500a4cd4d89ba338ad796d39ccb9d94794cc0d7 (commit)


- Log -----------------------------------------------------------------
commit 43ecb9c35caed8623cfd83e7d893b8b67725feb7
Author: Rich Salz <rsalz at openssl.org>
Date:   Mon Feb 8 10:11:56 2016 -0500

    GH641: Don't care openssl_zmalloc
    
    Don't cast malloc-family return values.
    Also found some places where (a) blank line was missing; and (b)
    the *wrong* return value was checked.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>

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

Summary of changes:
 crypto/bio/b_addr.c    | 7 ++++---
 crypto/evp/cmeth_lib.c | 6 ++++--
 crypto/evp/encode.c    | 2 +-
 crypto/evp/evp_lib.c   | 6 ++++--
 crypto/hmac/hmac.c     | 8 +++++---
 5 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c
index a2a0dd2..39597b8 100644
--- a/crypto/bio/b_addr.c
+++ b/crypto/bio/b_addr.c
@@ -75,7 +75,8 @@
 
 BIO_ADDR *BIO_ADDR_new(void)
 {
-    BIO_ADDR *ret = (BIO_ADDR *)OPENSSL_zalloc(sizeof(BIO_ADDR));
+    BIO_ADDR *ret = OPENSSL_zalloc(sizeof(*ret));
+
     ret->sa.sa_family = AF_UNSPEC;
     return ret;
 }
@@ -557,10 +558,10 @@ static int addrinfo_wrap(int family, int socktype,
 {
     OPENSSL_assert(bai != NULL);
 
-    *bai = (BIO_ADDRINFO *)OPENSSL_zalloc(sizeof(**bai));
-
+    *bai = OPENSSL_zalloc(sizeof(**bai));
     if (*bai == NULL)
         return 0;
+
     (*bai)->bai_family = family;
     (*bai)->bai_socktype = socktype;
     if (socktype == SOCK_STREAM)
diff --git a/crypto/evp/cmeth_lib.c b/crypto/evp/cmeth_lib.c
index 1e7cac8..33944e1 100644
--- a/crypto/evp/cmeth_lib.c
+++ b/crypto/evp/cmeth_lib.c
@@ -64,7 +64,8 @@
 
 EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len)
 {
-    EVP_CIPHER *cipher = (EVP_CIPHER *)OPENSSL_zalloc(sizeof(EVP_CIPHER));
+    EVP_CIPHER *cipher = OPENSSL_zalloc(sizeof(EVP_CIPHER));
+
     if (cipher != NULL) {
         cipher->nid = cipher_type;
         cipher->block_size = block_size;
@@ -77,7 +78,8 @@ EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher)
 {
     EVP_CIPHER *to = EVP_CIPHER_meth_new(cipher->nid, cipher->block_size,
                                          cipher->key_len);
-    if (cipher != NULL)
+
+    if (to != NULL)
         memcpy(to, cipher, sizeof(*to));
     return to;
 }
diff --git a/crypto/evp/encode.c b/crypto/evp/encode.c
index de52ae4..ed85f89 100644
--- a/crypto/evp/encode.c
+++ b/crypto/evp/encode.c
@@ -142,7 +142,7 @@ static unsigned char conv_ascii2bin(unsigned char a)
 
 EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void)
 {
-    return (EVP_ENCODE_CTX *)OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
+    return OPENSSL_zalloc(sizeof(EVP_ENCODE_CTX));
 }
 
 void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)
diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
index ff2a1d2..a163628 100644
--- a/crypto/evp/evp_lib.c
+++ b/crypto/evp/evp_lib.c
@@ -352,7 +352,8 @@ unsigned long EVP_MD_flags(const EVP_MD *md)
 
 EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type)
 {
-    EVP_MD *md = (EVP_MD *)OPENSSL_zalloc(sizeof(EVP_MD));
+    EVP_MD *md = OPENSSL_zalloc(sizeof(*md));
+
     if (md != NULL) {
         md->type = md_type;
         md->pkey_type = pkey_type;
@@ -362,7 +363,8 @@ EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type)
 EVP_MD *EVP_MD_meth_dup(const EVP_MD *md)
 {
     EVP_MD *to = EVP_MD_meth_new(md->type, md->pkey_type);
-    if (md != NULL)
+
+    if (to != NULL)
         memcpy(to, md, sizeof(*to));
     return to;
 }
diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c
index f372955..9504aad 100644
--- a/crypto/hmac/hmac.c
+++ b/crypto/hmac/hmac.c
@@ -171,12 +171,14 @@ size_t HMAC_size(HMAC_CTX *ctx)
 
 HMAC_CTX *HMAC_CTX_new(void)
 {
-    HMAC_CTX *ctx = (HMAC_CTX *)OPENSSL_zalloc(sizeof(HMAC_CTX));
-    if (ctx)
+    HMAC_CTX *ctx = OPENSSL_zalloc(sizeof(HMAC_CTX));
+
+    if (ctx != NULL) {
         if (!HMAC_CTX_reset(ctx)) {
             HMAC_CTX_free(ctx);
-            ctx = NULL;
+            return NULL;
         }
+    }
     return ctx;
 }
 


More information about the openssl-commits mailing list