Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Feb 2019 14:47:22 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@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: r343714 - stable/12/usr.bin/systat
Message-ID:  <201902031447.x13ElMwC011143@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <mt@markoturk.info>
  
  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 <andyf@speednet.com.au>

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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902031447.x13ElMwC011143>