diff options
author | Dmitry-Me <wipedout@yandex.ru> | 2016-02-15 10:12:40 +0300 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-02-26 11:26:56 -0500 |
commit | d3c02d844abeaf961bad692cf6f3876ccabf2435 (patch) | |
tree | acaa22f09a0a64e32b6391626dcb8c813dbe15f1 /crypto/o_str.c | |
parent | acae59bb29ddc769743ab4a8ae373b5ff2f42b57 (diff) |
GH680: Reuse strnlen() in strndup()
Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto/o_str.c')
-rw-r--r-- | crypto/o_str.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/crypto/o_str.c b/crypto/o_str.c index b200060917..b01128cdb3 100644 --- a/crypto/o_str.c +++ b/crypto/o_str.c @@ -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) { |