This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! The following program segfaults: #include <stdio.h> #include <locale.h> int main () { char buf[10]; setlocale (LC_ALL, "vi_VN.tcvn"); sprintf (buf, "%.*s", 2, "vi"); } The problem is that TCVN and a bunch of other encodings are using high bits of mbstate_t's __count member for other things, so in this case we end up with negative len. 2003-01-30 Jakub Jelinek <jakub@redhat.com> * stdio-common/vfprintf.c (vfprintf): Only subtract lowest 3 bits of ps.__count. --- libc/stdio-common/vfprintf.c.jj 2003-01-28 01:41:15.000000000 -0500 +++ libc/stdio-common/vfprintf.c 2003-01-30 12:36:00.000000000 -0500 @@ -1185,7 +1185,7 @@ vfprintf (FILE *s, const CHAR_T *format, if (str2 == NULL) \ len = strlen (string); \ else \ - len = str2 - string - (ps.__count); \ + len = str2 - string - (ps.__count & 7); \ } \ } \ else \ Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |