]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: ubinfo: add parameter check
authorAaron Marcher <me@drkhsh.at>
Tue, 8 Aug 2017 10:53:27 +0000 (12:53 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 10 Aug 2017 09:46:49 +0000 (11:46 +0200)
Adds a check if the UBI device number is specified when passing a volume
name as parameter.

This fixes an issue, where by default an inexistent UBI device named
"ubi-1" is selected because of missing checks.

Signed-off-by: Aaron Marcher <me@drkhsh.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
ubi-utils/ubinfo.c

index 82d4f18623ffe81408fe56e9a631432c59aa2cdd..29530bebf7d4219f6bea5eb4c77a86adcac72b8a 100644 (file)
@@ -399,6 +399,12 @@ int main(int argc, char * const argv[])
                        goto out_libubi;
        }
 
+       if (args.vol_name && args.devn == -1) {
+               errmsg("volume name is specified, but UBI device number is not "
+                          "(use -h for help)\n");
+               goto out_libubi;
+       }
+
        if (args.vol_name) {
                err = get_vol_id_by_name(libubi, args.devn, args.vol_name);
                if (err)