diff options
author | Thomas Haller <thaller@redhat.com> | 2020-06-21 12:38:45 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-06-21 12:41:53 +0200 |
commit | fd34fe50a2100ce5d9440047ec65f25097cb6a32 (patch) | |
tree | 71aa32914f58bc6866c224dffc36c066b943da61 | |
parent | 83c79bc7a82ea513574cd08a38115a485921b1fa (diff) | |
download | NetworkManager-fd34fe50a2100ce5d9440047ec65f25097cb6a32.tar.gz |
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: eda47170ed2e ('shared: add NMStrBuf util')
-rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index cb43182c41..39dfe6f473 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -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); |