X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbootchart%2Fstore.c;h=9ea1b27de4b1666614170b91d55a8f212bb4ca11;hb=e6c253e363dee77ef7e5c5f44c4ca55cded3fd47;hp=2d2ea428fa570804e1c467727c2a6abd4657fe9c;hpb=ece74070c7102b2d48ccc01260976b3f5cb6d9f0;p=elogind.git diff --git a/src/bootchart/store.c b/src/bootchart/store.c index 2d2ea428f..9ea1b27de 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 -1) /* Oops, we only have room for MAXCPUS data */ break; sampledata->runtime[c] = atoll(rt); @@ -251,6 +253,7 @@ schedstat_next: _cleanup_fclose_ FILE *st = NULL; char t[32]; struct ps_struct *parent; + int r; ps->next_ps = new0(struct ps_struct, 1); if (!ps->next_ps) { @@ -310,7 +313,11 @@ schedstat_next: if (!sscanf(m, "%*s %*s %s", t)) continue; - ps->starttime = strtod(t, NULL) / 1000.0; + r = safe_atod(t, &ps->starttime); + if (r < 0) + continue; + + ps->starttime /= 1000.0; if (arg_show_cgroup) /* if this fails, that's OK */ @@ -394,7 +401,7 @@ schedstat_next: continue; ps->sample->next = new0(struct ps_sched_struct, 1); - if (!ps->sample) { + if (!ps->sample->next) { log_oom(); exit(EXIT_FAILURE); }