[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
glibc 2.2 strftime.c portability bug (Solaris 7 32-bit sparc, ja)
From: |
Paul Eggert |
Subject: |
glibc 2.2 strftime.c portability bug (Solaris 7 32-bit sparc, ja) |
Date: |
Wed, 22 Nov 2000 22:14:10 -0800 (PST) |
I ran into a portability bug with glibc 2.2 strftime.c while testing
GNU fileutils test version 4.0.32, which includes a copy of
strftime.c. The Solaris 7 (32-bit sparc) ja locale uses the EUC
encoding, and in that environment Solaris mbrlen dumps core when given
a size argument of (size_t) -1. This bug is probably my fault -- I
probably introduced it in my 1996 changes to glibc strftime.c but I
never ran into it until this week's testing. Sorry about that. Here
is a patch.
2000-11-22 Paul Eggert <address@hidden>
* lib/strftime.c (my_strftime): Do not invoke mbrlen with a
size of (size_t) -1; it's not portable.
===================================================================
RCS file: lib/strftime.c,v
retrieving revision 4.0.32.0
retrieving revision 4.0.32.1
diff -pu -r4.0.32.0 -r4.0.32.1
--- lib/strftime.c 2000/10/26 09:39:00 4.0.32.0
+++ lib/strftime.c 2000/11/22 15:50:11 4.0.32.1
@@ -515,6 +515,9 @@ my_strftime (s, maxsize, format, tp ut_a
size_t i = 0;
CHAR_T *p = s;
const CHAR_T *f;
+#if DO_MULTIBYTE && !defined COMPILE_WIDE
+ const char *format_end = NULL;
+#endif
zone = NULL;
#if HAVE_TM_ZONE
@@ -607,10 +610,15 @@ my_strftime (s, maxsize, format, tp ut_a
{
mbstate_t mbstate = mbstate_zero;
size_t len = 0;
+ size_t fsize;
+
+ if (! format_end)
+ format_end = f + strlen (f) + 1;
+ fsize = format_end - f;
do
{
- size_t bytes = mbrlen (f + len, (size_t) -1, &mbstate);
+ size_t bytes = mbrlen (f + len, fsize - len, &mbstate);
if (bytes == 0)
break;
- glibc 2.2 strftime.c portability bug (Solaris 7 32-bit sparc, ja),
Paul Eggert <=