diff mbox series

security: openssl: check_common_name initialisation

Message ID 20261009135331.402787-1-stefano.babic@swupdate.org
State Accepted
Headers show
Series security: openssl: check_common_name initialisation | expand

Commit Message

Stefano Babic Oct. 9, 2026, 1:53 p.m. UTC
Common Name is not initialised and if the ASN1_STRING_to_UTF8() function
fails, free is called with a random pointer. Initialize the pointer to
NULL.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 crypto/swupdate_cms_verify_openssl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/crypto/swupdate_cms_verify_openssl.c b/crypto/swupdate_cms_verify_openssl.c
index ab4d255e..2587c09a 100644
--- a/crypto/swupdate_cms_verify_openssl.c
+++ b/crypto/swupdate_cms_verify_openssl.c
@@ -258,7 +258,7 @@  static int check_common_name(X509_NAME *subject, const char *name)
 	while ((i = next_common_name(subject, i)) > -1) {
 		X509_NAME_ENTRY *e = X509_NAME_get_entry(subject, i);
 		ASN1_STRING *d = X509_NAME_ENTRY_get_data(e);
-		unsigned char *cn;
+		unsigned char *cn = NULL;
 		size_t len = strlen(name);
 		bool matches = (ASN1_STRING_to_UTF8(&cn, d) == (int)len)
 				&& (strncmp(name, (const char *)cn, len) == 0);