Merge pull request #6258 from vcaputo/overflow

fix strxcpyx null termination overflows
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2017-07-03 21:29:14 -04:00
committed by GitHub
2 changed files with 35 additions and 4 deletions
+7
View File
@@ -51,6 +51,13 @@ static void test_strpcpyf(void) {
assert_se(streq(target, "space left: 25. foobar"));
assert_se(space_left == 3);
/* test overflow */
s = target;
space_left = strpcpyf(&s, 12, "00 left: %i. ", 999);
assert_se(streq(target, "00 left: 99"));
assert_se(space_left == 0);
assert_se(target[12] == '2');
}
static void test_strpcpyl(void) {