]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
TLS: Fix X.509 certificate name conversion into empty string
authorJouni Malinen <j@w1.fi>
Sat, 9 Feb 2019 23:51:51 +0000 (01:51 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 11 Feb 2019 00:35:29 +0000 (02:35 +0200)
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 <j@w1.fi>
src/tls/x509v3.c

index f80c9a358bf529bb3b8af5128c3288317c56b4a1..fa4d44229622dc9ece412be3fa43e7fa9125d475 100644 (file)
@@ -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';
 }