This is the mail archive of the libc-hacker@sourceware.cygnus.com 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]

A patch for libio


Hi, Ulrich,

This is a patch for glibc 2.0.7. Could you please check glibc 2.1 has
the same bug?

BTW, what happened to my libstdc++ patch?

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
----
Sun Aug 23 09:36:54 1998  H.J. Lu  (hjl@gnu.org)

	* libio/vsnprintf.c (_IO_vsnprintf): Clear "string" if "maxlen"
	is 1.

Index: libio/vsnprintf.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc-2.0/libio/vsnprintf.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 vsnprintf.c
--- vsnprintf.c	1997/09/19 18:10:38	1.1.1.1
+++ vsnprintf.c	1998/08/23 16:35:11
@@ -45,6 +45,10 @@ _IO_vsnprintf (string, maxlen, format, a
 
   _IO_init ((_IO_FILE *) &sf, 0);
   _IO_JUMPS ((_IO_FILE *) &sf) = &_IO_str_jumps;
+  if (maxlen == 1)
+    /* This is a very special case since _IO_str_init_static () will
+       use strlen (string) for the size of string if maxlen - 1 == 0. */
+    string [0] = '\0';
   _IO_str_init_static ((_IO_FILE *) &sf, string, maxlen - 1, string);
   ret = _IO_vfprintf ((_IO_FILE *) &sf, format, args);
   *((_IO_FILE *) &sf)->_IO_write_ptr = '\0';


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