diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-06-22 12:50:52 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-06-23 15:45:17 +0200 |
commit | bfa5f0f574dbdb82be70586f70975d28512f3554 (patch) | |
tree | 776b434772c7fd9f954baa636ac12b263538115b | |
parent | 3ae326d4d8eaaa1d85c7f051cb2a5605f63ae0b2 (diff) |
put_str: Use memcpy instead of strncpy
This fixes a warning from latest gcc.
There is no point in using strncpy here as we
intentionally copy only the string contents without
the terminating NUL. The len is set from strlen().
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18628)
-rw-r--r-- | crypto/property/property_parse.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crypto/property/property_parse.c b/crypto/property/property_parse.c index d512507e6b..ca2bd33381 100644 --- a/crypto/property/property_parse.c +++ b/crypto/property/property_parse.c @@ -577,7 +577,7 @@ static void put_char(char ch, char **buf, size_t *remain, size_t *needed) ++*needed; return; } - if(*remain == 1) + if (*remain == 1) **buf = '\0'; else **buf = ch; @@ -596,16 +596,16 @@ static void put_str(const char *str, char **buf, size_t *remain, size_t *needed) if (*remain == 0) return; - if(*remain < len + 1) + if (*remain < len + 1) len = *remain - 1; - if(len > 0) { - strncpy(*buf, str, len); + if (len > 0) { + memcpy(*buf, str, len); *buf += len; *remain -= len; } - if(len < olen && *remain == 1) { + if (len < olen && *remain == 1) { **buf = '\0'; ++*buf; --*remain; |