mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 05:21:51 +08:00
Don't allocate more than is needed in BUF_strndup().
This commit is contained in:
parent
dcca7b13e9
commit
d8ac1ea77e
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user