diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-06-28 17:13:31 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-06-29 18:41:46 +0200 |
commit | 452580e5b0f85201006bacb1a697e0c5b7154b76 (patch) | |
tree | 7c9a93aa2829c77d34e8c6c11595cfe55273dc45 /test | |
parent | 475c5bbd1091717411d67b8662320a1b0a8c9e42 (diff) |
coverity #1486532: fix potential NULL dereference in test_mk_file_path()
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15942)
Diffstat (limited to 'test')
-rw-r--r-- | test/testutil/driver.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test/testutil/driver.c b/test/testutil/driver.c index f91d1ab932..8568a51fd7 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -439,11 +439,12 @@ char *test_mk_file_path(const char *dir, const char *file) char *dir_end; char dir_end_sep; # endif - size_t len = strlen(dir) + strlen(sep) + strlen(file) + 1; + size_t dirlen = dir != NULL ? strlen(dir) : 0; + size_t len = dirlen + strlen(sep) + strlen(file) + 1; char *full_file = OPENSSL_zalloc(len); if (full_file != NULL) { - if (dir != NULL && dir[0] != '\0') { + if (dir != NULL && dirlen > 0) { OPENSSL_strlcpy(full_file, dir, len); # ifdef OPENSSL_SYS_VMS /* |