This is the mail archive of the libc-alpha@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]

glibc strftime.c bug: assumes subformats yield nonempty buffers


While fixing the other bugs, I noticed by code inspection that glibc
strftime's subformat code assumes that subformats yield nonempty
strings.  This isn't true e.g. if the subformat is "%p" and %p yields
the empty string in this locale.  Here is a patch.


1998-09-24  Paul Eggert  <eggert@twinsun.com>

	* strftime.c (my_strftime): When asking for the length of the
	subformatted buffer, do not limit the length to look for;
	otherwise, we have no reliable way to distinguish between the
	empty buffer and an error.

--- strftime.c	1998/09/24 20:46:02	2.0.96.4
+++ strftime.c	1998/09/24 20:51:19	2.0.96.5
@@ -717,7 +717,5 @@ my_strftime (s, maxsize, format, tp)
 	  {
 	    char *old_start = p;
-	    size_t len = my_strftime (NULL, maxsize - i, subfmt, tp);
-	    if (len == 0 && *subfmt)
-	      return 0;
+	    size_t len = my_strftime (NULL, (size_t) -1, subfmt, tp);
 	    add (len, my_strftime (p, maxsize - i, subfmt, tp));
 


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