Don't allocate more than is needed in BUF_strndup().
This commit is contained in:
parent
81ce94f8dc
commit
4ceb430a46
1 changed files with 5 additions and 0 deletions
|
@ -69,9 +69,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 a new issue