aboutsummaryrefslogtreecommitdiff
path: root/sbin/camcontrol
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2019-09-09 22:08:22 +0000
committerAlexander Motin <mav@FreeBSD.org>2019-09-09 22:08:22 +0000
commit576649b30a31e399e6ac776fbb42ebbde240f2e3 (patch)
tree850c2dbc8d3e7f7ea55860eecfde707ad009326e /sbin/camcontrol
parentfee2a2fa39834d8d5eaa981298fce9d2ed31546d (diff)
downloadsrc-576649b30a31e399e6ac776fbb42ebbde240f2e3.tar.gz
src-576649b30a31e399e6ac776fbb42ebbde240f2e3.zip
Initialize page/subpage in case of `modepage -d`.
Previously without -m parameter it worked mostly by concodence. While there, make page/subpage values validation more strict. MFC after: 5 days Sponsored by: iXsystems, Inc.
Notes
Notes: svn path=/head/; revision=352111
Diffstat (limited to 'sbin/camcontrol')
-rw-r--r--sbin/camcontrol/camcontrol.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index 9a3f77caea4b..4efaa6d24771 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -4549,7 +4549,7 @@ modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
int task_attr, int retry_count, int timeout)
{
char *str_subpage;
- int c, page = -1, subpage = -1, pc = 0, llbaa = 0;
+ int c, page = -1, subpage = 0, pc = 0, llbaa = 0;
int binary = 0, cdb_len = 10, dbd = 0, desc = 0, edit = 0, list = 0;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
@@ -4575,11 +4575,9 @@ modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
page = strtol(optarg, NULL, 0);
if (str_subpage)
subpage = strtol(str_subpage, NULL, 0);
- else
- subpage = 0;
- if (page < 0)
+ if (page < 0 || page > 0x3f)
errx(1, "invalid mode page %d", page);
- if (subpage < 0)
+ if (subpage < 0 || subpage > 0xff)
errx(1, "invalid mode subpage %d", subpage);
break;
case 'D':
@@ -4598,7 +4596,10 @@ modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
}
}
- if (page == -1 && desc == 0 && list == 0)
+ if (desc && page == -1)
+ page = SMS_ALL_PAGES_PAGE;
+
+ if (page == -1 && list == 0)
errx(1, "you must specify a mode page!");
if (dbd && desc)