Make sure that the given CPU range is within the bounds of the OS

glibc provides CPU_SETSIZE as the maximum CPU count.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/options.c b/options.c
index 5bbeb34..c99f102 100644
--- a/options.c
+++ b/options.c
@@ -264,6 +264,7 @@
 {
 	struct thread_data *td = data;
 	char *cpu, *str, *p;
+	int ret = 0;
 
 	CPU_ZERO(&td->o.cpumask);
 
@@ -292,15 +293,25 @@
 		if (icpu2 == -1)
 			icpu2 = icpu;
 		while (icpu <= icpu2) {
+			if (icpu >= CPU_SETSIZE) {
+				log_err("fio: your OS only supports up to"
+					" %d CPUs\n", (int) CPU_SETSIZE);
+				ret = 1;
+				break;
+			}
+				
 			dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
 			CPU_SET(atoi(cpu), &td->o.cpumask);
 			icpu++;
 		}
+		if (ret)
+			break;
 	}
 
 	free(p);
-	td->o.cpumask_set = 1;
-	return 0;
+	if (!ret)
+		td->o.cpumask_set = 1;
+	return ret;
 }
 #endif