]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdio-common/bug21.c
CVE-2012-3406: Stack overflow in vfprintf [BZ #16617]
[thirdparty/glibc.git] / stdio-common / bug21.c
CommitLineData
26e21e75 1#include <stdio.h>
2084e7ca 2#include <libc-internal.h>
26e21e75
UD
3
4static int
5do_test (void)
6{
7 static const char buf[] = " ";
8 char *str;
9
2084e7ca
JM
10 /* GCC in C99 mode treats %a as the C99 format expecting float *,
11 but glibc with _GNU_SOURCE treats %as as the GNU allocation
12 extension, so resulting in "warning: format '%a' expects argument
13 of type 'float *', but argument 3 has type 'char **'". This
14 applies to the other %as, %aS and %a[] formats below as well. */
15 DIAG_PUSH_NEEDS_COMMENT;
16 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
26e21e75 17 int r = sscanf (buf, "%as", &str);
2084e7ca 18 DIAG_POP_NEEDS_COMMENT;
26e21e75
UD
19 printf ("%d %p\n", r, str);
20
21 return r != -1 || str != NULL;
22}
23
24#define TEST_FUNCTION do_test ()
25#include "../test-skeleton.c"