taskset: tighten the check for stride values
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 9 Nov 2019 16:32:43 +0000 (17:32 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 9 Nov 2019 16:32:43 +0000 (17:32 +0100)
function                                             old     new   delta
taskset_main                                         986     987      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
util-linux/taskset.c

index df1bc0a4f5c5ebe913c17a9c91c871f70f804063..b542f8c83ac7c123850479bcd073a4b64fe53109 100644 (file)
@@ -149,8 +149,8 @@ static void parse_cpulist(ul *mask, unsigned max, char *s)
                if ((*s != ',' && *s != '\0')
                 || bit > end
                 || end == UINT_MAX /* bb_strtou returns this on malformed / ERANGE numbers */
-                || stride == 0
-                || stride == UINT_MAX
+                || (stride - 1) > (UINT_MAX / 4)
+               /* disallow 0, malformed input, and too large stride prone to overflows */
                ) {
                        bb_error_msg_and_die("bad affinity '%s'", aff);
                }