diff options
author | pluknet <pluknet@FreeBSD.org> | 2011-04-04 09:25:27 +0000 |
---|---|---|
committer | pluknet <pluknet@FreeBSD.org> | 2011-04-04 09:25:27 +0000 |
commit | 7eb224fc95404347699755306926d136eed33526 (patch) | |
tree | 3012944cc182796c2084e0d168ff77f17ce5f086 /lib/libdevstat | |
parent | 8c3b1b83f91d3ae32e57985dc139f3728564c2f5 (diff) | |
download | FreeBSD-src-7eb224fc95404347699755306926d136eed33526.zip FreeBSD-src-7eb224fc95404347699755306926d136eed33526.tar.gz |
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
Diffstat (limited to 'lib/libdevstat')
-rw-r--r-- | lib/libdevstat/devstat.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libdevstat/devstat.c b/lib/libdevstat/devstat.c index d0ba704..06d2148 100644 --- a/lib/libdevstat/devstat.c +++ b/lib/libdevstat/devstat.c @@ -1014,11 +1014,12 @@ devstat_buildmatch(char *match_str, struct devstat_match **matches, * 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) { |