From: Zbigniew Jędrzejewski-Szmek Date: Sun, 2 Jul 2017 16:37:42 +0000 (-0400) Subject: test-strxcpyx: add test for strpcpyf overflow X-Git-Tag: v234~41^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54d46a789e3add120708621283f3f1302df7fb1d;p=platform%2Fupstream%2Fsystemd.git test-strxcpyx: add test for strpcpyf overflow This fails before 'strxcpyx: don't overflow dest on strpcpyf truncate'. --- diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c index 9bea770..d95945f 100644 --- a/src/test/test-strxcpyx.c +++ b/src/test/test-strxcpyx.c @@ -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) {