]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
udf: Fix uninitialized array access for some pathnames
authorJan Kara <jack@suse.cz>
Wed, 21 Jun 2023 09:32:35 +0000 (11:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2023 14:35:09 +0000 (16:35 +0200)
[ Upstream commit 028f6055c912588e6f72722d89c30b401bbcf013 ]

For filenames that begin with . and are between 2 and 5 characters long,
UDF charset conversion code would read uninitialized memory in the
output buffer. The only practical impact is that the name may be prepended a
"unification hash" when it is not actually needed but still it is good
to fix this.

Reported-by: syzbot+cd311b1e43cc25f90d18@syzkaller.appspotmail.com
Link: https://lore.kernel.org/all/000000000000e2638a05fe9dc8f9@google.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/udf/unicode.c

index 61a1738895b7a733e1c84897beaa5b467de2c52c..ad04dc22783394b2d02b94ad3b9304b65855397e 100644 (file)
@@ -268,7 +268,7 @@ static int udf_name_from_CS0(uint8_t *str_o, int str_max_len,
        }
 
        if (translate) {
-               if (str_o_len <= 2 && str_o[0] == '.' &&
+               if (str_o_len > 0 && str_o_len <= 2 && str_o[0] == '.' &&
                    (str_o_len == 1 || str_o[1] == '.'))
                        needsCRC = 1;
                if (needsCRC) {