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 <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-02-10 01:51:51 +02:00
parent 3eae9766b7
commit 62269c8d8d

View 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';
}