]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps: adjust stat usage to account for uplink
authorolszomal <Malgorzata.Olszowka@stunnel.org>
Fri, 8 Aug 2025 10:06:36 +0000 (12:06 +0200)
committerEugene Syromiatnikov <esyr@openssl.org>
Wed, 8 Jul 2026 09:28:33 +0000 (11:28 +0200)
Call stat() instead of fstat() when the FILE pointer provided
by BIO_get_fp() is unavailable (as it may be the case in case of UPLINK
builds).

Signed-off-by: olszomal <Malgorzata.Olszowka@stunnel.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Wed Jul  8 09:47:42 2026
(Merged from https://github.com/openssl/openssl/pull/28172)

apps/lib/apps.c

index 2c55c0af21e48443ca4d0e3ca6d057a24be93ba1..128c40d0869a954f1c157dbf4bde29009269431c 100644 (file)
@@ -1849,11 +1849,18 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
         goto err;
 
 #ifndef OPENSSL_NO_POSIX_IO
-    BIO_get_fp(in, &dbfp);
-    if (fstat(fileno(dbfp), &dbst) == -1) {
-        ERR_raise_data(ERR_LIB_SYS, errno,
-            "calling fstat(%s)", dbfile);
-        goto err;
+    if (BIO_get_fp(in, &dbfp) > 0 && dbfp != NULL) {
+        if (fstat(fileno(dbfp), &dbst) == -1) {
+            ERR_raise_data(ERR_LIB_SYS, errno,
+                "calling fstat(%s)", dbfile);
+            goto err;
+        }
+    } else {
+        if (stat(dbfile, &dbst) == -1) {
+            ERR_raise_data(ERR_LIB_SYS, errno,
+                "calling stat(%s)", dbfile);
+            goto err;
+        }
     }
 #endif