Commit a3e67efa01 for openssl.org

commit a3e67efa015ca68f2e2be00889d92612f5bb5040
Author: Anton Moryakov <ant.v.moryakov@gmail.com>
Date:   Thu Jan 22 17:51:12 2026 +0300

    crypto: x509: fix unreachable code in X509V3_get_section and X509V3_get_string

    The functions X509V3_get_section() and X509V3_get_string() contain a
    redundant null check after an identical check has already guaranteed
    that the function pointer (ctx->db_meth->get_section / get_string) is
    non-NULL. As a result, the final 'return NULL;' statement is unreachable.

    This change removes the redundant condition and the dead code, improving
    code clarity and eliminating warnings from static analyzers.

    Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>

    Reviewed-by: Paul Dale <paul.dale@oracle.com>
    Reviewed-by: Tim Hudson <tjh@openssl.org>
    MergeDate: Mon Jan 26 15:28:01 2026
    (Merged from https://github.com/openssl/openssl/pull/29692)

diff --git a/crypto/x509/v3_conf.c b/crypto/x509/v3_conf.c
index f9350d6381..343bdf8931 100644
--- a/crypto/x509/v3_conf.c
+++ b/crypto/x509/v3_conf.c
@@ -399,9 +399,7 @@ char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section)
         ERR_raise(ERR_LIB_X509V3, X509V3_R_OPERATION_NOT_DEFINED);
         return NULL;
     }
-    if (ctx->db_meth->get_string)
-        return ctx->db_meth->get_string(ctx->db, name, section);
-    return NULL;
+    return ctx->db_meth->get_string(ctx->db, name, section);
 }

 STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section)
@@ -410,9 +408,7 @@ STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section)
         ERR_raise(ERR_LIB_X509V3, X509V3_R_OPERATION_NOT_DEFINED);
         return NULL;
     }
-    if (ctx->db_meth->get_section)
-        return ctx->db_meth->get_section(ctx->db, section);
-    return NULL;
+    return ctx->db_meth->get_section(ctx->db, section);
 }

 void X509V3_string_free(X509V3_CTX *ctx, char *str)