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>
l += 2;
else
l = (l+3) & ~3;
+ if (l > 255)
+ l = 255;
str[l-2] = '~';
str[l-1] = '0';
*len = l;