summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-06-18 20:29:41 -0400
committerRich Felker <dalias@aerifal.cx>2012-06-18 20:29:41 -0400
commita2f149b5d183a842487cc7c76d63511b67db32f5 (patch)
treed39a3ff2bd3ae04debd7051748869b1a6335c1d2
parentdeb90c79e5c498fbb48de1423df034447f330e38 (diff)
downloadmusl-a2f149b5d183a842487cc7c76d63511b67db32f5.tar.gz
musl-a2f149b5d183a842487cc7c76d63511b67db32f5.tar.bz2
musl-a2f149b5d183a842487cc7c76d63511b67db32f5.tar.xz
musl-a2f149b5d183a842487cc7c76d63511b67db32f5.zip
fix erroneous utf-16 encoding with surrogates in iconv
apparently this was never tested before.
-rw-r--r--src/locale/iconv.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index 30a457f3..c48e45aa 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -336,6 +336,7 @@ size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
}
if (type-UCS2BE < 2U) goto ilseq;
if (*outb < 4) goto toobig;
+ c -= 0x10000;
put_16((void *)*out, (c>>10)|0xd800, totype);
put_16((void *)(*out + 2), (c&0x3ff)|0xdc00, totype);
*out += 4;