From: Heiko Carstens Date: Fri, 9 Sep 2011 09:19:32 +0000 (+0200) Subject: lib,cpuset: fix stride handling in cpulist_parse() X-Git-Tag: v2.21-rc1~436 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72232a267a8b021c5170419062f8ae831f18ca0e;p=thirdparty%2Futil-linux.git lib,cpuset: fix stride handling in cpulist_parse() If cpulist_parse() gets passed a cpu list with a stride value of 0 it will be stuck in an endless loop. E.g. the following cpu list will cause an endless loop: "0-2:0". Fix this by causing a parse error if the stride value is 0. Signed-off-by: Heiko Carstens --- diff --git a/lib/cpuset.c b/lib/cpuset.c index cf22aa7786..85927553ee 100644 --- a/lib/cpuset.c +++ b/lib/cpuset.c @@ -292,6 +292,8 @@ int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize, int fail) if (c1 != NULL && (c2 == NULL || c1 < c2)) { if (sscanf(c1, "%u", &s) < 1) return 1; + if (s == 0) + return 1; } }