Author: pluknet
Date: Mon Apr 4 09:25:27 2011
New Revision: 220319
URL: http://svn.freebsd.org/changeset/base/220319
Log:
Do not increment num_args if strsep(3) returned an empty field.
That fixes devstat_buildmatch(3) crashes with certain strings.
Reported by: arundel
MFC after: 2 weeks
Modified:
head/lib/libdevstat/devstat.c
Modified: head/lib/libdevstat/devstat.c
==============================================================================
--- head/lib/libdevstat/devstat.c Mon Apr 4 08:04:32 2011
(r220318)
+++ head/lib/libdevstat/devstat.c Mon Apr 4 09:25:27 2011
(r220319)
@@ -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) {
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"