[PATCH] Detect too-large stride or stripe-width specification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
 misc/mke2fs.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 857d345..144e11a 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -799,13 +799,17 @@ static void parse_extended_opts(struct ext2_super_block *param,
 			arg++;
 		}
 		if (strcmp(token, "stride") == 0) {
+			unsigned long stride;
+
 			if (!arg) {
 				r_usage++;
 				badopt = token;
 				continue;
 			}
-			param->s_raid_stride = strtoul(arg, &p, 0);
-			if (*p || (param->s_raid_stride == 0)) {
+			stride = strtoul(arg, &p, 0);
+			param->s_raid_stride = stride;
+			/* check for invalid or too-large stride */
+			if (*p || (param->s_raid_stride != stride)) {
 				fprintf(stderr,
 					_("Invalid stride parameter: %s\n"),
 					arg);
@@ -814,13 +818,17 @@ static void parse_extended_opts(struct ext2_super_block *param,
 			}
 		} else if (strcmp(token, "stripe-width") == 0 ||
 			   strcmp(token, "stripe_width") == 0) {
+			unsigned long stripe_width;
+
 			if (!arg) {
 				r_usage++;
 				badopt = token;
 				continue;
 			}
-			param->s_raid_stripe_width = strtoul(arg, &p, 0);
-			if (*p || (param->s_raid_stripe_width == 0)) {
+			stripe_width = strtoul(arg, &p, 0);
+			param->s_raid_stripe_width = stripe_width;
+			/* check for invalid or too-large stripe width */
+			if (*p || (param->s_raid_stripe_width != stripe_width)) {
 				fprintf(stderr,
 					_("Invalid stripe-width parameter: %s\n"),
 					arg);
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux