summaryrefslogtreecommitdiff
path: root/src/bootchart
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2014-09-26 21:41:02 +0200
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2014-09-28 14:46:38 +0200
commit9bcf7507fab6e6b022ae3cc7178237e6e0a09e9a (patch)
treee8dcd984c8dcbb44ffd2daf4078fef065fe98bfe /src/bootchart
parent492d7a3038b154e1813a1ece913a5a27148fec19 (diff)
bootchart: parse userinput with safe_atoi
Found by coverity. Fixes: CID#996409
Diffstat (limited to 'src/bootchart')
-rw-r--r--src/bootchart/store.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index ed683e88d9..3099ff1208 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);