summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-06-21 12:38:45 +0200
committerThomas Haller <thaller@redhat.com>2020-06-21 22:34:49 +0200
commit98ace1468a2b2c88bd77abaa5e1c52c3bdd4c3e0 (patch)
tree29346a75ec7c5ab6df2b14c002562928acae6904
parent7a3f78d7eb81491c7d830c52483ea2c52dd787fe (diff)
downloadNetworkManager-98ace1468a2b2c88bd77abaa5e1c52c3bdd4c3e0.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') (cherry picked from commit fd34fe50a2100ce5d9440047ec65f25097cb6a32) (cherry picked from commit 28644556e1b98696e7911437def34794041b4608)
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c2
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 5dd099a7c9..44e3d66656 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -4799,7 +4799,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);