diff options
| author | Steve Langasek <steve.langasek@canonical.com> | 2016-10-01 14:18:49 -0700 |
|---|---|---|
| committer | Steve Langasek <steve.langasek@canonical.com> | 2016-10-01 14:18:49 -0700 |
| commit | b65e78ec015a308c1798e602c94502327cc90cd9 (patch) | |
| tree | 4185dc52bcba0af1f815b88e100cd68a626916ca /Cryptlib/OpenSSL/crypto/buffer | |
| parent | 21ebe03556d7030055644f46efd3c165396a7a75 (diff) | |
| parent | 86b44a70f0e22233427cef3e966869e59b5e9dd5 (diff) | |
| download | efi-boot-shim-b65e78ec015a308c1798e602c94502327cc90cd9.tar.gz efi-boot-shim-b65e78ec015a308c1798e602c94502327cc90cd9.zip | |
Resync with Ubuntu, including patch to fix debian/copyright.
Diffstat (limited to 'Cryptlib/OpenSSL/crypto/buffer')
| -rw-r--r-- | Cryptlib/OpenSSL/crypto/buffer/buf_str.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Cryptlib/OpenSSL/crypto/buffer/buf_str.c b/Cryptlib/OpenSSL/crypto/buffer/buf_str.c index ebc5ab46..fa0d608e 100644 --- a/Cryptlib/OpenSSL/crypto/buffer/buf_str.c +++ b/Cryptlib/OpenSSL/crypto/buffer/buf_str.c @@ -58,6 +58,7 @@ #include <stdio.h> #include "cryptlib.h" +#include <limits.h> #include <openssl/buffer.h> size_t BUF_strnlen(const char *str, size_t maxlen) @@ -72,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)); } @@ -81,16 +82,22 @@ 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; + ret = OPENSSL_malloc(siz + 1); if (ret == NULL) { BUFerr(BUF_F_BUF_STRNDUP, ERR_R_MALLOC_FAILURE); - return (NULL); + return NULL; } - BUF_strlcpy(ret, str, siz + 1); + + memcpy(ret, str, siz); + ret[siz] = '\0'; + return (ret); } @@ -98,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); } |
