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 T6903

Reviewers: zmike

Subscribers: cedric

Maniphest Tasks: T6903

Differential Revision: https://phab.enlightenment.org/D6011
This commit is contained in:
Xavi Artigas 2018-04-27 13:43:12 -04:00 committed by Mike Blumenkrantz
parent 0cf63649c7
commit bf8ce8ff7a
1 changed files with 2 additions and 0 deletions

View File

@ -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);
}