]> www.infradead.org Git - mtd-utils.git/commitdiff
nanddump: check for negative inputs
authorBrian Norris <computersforpeace@gmail.com>
Wed, 1 Dec 2010 07:12:30 +0000 (23:12 -0800)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 2 Dec 2010 03:25:50 +0000 (05:25 +0200)
Includes error messages for negative device offsets and negative lengths,
telling the user what the offending option and value were.

Previous patch left out the "negative" in the error message.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
nanddump.c

index b0dd7dc5e9a879e3f1ceff7aca325f675658b132..6a6f9049a15b0c1fc3ceeca17053b5b15e841774 100644 (file)
@@ -173,6 +173,13 @@ static void process_options(int argc, char * const argv[])
                }
        }
 
+       if (start_addr < 0)
+               errmsg_die("Can't specify negative offset with option -s: %lld",
+                               start_addr);
+
+       if (length < 0)
+               errmsg_die("Can't specify negative length with option -l: %lld", length);
+
        if (quiet && pretty_print) {
                fprintf(stderr, "The quiet and pretty print options are mutually-\n"
                                "exclusive. Choose one or the other.\n");