From 54d46a789e3add120708621283f3f1302df7fb1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Jul 2017 12:37:42 -0400 Subject: [PATCH] test-strxcpyx: add test for strpcpyf overflow This fails before 'strxcpyx: don't overflow dest on strpcpyf truncate'. --- src/test/test-strxcpyx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c index 9bea7701314..d95945f6b01 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) { -- 2.47.3