Skip to content

Commit

Permalink
Fix two printf handler issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubjelinek authored and drepper committed Feb 15, 2011
1 parent edf9294 commit c1d0e63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2011-02-11 Jakub Jelinek <jakub@redhat.com>

* stdio-common/printf-parsemb.c (__parse_one_specmb): Handle
arginfo fn returning -1.

* stdio-common/_i18n_number.h (_i18n_number_rewrite): Ensure decimal
and thousands string is zero terminated.

2011-02-03 Andreas Schwab <schwab@redhat.com>

* sysdeps/unix/sysv/linux/sparc/bits/socket.h: Sync with
Expand Down
14 changes: 10 additions & 4 deletions stdio-common/_i18n_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
# define decimal NULL
# define thousands NULL
#else
char decimal[MB_LEN_MAX];
char thousands[MB_LEN_MAX];
char decimal[MB_LEN_MAX + 1];
char thousands[MB_LEN_MAX + 1];
#endif

/* "to_outpunct" is a map from ASCII decimal point and thousands-sep
Expand All @@ -47,13 +47,19 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
mbstate_t state;
memset (&state, '\0', sizeof (state));

if (__wcrtomb (decimal, wdecimal, &state) == (size_t) -1)
size_t n = __wcrtomb (decimal, wdecimal, &state);
if (n == (size_t) -1)
memcpy (decimal, ".", 2);
else
decimal[n] = '\0';

memset (&state, '\0', sizeof (state));

if (__wcrtomb (thousands, wthousands, &state) == (size_t) -1)
n = __wcrtomb (thousands, wthousands, &state);
if (n == (size_t) -1)
memcpy (thousands, ",", 2);
else
thousands[n] = '\0';
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions stdio-common/printf-parsemb.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
/* We don't try to get the types for all arguments if the format
uses more than one. The normal case is covered though. If
the call returns -1 we continue with the normal specifiers. */
|| (spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
(&spec->info, 1, &spec->data_arg_type,
&spec->size)) < 0)
|| (int) (spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
(&spec->info, 1, &spec->data_arg_type,
&spec->size)) < 0)
{
/* Find the data argument types of a built-in spec. */
spec->ndata_args = 1;
Expand Down

0 comments on commit c1d0e63

Please sign in to comment.