]> www.infradead.org Git - mtd-utils.git/commitdiff
ubiupdatevol: fix -t parameter
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 17 Dec 2008 10:15:54 +0000 (11:15 +0100)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 20 Jan 2009 13:30:56 +0000 (15:30 +0200)
The execution of
|./ubiupdatevol /dev/ubi0 -t
will fail because 'argv[optind + 1]' is undefined and the later executed
'strcmp(args.img, "-")' will segfault.
So I can hack around and supply a dummy image or fix it that way.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/src/ubiupdatevol.c

index 5eeaa3cafdebe2cd75fa410e59c2255ea5a6b218..c83731c80b473809a161ea0b0dc94793b58824c6 100644 (file)
@@ -157,10 +157,15 @@ static int parse_opt(int argc, char * const argv[])
        args.node = argv[optind];
        args.img  = argv[optind + 1];
 
-       if (strcmp(args.img, "-") == 0)
-               args.use_stdin = 1;
-       if (args.use_stdin && !args.size)
-               return errmsg("file size must be specified if input is stdin");
+       if (args.img && args.truncate)
+               return errmsg("You can't truncate and specify an image (use -h for help)");
+
+       if (args.img && !args.truncate) {
+               if (strcmp(args.img, "-") == 0)
+                       args.use_stdin = 1;
+               if (args.use_stdin && !args.size)
+                       return errmsg("file size must be specified if input is stdin");
+       }
 
        return 0;
 }