summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-07-02 18:37:42 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-07-04 02:50:14 +0200
commit54d46a789e3add120708621283f3f1302df7fb1d (patch)
tree0d2e4c80be29f6ac174ba1fc8f8b8c5153f13e5f /src/test
parentstrxcpyx: assert throughout on non-NULL src/dest (diff)
downloadsystemd-54d46a789e3add120708621283f3f1302df7fb1d.tar.xz
systemd-54d46a789e3add120708621283f3f1302df7fb1d.zip
test-strxcpyx: add test for strpcpyf overflow
This fails before 'strxcpyx: don't overflow dest on strpcpyf truncate'.
Diffstat (limited to '')
-rw-r--r--src/test/test-strxcpyx.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c
index 9bea770131..d95945f6b0 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) {