From: stsp Date: Mon, 8 Feb 2021 19:05:05 +0000 (+0000) Subject: Make bioctl properly verify raidlevels specified via the -c option. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f1c55410fda2b0d125a0102e4c78ba4b89e335c2;p=openbsd Make bioctl properly verify raidlevels specified via the -c option. Trailing characters in the option argument were ignored, such that -cC1 (typo of -c1C) was interpreted as -cC instead of being rejected. ok jsing@ --- diff --git a/sbin/bioctl/bioctl.c b/sbin/bioctl/bioctl.c index 2d2146bb30f..58561e5f30f 100644 --- a/sbin/bioctl/bioctl.c +++ b/sbin/bioctl/bioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioctl.c,v 1.146 2021/02/08 11:20:03 stsp Exp $ */ +/* $OpenBSD: bioctl.c,v 1.147 2021/02/08 19:05:05 stsp Exp $ */ /* * Copyright (c) 2004, 2005 Marco Peereboom @@ -133,6 +133,8 @@ main(int argc, char *argv[]) func |= BIOC_CREATERAID; if (strcmp(optarg, "1C") == 0) { cr_level = 0x1C; + } else if (strlen(optarg) != 1) { + errx(1, "Invalid RAID level"); } else if (isdigit((unsigned char)*optarg)) { cr_level = strtonum(optarg, 0, 10, &errstr); if (errstr != NULL)