libutil/iconv: don't allow wtf-8 surrogate pairs
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 5 Jul 2023 01:26:12 +0000 (13:26 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 26 Oct 2023 01:24:32 +0000 (01:24 +0000)
commit949fe5707774fdc655b8430b0de805aa21004622
tree249067c917d42653dc84d5614b0622a9597f6464
parentd7481f94e0fa0708250e9ab761559c28f83ecade
libutil/iconv: don't allow wtf-8 surrogate pairs

At present, if we meet a string like "hello \xed\xa7\x96 world", the
bytes in the middle will be converted into half of a surrogate pair,
and the UTF-16 will be invalid. It is better to error out immediately,
because the UTF-8 string is already invalid.

https://learn.microsoft.com/en-us/windows/win32/api/Stringapiset/nf-stringapiset-widechartomultibyte#remarks
is a citation for the statement about this being a pre-Vista
problem.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/charset/iconv.c