From 8d8224550c1f5b5c77afbf5acd95f73979276a0a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 6 Mar 2009 02:23:59 -0500 Subject: [PATCH] mke2fs, tune2fs: Do not allow the reserved_ratio to be negative Add a check to make sure the argument to the -m option (which specifies the reserved ratio) is greater than zero. Addresses-Debian-Bug: #517015 Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.c | 3 ++- misc/tune2fs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 746d973..15948e0 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1260,7 +1260,8 @@ static void PRS(int argc, char *argv[]) break; case 'm': reserved_ratio = strtod(optarg, &tmp); - if (reserved_ratio > 50 || *tmp) { + if ( *tmp || reserved_ratio > 50 || + reserved_ratio < 0) { com_err(program_name, 0, _("invalid reserved blocks percent - %s"), optarg); diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 887a702..d779611 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -720,7 +720,8 @@ static void parse_tune2fs_options(int argc, char **argv) break; case 'm': reserved_ratio = strtod(optarg, &tmp); - if (*tmp || reserved_ratio > 50) { + if (*tmp || reserved_ratio > 50 || + reserved_ratio < 0) { com_err(program_name, 0, _("bad reserved block ratio - %s"), optarg); -- 1.8.3.1