From owner-svn-src-all@freebsd.org Sun Feb 3 14:47:23 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD52D14D0EBD; Sun, 3 Feb 2019 14:47:23 +0000 (UTC) (envelope-from gonzo@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 E7D1F71663; Sun, 3 Feb 2019 14:47:22 +0000 (UTC) (envelope-from gonzo@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 DD4C9200A5; Sun, 3 Feb 2019 14:47:22 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x13ElMoB011144; Sun, 3 Feb 2019 14:47:22 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x13ElMwC011143; Sun, 3 Feb 2019 14:47:22 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201902031447.x13ElMwC011143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Sun, 3 Feb 2019 14:47:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r343714 - stable/12/usr.bin/systat X-SVN-Group: stable-12 X-SVN-Commit-Author: gonzo X-SVN-Commit-Paths: stable/12/usr.bin/systat X-SVN-Commit-Revision: 343714 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E7D1F71663 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] 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: Sun, 03 Feb 2019 14:47:24 -0000 Author: gonzo Date: Sun Feb 3 14:47:22 2019 New Revision: 343714 URL: https://svnweb.freebsd.org/changeset/base/343714 Log: MFC r343222-r343223, r343338 r343222: Fix crash in systat(4) when certain commands are called without arguments Add check for missing arguments to dsmatchselect and dsselect PR: 219689 Submitted by: Marko Turk r343223: Fix inconsistency in return values introduced by r343222 Consistently return 1 or the case of missing arguments in both functions PR: 219689 X-MFC-With: 343222 r343338: Fix systat's :only command parser for the multiple arguments case According to systat(1) :only option is supposed to accept multiple drives but the parser for its arguments stops after first entry. Fix the parser logic to accept multiple drives. PR: 59220 Reported by: Andy Farkas Modified: stable/12/usr.bin/systat/devs.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/systat/devs.c ============================================================================== --- stable/12/usr.bin/systat/devs.c Sun Feb 3 12:46:27 2019 (r343713) +++ stable/12/usr.bin/systat/devs.c Sun Feb 3 14:47:22 2019 (r343714) @@ -193,6 +193,11 @@ dsmatchselect(const char *args, devstat_select_mode se int i; int retval = 0; + if (!args) { + warnx("dsmatchselect: no arguments"); + return(1); + } + /* * Break the (pipe delimited) input string out into separate * strings. @@ -251,6 +256,11 @@ dsselect(const char *args, devstat_select_mode select_ int i; int retval = 0; + if (!args) { + warnx("dsselect: no argument"); + return(1); + } + /* * If we've gone through this code before, free previously * allocated resources. @@ -278,7 +288,7 @@ dsselect(const char *args, devstat_select_mode select_ ; if (*cp) *cp++ = '\0'; - if (cp - args == 0) + if (cp - tmpstr1 == 0) break; for (i = 0; i < num_devices; i++) { asprintf(&buffer, "%s%d", dev_select[i].device_name, @@ -302,7 +312,7 @@ dsselect(const char *args, devstat_select_mode select_ } if (i >= num_devices) error("%s: unknown drive", args); - args = cp; + tmpstr1 = cp; } free(tmpstr);