From owner-svn-src-all@freebsd.org Fri Sep 13 15:18:46 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 67DEDF40FA; Fri, 13 Sep 2019 15:18:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46VK6G29fBz3J8J; Fri, 13 Sep 2019 15:18:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2F23890A6; Fri, 13 Sep 2019 15:18:46 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x8DFIkOF045654; Fri, 13 Sep 2019 15:18:46 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8DFIkp1045653; Fri, 13 Sep 2019 15:18:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201909131518.x8DFIkp1045653@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 13 Sep 2019 15:18:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r352293 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sbin/camcontrol X-SVN-Commit-Revision: 352293 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Sep 2019 15:18:46 -0000 Author: mav Date: Fri Sep 13 15:18:45 2019 New Revision: 352293 URL: https://svnweb.freebsd.org/changeset/base/352293 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/11/sbin/camcontrol/camcontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.c Fri Sep 13 15:18:28 2019 (r352292) +++ stable/11/sbin/camcontrol/camcontrol.c Fri Sep 13 15:18:45 2019 (r352293) @@ -4393,7 +4393,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) { @@ -4419,11 +4419,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': @@ -4442,7 +4440,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)