mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 06:10:14 +01:00
shared: fix string truncation in nm_str_buf_append_printf()
If g_vsnprintf() returns that it wants to write 5 characters, it
really needs space for 5+1 characters. If we have 5 characters
available, it would have written "0123\0", which leaves the buffer
broken.
Fixes: eda47170ed ('shared: add NMStrBuf util')
This commit is contained in:
parent
83c79bc7a8
commit
fd34fe50a2
1 changed files with 1 additions and 1 deletions
|
|
@ -4871,7 +4871,7 @@ nm_str_buf_append_printf (NMStrBuf *strbuf,
|
|||
nm_assert (l >= 0);
|
||||
nm_assert (l < G_MAXINT);
|
||||
|
||||
if ((gsize) l > available) {
|
||||
if ((gsize) l >= available) {
|
||||
gsize l2 = ((gsize) l) + 1u;
|
||||
|
||||
nm_str_buf_maybe_expand (strbuf, l2, FALSE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue