From: Thomas Hindoe Paaboel Andersen Date: Fri, 26 Sep 2014 19:41:02 +0000 (+0200) Subject: bootchart: parse userinput with safe_atoi X-Git-Tag: v217~416 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9bcf7507fab6e6b022ae3cc7178237e6e0a09e9a;p=elogind.git bootchart: parse userinput with safe_atoi Found by coverity. Fixes: CID#996409 --- diff --git a/src/bootchart/store.c b/src/bootchart/store.c index ed683e88d..3099ff120 100644 --- a/src/bootchart/store.c +++ b/src/bootchart/store.c @@ -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);