shared/strbuf: only clear the bytes that we actually wrote to

The allocated buffes are not known to be written. It is unnecessary to
clear them.

If the user writes sensitive data to those locations, without using
the NMStrBuf API, then it is up to the user to bzero the memory
accordingly.
This commit is contained in:
Thomas Haller 2020-04-06 10:41:36 +02:00
parent d1c2572e11
commit abacc1e919

View file

@ -194,7 +194,7 @@ nm_str_buf_destroy (NMStrBuf *strbuf)
return;
_nm_str_buf_assert (strbuf);
if (strbuf->_do_bzero_mem)
nm_explicit_bzero (strbuf->_str, strbuf->_allocated);
nm_explicit_bzero (strbuf->_str, strbuf->_len);
g_free (strbuf->_str);
/* the buffer is in invalid state afterwards, however, we clear it