From 077b070132f2abcd7f70c9e0805206bb77c5bbb8 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Wed, 23 Oct 2024 17:57:14 -0600 Subject: [PATCH 1/2] CID 426427 remove duplicate null checks --- src/x509_str.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x509_str.c b/src/x509_str.c index a659a73d46..e310978283 100644 --- a/src/x509_str.c +++ b/src/x509_str.c @@ -264,7 +264,7 @@ static int X509StoreVerifyCert(WOLFSSL_X509_STORE_CTX* ctx) WOLFSSL_FILETYPE_ASN1); SetupStoreCtxError(ctx, ret); #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) - if (ctx->store && ctx->store->verify_cb) + if (ctx->store->verify_cb) ret = ctx->store->verify_cb(ret >= 0 ? 1 : 0, ctx) == 1 ? 0 : ret; #endif @@ -288,7 +288,7 @@ static int X509StoreVerifyCert(WOLFSSL_X509_STORE_CTX* ctx) } SetupStoreCtxError(ctx, ret); #if defined(OPENSSL_ALL) || defined(WOLFSSL_QT) - if (ctx->store && ctx->store->verify_cb) + if (ctx->store->verify_cb) ret = ctx->store->verify_cb(ret >= 0 ? 1 : 0, ctx) == 1 ? 0 : -1; #endif From 52ba700eb360d7b8a145d89cd8f816bc2ee218b7 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Wed, 23 Oct 2024 18:05:12 -0600 Subject: [PATCH 2/2] CID 426426 code maintainability warning, stored NULL value overwritten before used --- src/x509_str.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/x509_str.c b/src/x509_str.c index e310978283..c3d33b85fb 100644 --- a/src/x509_str.c +++ b/src/x509_str.c @@ -1754,7 +1754,7 @@ WOLF_STACK_OF(WOLFSSL_X509_OBJECT)* wolfSSL_X509_STORE_get0_objects( * simplify cleanup logic handling cert merging above */ for (i = 0; i < wolfSSL_sk_X509_num(cert_stack); i++) { x509 = (WOLFSSL_X509 *)wolfSSL_sk_value(cert_stack, i); - obj = wolfSSL_X509_OBJECT_new(); + obj = wolfSSL_X509_OBJECT_new(); if (obj == NULL) { WOLFSSL_MSG("wolfSSL_X509_OBJECT_new error"); goto err_cleanup; @@ -1766,10 +1766,9 @@ WOLF_STACK_OF(WOLFSSL_X509_OBJECT)* wolfSSL_X509_STORE_get0_objects( } obj->type = WOLFSSL_X509_LU_X509; obj->data.x509 = x509; - x509 = NULL; } - while(wolfSSL_sk_X509_num(cert_stack) > 0) { + while (wolfSSL_sk_X509_num(cert_stack) > 0) { wolfSSL_sk_X509_pop(cert_stack); } #endif @@ -1799,7 +1798,7 @@ WOLF_STACK_OF(WOLFSSL_X509_OBJECT)* wolfSSL_X509_STORE_get0_objects( if (ret != NULL) X509StoreFreeObjList(store, ret); if (cert_stack != NULL) { - while(store->numAdded > 0) { + while (store->numAdded > 0) { wolfSSL_sk_X509_pop(cert_stack); store->numAdded--; }