Whamcloud - gitweb
mke2fs: add range checks for -E desc_size
authorTheodore Ts'o <tytso@mit.edu>
Mon, 26 May 2025 16:51:49 +0000 (12:51 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 26 May 2025 16:51:49 +0000 (12:51 -0400)
Prevent the user from specifying group descriptor that result in
invalid/corrupted file systems.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/mke2fs.c

index 456cf6f..c84ace7 100644 (file)
@@ -865,7 +865,10 @@ static void parse_extended_opts(struct ext2_super_block *param,
                                continue;
                        }
                        ulong = strtoul(arg, &p, 0);
-                       if (*p || (ulong & (ulong - 1))) {
+                       if (*p ||
+                           (ulong < EXT2_MIN_DESC_SIZE_64BIT) ||
+                           (ulong > EXT2_MAX_DESC_SIZE) ||
+                           (ulong & (ulong - 1))) {
                                fprintf(stderr,
                                        _("Invalid desc_size: '%s'\n"), arg);
                                r_usage++;