]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib,cpuset: fix stride handling in cpulist_parse()
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Fri, 9 Sep 2011 09:19:32 +0000 (11:19 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 9 Sep 2011 22:00:24 +0000 (00:00 +0200)
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 <heiko.carstens@de.ibm.com>
lib/cpuset.c

index cf22aa7786a6425e7ca156c6e69bb49e802ebf37..85927553ee6b386411cea9297e21cd7c729021e3 100644 (file)
@@ -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;
                        }
                }