From owner-svn-src-stable-8@FreeBSD.ORG Mon Apr 18 08:49:25 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 932AD1065670; Mon, 18 Apr 2011 08:49:25 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81B8B8FC08; Mon, 18 Apr 2011 08:49:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3I8nP1f064527; Mon, 18 Apr 2011 08:49:25 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3I8nPrR064525; Mon, 18 Apr 2011 08:49:25 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201104180849.p3I8nPrR064525@svn.freebsd.org> From: Sergey Kandaurov Date: Mon, 18 Apr 2011 08:49:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220765 - stable/8/lib/libdevstat X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Apr 2011 08:49:25 -0000 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) {