From 906e73af399c21e030b87a98e3dfe11a64d24030 Mon Sep 17 00:00:00 2001 From: markj Date: Sun, 1 Sep 2019 21:20:31 +0000 Subject: [PATCH] Fix an off-by-one bug in the CPU and domain ID parser. The "size" parameter is the size of the corresponding bit set, so the maximum CPU or domain index is size - 1. MFC after: 1 week --- usr.bin/cpuset/cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/cpuset/cpuset.c b/usr.bin/cpuset/cpuset.c index c1481e2c159..9e3eedaa274 100644 --- a/usr.bin/cpuset/cpuset.c +++ b/usr.bin/cpuset/cpuset.c @@ -100,10 +100,10 @@ parselist(char *list, struct bitset *mask, int size) for (l = list; *l != '\0';) { if (isdigit(*l)) { curnum = atoi(l); - if (curnum > size) + if (curnum >= size) errx(EXIT_FAILURE, "List entry %d exceeds maximum of %d", - curnum, size); + curnum, size - 1); while (isdigit(*l)) l++; switch (state) { -- 2.45.0