about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-04-04 14:48:48 -0400
committerRich Felker <dalias@aerifal.cx>2013-04-04 14:48:48 -0400
commit40b2b5fa94d3ae27293f4d572bdcf1c3a5ef590f (patch)
tree23316881f9eb48de0b7fbd2b46c1292ce877e9e7
parent50d9661d9b231f503b21e9d8787d1411b864d58a (diff)
downloadmusl-40b2b5fa94d3ae27293f4d572bdcf1c3a5ef590f.tar.gz
musl-40b2b5fa94d3ae27293f4d572bdcf1c3a5ef590f.tar.xz
musl-40b2b5fa94d3ae27293f4d572bdcf1c3a5ef590f.zip
fix incorrect range checks in wcsrtombs
negative values of wchar_t need to be treated in the non-ASCII case so
that they can properly generate EILSEQ rather than getting truncated
to 8bit values and stored in the output.
-rw-r--r--src/multibyte/wcsrtombs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/multibyte/wcsrtombs.c b/src/multibyte/wcsrtombs.c
index 2582ac2f..d48a65e7 100644
--- a/src/multibyte/wcsrtombs.c
+++ b/src/multibyte/wcsrtombs.c
@@ -18,7 +18,7 @@ size_t wcsrtombs(char *restrict s, const wchar_t **restrict ws, size_t n, mbstat
 	size_t N = n, l;
 	if (!s) {
 		for (n=0, ws2=*ws; *ws2; ws2++) {
-			if (*ws2 >= 0x80) {
+			if (*ws2 >= 0x80u) {
 				l = wcrtomb(buf, *ws2, 0);
 				if (!(l+1)) return -1;
 				n += l;
@@ -27,7 +27,7 @@ size_t wcsrtombs(char *restrict s, const wchar_t **restrict ws, size_t n, mbstat
 		return n;
 	}
 	while (n>=4 && **ws) {
-		if (**ws >= 0x80) {
+		if (**ws >= 0x80u) {
 			l = wcrtomb(s, **ws, 0);
 			if (!(l+1)) return -1;
 			s += l;
@@ -39,7 +39,7 @@ size_t wcsrtombs(char *restrict s, const wchar_t **restrict ws, size_t n, mbstat
 		(*ws)++;
 	}
 	while (n && **ws) {
-		if (**ws >= 0x80) {
+		if (**ws >= 0x80u) {
 			l = wcrtomb(buf, **ws, 0);
 			if (!(l+1)) return -1;
 			if (l>n) return N-n;