--- embedaddon/libiconv/lib/loop_wchar.h 2012/02/21 22:57:48 1.1.1.1
+++ embedaddon/libiconv/lib/loop_wchar.h 2021/03/17 13:38:46 1.1.1.3
@@ -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
@@ -14,8 +14,7 @@
*
* You should have received a copy of the GNU Library General Public
* License along with the GNU LIBICONV Library; see the file COPYING.LIB.
- * If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301, USA.
+ * If not, see .
*/
/* This file defines three conversion loops:
@@ -25,6 +24,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 +329,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 +411,12 @@ static size_t wchar_to_loop_convert (iconv_t icd,
result += res;
break;
}
+ }
+ incount++;
+ if (incount > *inbytesleft) {
+ /* Incomplete input. */
+ errno = EINVAL;
+ return -1;
}
}
}