Commit d2a9af2144 for openssl.org

commit d2a9af2144ac2938619e44af3eaeaed3ea49cb05
Author: olszomal <Malgorzata.Olszowka@stunnel.org>
Date:   Fri Aug 8 12:06:36 2025 +0200

    apps: adjust stat usage to account for uplink

    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)

diff --git a/apps/lib/apps.c b/apps/lib/apps.c
index 2c55c0af21..128c40d086 100644
--- a/apps/lib/apps.c
+++ b/apps/lib/apps.c
@@ -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