Document CVE-2024-2961
[glibc.git] / stdio-common / scanf7.c
blobf568738d7e2d699aebdc0ac6deda867e68c4b89a
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <libc-diag.h>
5 int
6 main (int argc, char *argv[])
8 long long int n;
9 int ret;
11 n = -1;
12 ret = sscanf ("1000", "%lld", &n);
13 printf ("%%lld: ret: %d, n: %Ld\n", ret, n);
14 if (ret != 1 || n != 1000L)
15 abort ();
17 n = -2;
19 /* We are testing a corner case of the scanf format string here. */
20 DIAG_PUSH_NEEDS_COMMENT;
21 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
22 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-extra-args");
24 ret = sscanf ("1000", "%llld", &n);
26 DIAG_POP_NEEDS_COMMENT;
28 printf ("%%llld: ret: %d, n: %Ld\n", ret, n);
29 if (ret > 0 || n >= 0L)
30 abort ();
32 return 0;