This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.13-28-g84a4211
- From: drepper at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 20 Feb 2011 13:00:21 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.13-28-g84a4211
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 84a4211850e3d23a9d3a4f3b294752a3b30bc0ff (commit)
from e23fe25b33324a9ea992276c1a4f04127bf9ba4b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=84a4211850e3d23a9d3a4f3b294752a3b30bc0ff
commit 84a4211850e3d23a9d3a4f3b294752a3b30bc0ff
Author: Petr Baudis <pasky@suse.cz>
Date: Sun Feb 20 07:59:49 2011 -0500
Fix allocation when handling positional parameters in printf.
diff --git a/ChangeLog b/ChangeLog
index b47a013..77de743 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-27 Petr Baudis <pasky@suse.cz>
+ Ulrich Drepper <drepper@gmail.com>
+
+ * stdio-common/vfprintf.c (vfprintf): Pass correct newlen
+ to extend_alloca().
+ * stdio-common/bug23.c: New file.
+ * stdio-common/Makefile (tests): Add bug23.
+
2010-09-28 Andreas Schwab <schwab@redhat.com>
Ulrich Drepper <drepper@gmail.com>
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 6aabfb6..6c71f1c 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -60,7 +60,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21 bug22 \
- scanf16 scanf17 tst-setvbuf1 tst-grouping
+ scanf16 scanf17 tst-setvbuf1 tst-grouping bug23
test-srcs = tst-unbputc tst-printf
diff --git a/stdio-common/bug23.c b/stdio-common/bug23.c
new file mode 100644
index 0000000..dcc5428
--- /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"
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index fc370e8..cfa4c30 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -1682,7 +1682,8 @@ do_positional:
{
/* Extend the array of format specifiers. */
struct printf_spec *old = specs;
- specs = extend_alloca (specs, nspecs_max, 2 * nspecs_max);
+ specs = extend_alloca (specs, nspecs_max,
+ 2 * nspecs_max * sizeof (*specs));
/* Copy the old array's elements to the new space. */
memmove (specs, old, nspecs * sizeof (struct printf_spec));
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 8 ++++++++
stdio-common/Makefile | 2 +-
stdio-common/bug23.c | 21 +++++++++++++++++++++
stdio-common/vfprintf.c | 5 +++--
4 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 stdio-common/bug23.c
hooks/post-receive
--
GNU C Library master sources