Fix an endless loop in the conversion to wchar_t. From upstream.

ok jasper@, Brad
This commit is contained in:
naddy 2010-02-07 15:25:03 +00:00
parent 9ea359c0cf
commit f3790e41d6
2 changed files with 28 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.32 2009/04/24 18:56:49 naddy Exp $
# $OpenBSD: Makefile,v 1.33 2010/02/07 15:25:03 naddy Exp $
COMMENT= character set conversion library
DISTNAME= libiconv-1.13
PKGNAME= ${DISTNAME}p0
CATEGORIES= converters devel
MASTER_SITES= ${MASTER_SITE_GNU:=libiconv/}

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-lib_loop_wchar_h,v 1.4 2010/02/07 15:25:03 naddy Exp $
--- lib/loop_wchar.h.orig Sat Feb 6 15:02:22 2010
+++ lib/loop_wchar.h Sat Feb 6 15:02:28 2010
@@ -321,7 +321,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 +403,12 @@ static size_t wchar_to_loop_convert (iconv_t icd,
result += res;
break;
}
+ }
+ incount++;
+ if (incount > *inbytesleft) {
+ /* Incomplete input. */
+ errno = EINVAL;
+ return -1;
}
}
}