Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Apr 2011 08:49:25 +0000 (UTC)
From:      Sergey Kandaurov <pluknet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r220765 - stable/8/lib/libdevstat
Message-ID:  <201104180849.p3I8nPrR064525@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pluknet
Date: Mon Apr 18 08:49:25 2011
New Revision: 220765
URL: http://svn.freebsd.org/changeset/base/220765

Log:
  MFC r220319:
  
   Do not increment num_args if strsep(3) returned an empty field.
   That fixes devstat_buildmatch(3) crashes with certain strings.
  
  Reported by:	arundel

Modified:
  stable/8/lib/libdevstat/devstat.c
Directory Properties:
  stable/8/lib/libdevstat/   (props changed)

Modified: stable/8/lib/libdevstat/devstat.c
==============================================================================
--- stable/8/lib/libdevstat/devstat.c	Mon Apr 18 01:02:43 2011	(r220764)
+++ stable/8/lib/libdevstat/devstat.c	Mon Apr 18 08:49:25 2011	(r220765)
@@ -1014,11 +1014,12 @@ devstat_buildmatch(char *match_str, stru
 	 * Break the (comma delimited) input string out into separate strings.
 	 */
 	for (tempstr = tstr, num_args  = 0; 
-	     (*tempstr = strsep(&match_str, ",")) != NULL && (num_args < 5); 
-	     num_args++)
-		if (**tempstr != '\0')
+	     (*tempstr = strsep(&match_str, ",")) != NULL && (num_args < 5);)
+		if (**tempstr != '\0') {
+			num_args++;
 			if (++tempstr >= &tstr[5])
 				break;
+		}
 
 	/* The user gave us too many type arguments */
 	if (num_args > 3) {



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