From 62269c8d8d7909bbc6c0f61fd55c6ae52badb164 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 10 Feb 2019 01:51:51 +0200 Subject: [PATCH] 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 --- src/tls/x509v3.c | 2 ++ 1 file changed, 2 insertions(+) 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'; }