about summary refs log tree commit diff
path: root/stdio-common/bug23.c
diff options
context:
space:
mode:
authorPetr Baudis <pasky@suse.cz>2011-02-20 07:59:49 -0500
committerUlrich Drepper <drepper@gmail.com>2011-02-20 07:59:49 -0500
commit84a4211850e3d23a9d3a4f3b294752a3b30bc0ff (patch)
tree04faa4e3387e0e86f2c0fc9ef47af138f1258006 /stdio-common/bug23.c
parente23fe25b33324a9ea992276c1a4f04127bf9ba4b (diff)
downloadglibc-84a4211850e3d23a9d3a4f3b294752a3b30bc0ff.tar.gz
glibc-84a4211850e3d23a9d3a4f3b294752a3b30bc0ff.tar.xz
glibc-84a4211850e3d23a9d3a4f3b294752a3b30bc0ff.zip
Fix allocation when handling positional parameters in printf.
Diffstat (limited to 'stdio-common/bug23.c')
-rw-r--r--stdio-common/bug23.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/stdio-common/bug23.c b/stdio-common/bug23.c
new file mode 100644
index 0000000000..dcc5428078
--- /dev/null
+++ b/stdio-common/bug23.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <string.h>
+
+static char buf[32768];
+static const char expected[] = "\
+\n\
+a\n\
+abbcd55%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
+
+static int
+do_test (void)
+{
+  snprintf (buf, sizeof (buf),
+	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
+	    "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
+	    "a", "b", "c", "d", 5);
+  return strcmp (buf, expected) != 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"