aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2022-08-11 22:16:41 -0400
committerTheodore Ts'o <tytso@mit.edu>2022-08-11 22:25:11 -0400
commit1bd16e790308f92e89a5dfbd40ab9e164fe88aa9 (patch)
tree154f1a4091e2e589c2dd2cd56c21cbcdbce7a6d5
parent6b3edcd191c20b3fb108f0d7564aaa930035d0ab (diff)
downloade2fsprogs-1bd16e790308f92e89a5dfbd40ab9e164fe88aa9.tar.gz
e2fsck: when mutating file name make sure its length never exceeds 255
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>
-rw-r--r--e2fsck/rehash.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 8cc36f24f..210cfdf2f 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -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;