summaryrefslogtreecommitdiffstats
path: root/crypto/buffer
diff options
context:
space:
mode:
authorBen Laurie <ben@links.org>2014-05-20 13:52:31 +0100
committerBen Laurie <ben@links.org>2014-05-20 13:52:31 +0100
commitd8ac1ea77ea4028e5cd04f6fcde9fc4d883b3101 (patch)
treee03f565155f50fca85d4aa0c3f75573383f64af6 /crypto/buffer
parentdcca7b13e9066443237dd3001ae52fd103151c98 (diff)
Don't allocate more than is needed in BUF_strndup().
Diffstat (limited to 'crypto/buffer')
-rw-r--r--crypto/buffer/buf_str.c5
1 files changed, 5 insertions, 0 deletions
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)
{