bootchart: parse userinput with safe_atoi

Found by coverity. Fixes: CID#996409
This commit is contained in:
Thomas Hindoe Paaboel Andersen
2014-09-28 14:46:38 +02:00
parent 492d7a3038
commit 9bcf7507fa
+4 -2
View File
@@ -192,12 +192,14 @@ vmstat_next:
m = buf;
while (m) {
int r;
if (sscanf(m, "%s %*s %*s %*s %*s %*s %*s %s %s", key, rt, wt) < 3)
goto schedstat_next;
if (strstr(key, "cpu")) {
c = atoi((const char*)(key+3));
if (c > MAXCPUS)
r = safe_atoi((const char*)(key+3), &c);
if (r < 0 || c > MAXCPUS)
/* Oops, we only have room for MAXCPUS data */
break;
sampledata->runtime[c] = atoll(rt);