diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2019-11-03 17:34:23 +0100 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2019-11-09 10:49:34 +0100 |
commit | db5cf86535b305378308c58c52596994e1ece1e6 (patch) | |
tree | c86fa77b60c999e0072f796eb88d6ed3817d7185 /crypto/LPdir_unix.c | |
parent | conf_def.c: Avoid calling strlen() in a loop (diff) | |
download | openssl-db5cf86535b305378308c58c52596994e1ece1e6.tar.xz openssl-db5cf86535b305378308c58c52596994e1ece1e6.zip |
Fix a -Warray-bounds gcc warning in OPENSSL_DIR_read
'__builtin_strncpy' offset [275, 4095] from the object at
'direntry' is out of the bounds of referenced subobject 'd_name'
with type 'char[256]' at offset 19
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10343)
Diffstat (limited to 'crypto/LPdir_unix.c')
-rw-r--r-- | crypto/LPdir_unix.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/LPdir_unix.c b/crypto/LPdir_unix.c index f2c8619115..ddf68b576f 100644 --- a/crypto/LPdir_unix.c +++ b/crypto/LPdir_unix.c @@ -131,9 +131,8 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) return 0; } - strncpy((*ctx)->entry_name, direntry->d_name, - sizeof((*ctx)->entry_name) - 1); - (*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0'; + OPENSSL_strlcpy((*ctx)->entry_name, direntry->d_name, + sizeof((*ctx)->entry_name)); #ifdef __VMS if ((*ctx)->expect_file_generations) { char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name); |