From: Theodore Ts'o Date: Mon, 26 May 2025 16:51:49 +0000 (-0400) Subject: mke2fs: add range checks for -E desc_size X-Git-Tag: archive/debian/1.47.2-2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c88e60327bafbce359a0ad6f0025bda403e2ee7;p=thirdparty%2Fe2fsprogs.git mke2fs: add range checks for -E desc_size Prevent the user from specifying group descriptor that result in invalid/corrupted file systems. Signed-off-by: Theodore Ts'o (cherry picked from commit 326e8ab43503dd9f44338754c84cb03a725ecc49) --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 017838d4..1b7399a5 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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++;