mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
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:
parent
acae59bb29
commit
d3c02d844a
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user