Date: Fri, 13 Sep 2019 15:18:29 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r352292 - stable/12/sbin/camcontrol Message-ID: <201909131518.x8DFIT28045578@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Sep 13 15:18:28 2019 New Revision: 352292 URL: https://svnweb.freebsd.org/changeset/base/352292 Log: MFC r352111: 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. Modified: stable/12/sbin/camcontrol/camcontrol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.c Fri Sep 13 15:17:30 2019 (r352291) +++ stable/12/sbin/camcontrol/camcontrol.c Fri Sep 13 15:18:28 2019 (r352292) @@ -4574,7 +4574,7 @@ modepage(struct cam_device *device, int argc, char **a 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) { @@ -4600,11 +4600,9 @@ modepage(struct cam_device *device, int argc, char **a 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': @@ -4623,7 +4621,10 @@ modepage(struct cam_device *device, int argc, char **a } } - 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909131518.x8DFIT28045578>