[PATCH] OpenSSL: Do not assume NUL termination when logging DN field mismatch

Xiangfei Ding xfding at google.com
Fri Nov 27 02:35:15 PST 2026


ASN1_STRING_get0_data() is not guaranteed to return a NUL-terminated
string. Pass ASN1_STRING_length(cn) with '%.*s' when logging a DN field
mismatch in match_dn_field().

Signed-off-by: Xiangfei Ding <xfding at google.com>
---
 src/crypto/tls_openssl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/crypto/tls_openssl.c b/src/crypto/tls_openssl.c
index 032bf05f2..47ceeaaba 100644
--- a/src/crypto/tls_openssl.c
+++ b/src/crypto/tls_openssl.c
@@ -2331,8 +2331,9 @@ static int match_dn_field(const X509 *cert, int nid, const char *field,
 		}
 		if (!ret) {
 			wpa_printf(MSG_ERROR,
-				   "OpenSSL: Failed to match %s '%s' with certificate DN field value '%s'",
-				   field, value, ASN1_STRING_get0_data(cn));
+				   "OpenSSL: Failed to match %s '%s' with certificate DN field value '%.*s'",
+				   field, value, ASN1_STRING_length(cn),
+				   ASN1_STRING_get0_data(cn));
 		}
 		break;
 	}
-- 
2.56.1.839.g22a8290db9-goog




More information about the Hostap mailing list