From: Luca Boccassi Date: Sun, 14 Nov 2021 01:28:42 +0000 (+0000) Subject: test-strxcpyx: check result of snprintf X-Git-Tag: v250-rc1~268^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F21355%2Fhead;p=thirdparty%2Fsystemd.git test-strxcpyx: check result of snprintf --- diff --git a/src/test/test-strxcpyx.c b/src/test/test-strxcpyx.c index 4b6d8ebce30..c68fe3c0644 100644 --- a/src/test/test-strxcpyx.c +++ b/src/test/test-strxcpyx.c @@ -83,10 +83,13 @@ static void test_sd_event_code_migration(void) { char c[100 * DECIMAL_STR_MAX(unsigned) + 1], *p; unsigned i; size_t l; - int o; + int o, r; - for (i = o = 0; i < 100; i++) - o += snprintf(&b[o], sizeof(b) - o, "%u ", i); + for (i = o = 0; i < 100; i++) { + r = snprintf(&b[o], sizeof(b) - o, "%u ", i); + assert_se(r >= 0 && r < (int) sizeof(b) - o); + o += r; + } p = c; l = sizeof(c);