diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-04-23 13:48:09 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-04-23 13:48:09 +0300 |
commit | c48ce65e277fab7bd4968dad4cc0471df084d7f4 (patch) | |
tree | 4b2f324ae3996e87b11568ad23169c89dd972f76 /ubi-utils/new-utils/src | |
parent | 898b17afb2611359467b1585578758cb633c4b9a (diff) |
mtd-utils: fix input parameter checks
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/new-utils/src')
-rw-r--r-- | ubi-utils/new-utils/src/ubiformat.c | 6 | ||||
-rw-r--r-- | ubi-utils/new-utils/src/ubinize.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/ubi-utils/new-utils/src/ubiformat.c b/ubi-utils/new-utils/src/ubiformat.c index dfae415..fe08f6f 100644 --- a/ubi-utils/new-utils/src/ubiformat.c +++ b/ubi-utils/new-utils/src/ubiformat.c @@ -135,13 +135,13 @@ static int parse_opt(int argc, char * const argv[]) case 'O': args.vid_hdr_offs = strtoul(optarg, &endp, 0); - if (endp == optarg || args.vid_hdr_offs < 0) + if (args.vid_hdr_offs < 0 || *endp != '\0' || endp == optarg) return errmsg("bad VID header offset: \"%s\"", optarg); break; case 'e': args.ec = strtoull(optarg, &endp, 0); - if (endp == optarg || args.ec <= 0 || *endp != '\0') + if (args.ec <= 0 || *endp != '\0' || endp == optarg) return errmsg("bad erase counter value: \"%s\"", optarg); if (args.ec >= EC_MAX) return errmsg("too high erase %llu, counter, max is %u", args.ec, EC_MAX); @@ -166,7 +166,7 @@ static int parse_opt(int argc, char * const argv[]) case 'x': args.ubi_ver = strtoul(optarg, &endp, 0); - if (endp == optarg || args.ubi_ver < 0) + if (args.ubi_ver < 0 || *endp != '\0' || endp == optarg) return errmsg("bad UBI version: \"%s\"", optarg); break; diff --git a/ubi-utils/new-utils/src/ubinize.c b/ubi-utils/new-utils/src/ubinize.c index cd4952d..704d906 100644 --- a/ubi-utils/new-utils/src/ubinize.c +++ b/ubi-utils/new-utils/src/ubinize.c @@ -191,19 +191,19 @@ static int parse_opt(int argc, char * const argv[]) case 'O': args.vid_hdr_offs = strtoul(optarg, &endp, 0); - if (endp == optarg || args.vid_hdr_offs < 0) + if (*endp != '\0' || endp == optarg || args.vid_hdr_offs < 0) return errmsg("bad VID header offset: \"%s\"", optarg); break; case 'e': args.ec = strtoul(optarg, &endp, 0); - if (endp == optarg || args.ec < 0) + if (*endp != '\0' || endp == optarg || args.ec < 0) return errmsg("bad erase counter value: \"%s\"", optarg); break; case 'x': args.ubi_ver = strtoul(optarg, &endp, 0); - if (endp == optarg || args.ubi_ver < 0) + if (*endp != '\0' || endp == optarg || args.ubi_ver < 0) return errmsg("bad UBI version: \"%s\"", optarg); break; |