g_strlcat(): Possible buffer overflow in implementation
Hi,
For later Windows Visual Studio CRT (8 [2005] and later), the CRT is toughened with checks to ensure that we don't do buffer overflows, which is exposed in the g_strlcat() implementation (Windows does not have a system implementation of strlcat()/strlcpy()) when running the strfuncs.c test program, specifically in the following test:
str_cpy_size = g_strlcat (str_cpy, str, strlen (str) + 15);
g_assert_nonnull (str_cpy);
g_assert_cmpstr ("The quick brown fox jumps over the lazy dogThe quick brow",
==, str_cpy);
g_assert_cmpint (str_cpy_size, ==, 2 * strlen (str));
(circa lines 363 to 368 in glib/tests/strfuncs.c).
As a result, a CRT abort is triggered as it detected a buffer overflow when running this code portion, so might need to look in the implementation of g_strlcat() to see how we avoid getting into this issue.
With blessings, thank you!