diff options
author | Emilia Kasper <emilia@openssl.org> | 2015-09-17 13:27:05 +0200 |
---|---|---|
committer | Emilia Kasper <emilia@openssl.org> | 2015-09-22 19:51:18 +0200 |
commit | de8883e11befde31d9b6cfbbd1fc017c365e0bbf (patch) | |
tree | dcd4acac52c104a9f78d0e584167acd4b08aab4b /crypto | |
parent | 110f7b37de9feecfb64950601cc7cec77cf6130b (diff) |
BUF_strndup: tidy
Fix comment, add another overflow check, tidy style
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/buffer/buf_str.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/buffer/buf_str.c b/crypto/buffer/buf_str.c index bca363c28e..1f3e8a4e79 100644 --- a/crypto/buffer/buf_str.c +++ b/crypto/buffer/buf_str.c @@ -73,7 +73,7 @@ size_t BUF_strnlen(const char *str, size_t maxlen) char *BUF_strdup(const char *str) { if (str == NULL) - return (NULL); + return NULL; return BUF_strndup(str, strlen(str)); } @@ -82,17 +82,17 @@ char *BUF_strndup(const char *str, size_t siz) char *ret; if (str == NULL) - return (NULL); + return NULL; siz = BUF_strnlen(str, siz); if (siz >= INT_MAX) - return (NULL); + return NULL; ret = OPENSSL_malloc(siz + 1); if (ret == NULL) { BUFerr(BUF_F_BUF_STRNDUP, ERR_R_MALLOC_FAILURE); - return (NULL); + return NULL; } memcpy(ret, str, siz); @@ -105,13 +105,13 @@ void *BUF_memdup(const void *data, size_t siz) { void *ret; - if (data == NULL) - return (NULL); + if (data == NULL || siz >= INT_MAX) + return NULL; ret = OPENSSL_malloc(siz); if (ret == NULL) { BUFerr(BUF_F_BUF_MEMDUP, ERR_R_MALLOC_FAILURE); - return (NULL); + return NULL; } return memcpy(ret, data, siz); } |