diff options
author | johan <johan@FreeBSD.org> | 2003-11-05 21:56:21 +0000 |
---|---|---|
committer | johan <johan@FreeBSD.org> | 2003-11-05 21:56:21 +0000 |
commit | 6422f144d7e95bd0991e5d5e5e53ed1a0b49f64c (patch) | |
tree | 0e18f21bc670f35453d3411188d6b13a8dab0042 /sbin/atacontrol/atacontrol.c | |
parent | e5c6a5c246ff74b9a31b10c66c0b635f0d9db980 (diff) | |
download | FreeBSD-src-6422f144d7e95bd0991e5d5e5e53ed1a0b49f64c.zip FreeBSD-src-6422f144d7e95bd0991e5d5e5e53ed1a0b49f64c.tar.gz |
Make sure argv[x] exists before using it.
PR: 56696
Reported by: Igor Truszkowski <igort@intergate.pl>
Submitted by: maxim@
Approved by: sos@
MFC after: 2 weeks
Diffstat (limited to 'sbin/atacontrol/atacontrol.c')
-rw-r--r-- | sbin/atacontrol/atacontrol.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c index 7e6d8b0..d5440d6 100644 --- a/sbin/atacontrol/atacontrol.c +++ b/sbin/atacontrol/atacontrol.c @@ -348,14 +348,19 @@ main(int argc, char **argv) int disk, dev, offset; iocmd.cmd = ATARAIDCREATE; - if (!strcmp(argv[2], "RAID0") || !strcmp(argv[2], "stripe")) - iocmd.u.raid_setup.type = 1; - if (!strcmp(argv[2], "RAID1") || !strcmp(argv[2],"mirror")) - iocmd.u.raid_setup.type = 2; - if (!strcmp(argv[2], "RAID0+1")) - iocmd.u.raid_setup.type = 3; - if (!strcmp(argv[2], "SPAN") || !strcmp(argv[2], "JBOD")) - iocmd.u.raid_setup.type = 4; + if (argc > 2) { + if (!strcmp(argv[2], "RAID0") || + !strcmp(argv[2], "stripe")) + iocmd.u.raid_setup.type = 1; + if (!strcmp(argv[2], "RAID1") || + !strcmp(argv[2],"mirror")) + iocmd.u.raid_setup.type = 2; + if (!strcmp(argv[2], "RAID0+1")) + iocmd.u.raid_setup.type = 3; + if (!strcmp(argv[2], "SPAN") || + !strcmp(argv[2], "JBOD")) + iocmd.u.raid_setup.type = 4; + } if (!iocmd.u.raid_setup.type) { fprintf(stderr, "atacontrol: Invalid RAID type\n"); fprintf(stderr, "atacontrol: Valid RAID types : \n"); @@ -365,7 +370,8 @@ main(int argc, char **argv) } if (iocmd.u.raid_setup.type & 1) { - if (!sscanf(argv[3], "%d", + if (argc < 4 || + !sscanf(argv[3], "%d", &iocmd.u.raid_setup.interleave) == 1) { fprintf(stderr, "atacontrol: Invalid interleave\n"); exit(EX_USAGE); |