Don't allocate more than is needed in BUF_strndup().

This commit is contained in:
Ben Laurie 2014-05-20 13:52:31 +01:00
parent dcca7b13e9
commit d8ac1ea77e

View File

@ -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)
{