GH680: Reuse strnlen() in strndup()

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
Dmitry-Me 2016-02-15 10:12:40 +03:00 committed by Rich Salz
parent acae59bb29
commit d3c02d844a

View File

@ -133,17 +133,13 @@ char *CRYPTO_strdup(const char *str, const char* file, int line)
char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)
{
const char *cp;
size_t maxlen;
char *ret;
if (str == NULL)
return NULL;
/* Get length. */
for (cp = str, maxlen = s; maxlen-- != 0 && *cp != '\0'; ++cp)
continue;
maxlen = cp - str;
maxlen = OPENSSL_strnlen(str, s)
ret = CRYPTO_malloc(maxlen + 1, file, line);
if (ret) {