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
This commit is contained in:
parent
4c506522c1
commit
1046090f1f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220319
@ -1014,11 +1014,12 @@ devstat_buildmatch(char *match_str, struct devstat_match **matches,
|
|||||||
* Break the (comma delimited) input string out into separate strings.
|
* Break the (comma delimited) input string out into separate strings.
|
||||||
*/
|
*/
|
||||||
for (tempstr = tstr, num_args = 0;
|
for (tempstr = tstr, num_args = 0;
|
||||||
(*tempstr = strsep(&match_str, ",")) != NULL && (num_args < 5);
|
(*tempstr = strsep(&match_str, ",")) != NULL && (num_args < 5);)
|
||||||
num_args++)
|
if (**tempstr != '\0') {
|
||||||
if (**tempstr != '\0')
|
num_args++;
|
||||||
if (++tempstr >= &tstr[5])
|
if (++tempstr >= &tstr[5])
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* The user gave us too many type arguments */
|
/* The user gave us too many type arguments */
|
||||||
if (num_args > 3) {
|
if (num_args > 3) {
|
||||||
|
Loading…
Reference in New Issue
Block a user