]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
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, 9 Jun 2025 20:55:47 +0000 (16:55 -0400)
Prevent the user from specifying group descriptor that result in
invalid/corrupted file systems.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit 326e8ab43503dd9f44338754c84cb03a725ecc49)

misc/mke2fs.c

index 017838d435755a4795a00a02baf11ba82981b424..1b7399a513e694948d42eee991f89df837b7d496 100644 (file)
@@ -883,7 +883,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++;