]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix missing NUL terminator in stdio-common/scanf13 test
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 11 Oct 2022 13:57:16 +0000 (14:57 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 28 Oct 2022 10:16:51 +0000 (11:16 +0100)
sscanf is only defined on nul terminated string input, but '\0' was
missing in this test which caused _IO_str_init_static_internal to
read OOB on the stack when computing the bounds of the string.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
stdio-common/scanf13.c

index 720224aa05f97abe06d131d0fbd5403e9bc89d57..60aa62a26f161338608dd296fadcd3251b9b3294 100644 (file)
@@ -67,6 +67,7 @@ main (void)
   buf[2049] = 0x84;
   buf[2058] = '\t';
   buf[2059] = 'a';
+  buf[sizeof (buf) - 1] = '\0';
   if (sscanf (buf, "%ms%mc", &sp1, &sp2) != 2)
     FAIL ();
   else