utils/ps: fix inifinite loop in CPU list parser

This commit is contained in:
Philippe Gerum 2020-02-04 10:25:44 +01:00
parent 0d8639ceb8
commit 34bf02d799
1 changed files with 3 additions and 2 deletions

View File

@ -678,8 +678,8 @@ static void build_cpu_mask(const char *cpu_list)
s = n = strdup(cpu_list);
while ((range = strtok_r(n, ",", &range_p)) != NULL) {
if (*range == '\0')
continue;
if (*range == '\0' || *range == '\n')
goto next;
end = -1;
if (range[strlen(range)-1] == '-')
end = nr_cpus - 1;
@ -704,6 +704,7 @@ static void build_cpu_mask(const char *cpu_list)
}
for (cpu = start; cpu <= end; cpu++)
CPU_SET(cpu, &cpu_restrict);
next:
n = NULL;
}