Browse Source

taskset: tighten the check for stride values

function                                             old     new   delta
taskset_main                                         986     987      +1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko 4 years ago
parent
commit
b230fdfa9d
1 changed files with 2 additions and 2 deletions
  1. 2 2
      util-linux/taskset.c

+ 2 - 2
util-linux/taskset.c

@@ -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);
 		}