This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/13446] crash in vfprintf with more than 64 format args and format specifiers


http://sourceware.org/bugzilla/show_bug.cgi?id=13446

--- Comment #3 from Andreas Jaeger <aj at suse dot de> 2011-11-29 10:38:41 UTC ---
The following comment was made to the downstream bugreport
https://bugzilla.novell.com/show_bug.cgi?id=733140#c6 by Christoph Bartoschek:

I would suggest the following patch instead. This way nsize is initialized with
the correct number of bytes. And nspecs_max uses the whole given buffer.

diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 753a5ac..6e026ae 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1683,8 +1683,9 @@ do_positional:
          {
            /* Extend the array of format specifiers.  */
            struct printf_spec *old = specs;
-           specs = extend_alloca (specs, nspecs_max,
-                                  2 * nspecs_max * sizeof (*specs));
+           size_t nsize = nspecs_max * sizeof(*specs);
+           specs = extend_alloca (specs, nsize, 2 * nsize);
+           nspecs_max = nsize/sizeof(*specs);

            /* Copy the old array's elements to the new space.  */
            memmove (specs, old, nspecs * sizeof (struct printf_spec));

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]