Commit d3c02d84 authored by Dmitry-Me's avatar Dmitry-Me Committed by Rich Salz
Browse files

GH680: Reuse strnlen() in strndup()



Signed-off-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent acae59bb
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -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) {