]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps/lib/apps.c: Add a check for OPENSSL_strdup()
authorJiashengJiang <jiasheng@purdue.edu>
Wed, 26 Mar 2025 21:40:16 +0000 (17:40 -0400)
committerTomas Mraz <tomas@openssl.org>
Fri, 28 Mar 2025 10:40:23 +0000 (11:40 +0100)
Add a check for the return value of OPENSSL_strdup() to guarantee the success of allocation, similar to the other call sites.

Fixes: c7d5ea2670 ("Prepare to detect index changes in OCSP responder.")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27172)

(cherry picked from commit 930c645e6b74a09398f6345b2d265c38ff035afe)

apps/lib/apps.c

index 06c1947449a7fa74f79d8d3eb617ecb5f8fad0d7..1b81f3859e0348a69ec26083482468f1c0413a7f 100644 (file)
@@ -1722,6 +1722,9 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
     }
 
     retdb->dbfname = OPENSSL_strdup(dbfile);
+    if (retdb->dbfname == NULL)
+        goto err;
+
 #ifndef OPENSSL_NO_POSIX_IO
     retdb->dbst = dbst;
 #endif