36 lines
1.0 KiB
Diff
36 lines
1.0 KiB
Diff
From 1bd16e790308f92e89a5dfbd40ab9e164fe88aa9 Mon Sep 17 00:00:00 2001
|
|
From: Theodore Ts'o <tytso@mit.edu>
|
|
Date: Thu, 11 Aug 2022 22:16:41 -0400
|
|
Subject: [PATCH] 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>
|
|
---
|
|
e2fsck/rehash.c | 2 ++
|
|
1 file changed, 2 insertions(+)
|
|
|
|
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
|
|
index 8cc36f24..210cfdf2 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;
|
|
--
|
|
2.33.0
|
|
|