From: Bruno Haible Date: Mon, 13 Jan 2003 15:10:15 +0000 (+0000) Subject: Added assertion. X-Git-Tag: v0.12~1181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b2414ff2123957cb63fd673e584cd0da5c706f7;p=thirdparty%2Fgettext.git Added assertion. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 940df1a6e..5480d193a 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-01-12 Bruno Haible + + * linebreak.c (iconv_string_keeping_offsets): Add an assertion, to + protect against Solaris 2.9 iconv() bug. + 2003-01-10 Bruno Haible * linebreak.c (mbs_possible_linebreaks, mbs_width_linebreaks): diff --git a/lib/linebreak.c b/lib/linebreak.c index 42d0ea10b..8385ed671 100644 --- a/lib/linebreak.c +++ b/lib/linebreak.c @@ -1394,7 +1394,7 @@ iconv_string_length (iconv_t cd, const char *s, size_t n) } /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */ #if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) { char *outptr = tmpbuf; size_t outsize = TMPBUFSIZE; @@ -1435,17 +1435,22 @@ iconv_string_keeping_offsets (iconv_t cd, const char *s, size_t n, outsize = m + extra; while (inptr < s_end) { + const char *saved_inptr; size_t insize; size_t res; offtable[inptr - s] = outptr - t; + saved_inptr = inptr; res = (size_t)(-1); for (insize = 1; inptr + insize <= s_end; insize++) { res = iconv (cd, (ICONV_CONST char **) &inptr, &insize, &outptr, &outsize); if (!(res == (size_t)(-1) && errno == EINVAL)) break; + /* We expect that no input bytes have been consumed so far. */ + if (inptr != saved_inptr) + abort (); } /* After we verified the convertibility and computed the translation's size m, there shouldn't be any conversion error here. */ @@ -1454,7 +1459,7 @@ iconv_string_keeping_offsets (iconv_t cd, const char *s, size_t n, } /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */ #if defined _LIBICONV_VERSION \ - || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) + || !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun) if (iconv (cd, NULL, NULL, &outptr, &outsize) == (size_t)(-1)) abort (); #endif diff --git a/src/ChangeLog b/src/ChangeLog index 7f0c0750d..7d06e2349 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-01-12 Bruno Haible + + * write-po.c (wrap): Add an assertion, to protect against Solaris 2.9 + iconv() bug. + 2003-01-10 Bruno Haible * po-charset.c (po_lex_charset_set): Work around Solaris 2.9 iconv() diff --git a/src/write-po.c b/src/write-po.c index 11386a6d2..59ad5777a 100644 --- a/src/write-po.c +++ b/src/write-po.c @@ -327,6 +327,10 @@ wrap (FILE *fp, const char *line_prefix, const char *name, const char *value, &outptr, &outsize); if (!(res == (size_t)(-1) && errno == EINVAL)) break; + /* We expect that no input bytes have been consumed + so far. */ + if (inptr != ep) + abort (); } if (res == (size_t)(-1)) { @@ -429,6 +433,10 @@ internationalized messages should not contain the `\\%c' escape sequence"), &outptr, &outsize); if (!(res == (size_t)(-1) && errno == EINVAL)) break; + /* We expect that no input bytes have been consumed + so far. */ + if (inptr != ep) + abort (); } if (res == (size_t)(-1)) {