From 72232a267a8b021c5170419062f8ae831f18ca0e Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Fri, 9 Sep 2011 11:19:32 +0200 Subject: [PATCH] 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 --- lib/cpuset.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cpuset.c b/lib/cpuset.c index cf22aa778..85927553e 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; } }