]> www.infradead.org Git - users/jedix/linux-maple.git/commit
udf: Check output buffer length when converting name to CS0
authorAndrew Gabbasov <andrew_gabbasov@mentor.com>
Thu, 24 Dec 2015 16:25:33 +0000 (10:25 -0600)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:43:50 +0000 (15:43 -0700)
commitcdb371e00f01970804c4ffacf00f1928c47be79b
treea4a8e7ce59b362fa2bc05d596bc622a71797c4d3
parent6409d32af2995c3e72444d8bbcec6d1d4564823c
udf: Check output buffer length when converting name to CS0

Orabug: 23330617

[ Upstream commit bb00c898ad1ce40c4bb422a8207ae562e9aea7ae ]

If a name contains at least some characters with Unicode values
exceeding single byte, the CS0 output should have 2 bytes per character.
And if other input characters have single byte Unicode values, then
the single input byte is converted to 2 output bytes, and the length
of output becomes larger than the length of input. And if the input
name is long enough, the output length may exceed the allocated buffer
length.

All this means that conversion from UTF8 or NLS to CS0 requires
checking of output length in order to stop when it exceeds the given
output buffer size.

[JK: Make code return -ENAMETOOLONG instead of silently truncating the
name]

CC: stable@vger.kernel.org
Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 516a102b0add0610805d0062670b18b1b44ccdda)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
fs/udf/unicode.c