]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: when mutating file name make sure its length never exceeds 255
authorTheodore Ts'o <tytso@mit.edu>
Fri, 12 Aug 2022 02:16:41 +0000 (22:16 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 12 Aug 2022 02:25:11 +0000 (22:25 -0400)
E2fsck will attempt to mutate filenames to ensure uniqueness if
necessary.  If there are two unique filenames that are 254 or 255
characters in length and do not contain the '~' character, the
mutate_name() function would create a filename which is 256 bytes
long, which is not a legal filename in Linux.  Adjust the mutate_name
function to avoid this possibility.

Addresses-Coverity-Bug: 1500768
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/rehash.c

index 8cc36f24fc0ba72b16bd40644e4b3213458c77a8..210cfdf2f425ca413b6222212dedc9da707b939a 100644 (file)
@@ -414,6 +414,8 @@ static void mutate_name(char *str, unsigned int *len)
                        l += 2;
                else
                        l = (l+3) & ~3;
+               if (l > 255)
+                       l = 255;
                str[l-2] = '~';
                str[l-1] = '0';
                *len = l;