]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fs/nls: Fix utf16 to utf8 conversion
authorArmin Wolf <W_Armin@gmx.de>
Tue, 11 Nov 2025 13:11:22 +0000 (14:11 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 18 Nov 2025 09:18:06 +0000 (11:18 +0200)
commit25524b6190295577e4918c689644451365e6466d
treeefc6b6375c109b3db62c74174537be73bddfb378
parent39ae6c50e599aa0cf62ea3d0dcf06492f7690ed7
fs/nls: Fix utf16 to utf8 conversion

Currently the function responsible for converting between utf16 and
utf8 strings will ignore any characters that cannot be converted. This
however also includes multi-byte characters that do not fit into the
provided string buffer.

This can cause problems if such a multi-byte character is followed by
a single-byte character. In such a case the multi-byte character might
be ignored when the provided string buffer is too small, but the
single-byte character might fit and is thus still copied into the
resulting string.

Fix this by stop filling the provided string buffer once a character
does not fit. In order to be able to do this extend utf32_to_utf8()
to return useful errno codes instead of -1.

Fixes: 74675a58507e ("NLS: update handling of Unicode")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20251111131125.3379-2-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
fs/nls/nls_base.c