From: Jouni Malinen Date: Sat, 9 Feb 2019 23:51:51 +0000 (+0200) Subject: TLS: Fix X.509 certificate name conversion into empty string X-Git-Tag: hostap_2_8~390 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62269c8d8d7909bbc6c0f61fd55c6ae52badb164;p=thirdparty%2Fhostap.git TLS: Fix X.509 certificate name conversion into empty string If none of the supported name attributes are present, the name string was nul terminated only at the end. Add an explicit nul termination at the end of the last written (or beginning of the buffer, if nothing is written) to avoid writing uninitialized data to debug log. Signed-off-by: Jouni Malinen --- diff --git a/src/tls/x509v3.c b/src/tls/x509v3.c index f80c9a358..fa4d44229 100644 --- a/src/tls/x509v3.c +++ b/src/tls/x509v3.c @@ -532,6 +532,8 @@ void x509_name_string(struct x509_name *name, char *buf, size_t len) } done: + if (pos < end) + *pos = '\0'; end[-1] = '\0'; }