]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
crypto: x509: fix unreachable code in X509V3_get_section and X509V3_get_string
authorAnton Moryakov <ant.v.moryakov@gmail.com>
Thu, 22 Jan 2026 14:51:12 +0000 (17:51 +0300)
committerTomas Mraz <tomas@openssl.org>
Mon, 26 Jan 2026 15:27:52 +0000 (16:27 +0100)
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)

crypto/x509/v3_conf.c

index f9350d638130ef8b3f7db23675b1d92b8f3da5d7..343bdf893148823a0978a9822c78aac4103044a1 100644 (file)
@@ -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)