Whamcloud - gitweb
mke2fs, tune2fs: Do not allow the reserved_ratio to be negative
authorTheodore Ts'o <tytso@mit.edu>
Fri, 6 Mar 2009 07:23:59 +0000 (02:23 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 6 Mar 2009 07:25:06 +0000 (02:25 -0500)
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" <tytso@mit.edu>
misc/mke2fs.c
misc/tune2fs.c

index 746d973..15948e0 100644 (file)
@@ -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);
index 887a702..d779611 100644 (file)
@@ -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);