public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Fix missing NUL terminator in stdio-common/scanf13 test
@ 2022-10-28 10:18 Szabolcs Nagy
  0 siblings, 0 replies; only message in thread
From: Szabolcs Nagy @ 2022-10-28 10:18 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b866018f54ad0670ee9b930a14ae6e8960b9f4bf

commit b866018f54ad0670ee9b930a14ae6e8960b9f4bf
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Tue Oct 11 14:57:16 2022 +0100

    Fix missing NUL terminator in stdio-common/scanf13 test
    
    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>

Diff:
---
 stdio-common/scanf13.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/stdio-common/scanf13.c b/stdio-common/scanf13.c
index 720224aa05..60aa62a26f 100644
--- a/stdio-common/scanf13.c
+++ b/stdio-common/scanf13.c
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-28 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 10:18 [glibc] Fix missing NUL terminator in stdio-common/scanf13 test Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).