aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-04-27 13:43:12 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-04-27 13:43:12 -0400
commitbf8ce8ff7a2fc4581e30700c989e228e41a57a47 (patch)
tree97b4719ddde714d8590c8a5fa71e57dbbb7db1e0
parenttests: use a global win object in fork mode when using buffer engine (diff)
downloadefl-bf8ce8ff7a2fc4581e30700c989e228e41a57a47.tar.gz
eina: Provide actual len (after possible truncation) to eina_stringshare_add_length
Summary: vsnprintf() returns "The number of characters that would have been written if n had been sufficiently large", so if this is larger than the requested length, we pass the requested length to eina_stringshare_add_length, to avoid reading uninitialised memory. Fix https://phab.enlightenment.org/T6903 Reviewers: zmike Subscribers: cedric Maniphest Tasks: https://phab.enlightenment.org/T6903 Differential Revision: https://phab.enlightenment.org/D6011
-rw-r--r--src/lib/eina/eina_stringshare.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/eina/eina_stringshare.c b/src/lib/eina/eina_stringshare.c
index ab9924e69b..9ded069e14 100644
--- a/src/lib/eina/eina_stringshare.c
+++ b/src/lib/eina/eina_stringshare.c
@@ -679,6 +679,8 @@ eina_stringshare_nprintf(unsigned int len, const char *fmt, ...)
if (size < 1)
return "";
+ if (size > len)
+ size = len;
return eina_stringshare_add_length(tmp, size);
}