From: Ben Laurie Date: Tue, 20 May 2014 12:52:31 +0000 (+0100) Subject: Don't allocate more than is needed in BUF_strndup(). X-Git-Tag: master-post-reformat~799 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d8ac1ea77ea4028e5cd04f6fcde9fc4d883b3101;p=oweals%2Fopenssl.git Don't allocate more than is needed in BUF_strndup(). --- diff --git a/crypto/buffer/buf_str.c b/crypto/buffer/buf_str.c index 11241f8727..a464eb6e25 100644 --- a/crypto/buffer/buf_str.c +++ b/crypto/buffer/buf_str.c @@ -71,9 +71,14 @@ char *BUF_strdup(const char *str) char *BUF_strndup(const char *str, size_t siz) { char *ret; + size_t len; if (str == NULL) return(NULL); + len = strlen(str); + if (siz > len) + siz = len; + ret=OPENSSL_malloc(siz+1); if (ret == NULL) {