--- embedaddon/libiconv/lib/loop_wchar.h 2012/02/21 22:57:48 1.1.1.1 +++ embedaddon/libiconv/lib/loop_wchar.h 2012/05/29 09:29:43 1.1.1.2 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2002, 2005-2006, 2008 Free Software Foundation, Inc. + * Copyright (C) 2000-2002, 2005-2006, 2008-2009, 2011 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it @@ -25,6 +25,15 @@ */ #if HAVE_WCRTOMB || HAVE_MBRTOWC +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . + In some builds of uClibc, is nonexistent and wchar_t is defined + by . */ +# include +# include +# include # include # define BUF_SIZE 64 /* assume MB_LEN_MAX <= 64 */ /* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ @@ -321,7 +330,8 @@ static size_t wchar_to_loop_convert (iconv_t icd, size_t result = 0; while (*inbytesleft > 0) { size_t incount; - for (incount = 1; incount <= *inbytesleft; incount++) { + for (incount = 1; ; ) { + /* Here incount <= *inbytesleft. */ char buf[BUF_SIZE]; const char* inptr = *inbuf; size_t inleft = incount; @@ -402,6 +412,12 @@ static size_t wchar_to_loop_convert (iconv_t icd, result += res; break; } + } + incount++; + if (incount > *inbytesleft) { + /* Incomplete input. */ + errno = EINVAL; + return -1; } } }