egg: Fix null termination behavior of egg_secure_strndup()

Even if the given string is shorter than n, the result should be null
terminated.  This matches the behavior of strndup().
This commit is contained in:
Daiki Ueno 2018-03-29 11:30:55 +02:00
parent 6a99758928
commit ea62c2dcda

View File

@ -1344,6 +1344,7 @@ egg_secure_strndup_full (const char *tag,
len = length + 1;
res = (char *)egg_secure_alloc_full (tag, len, options);
memcpy (res, str, len);
res[length] = '\0';
return res;
}