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: v1.47.3-rc1~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=326e8ab43503dd9f44338754c84cb03a725ecc49;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 --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 456cf6f1..c84ace7a 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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++;