]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-strxcpyx: check result of snprintf 21355/head
authorLuca Boccassi <luca.boccassi@microsoft.com>
Sun, 14 Nov 2021 01:28:42 +0000 (01:28 +0000)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Sun, 14 Nov 2021 01:28:42 +0000 (01:28 +0000)
src/test/test-strxcpyx.c

index 4b6d8ebce30d4c3196c11e9abcb097281648dc89..c68fe3c06444233aa6f48a3556967cb82cdc3a5c 100644 (file)
@@ -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);