diff options
| author | Alan Cox <alan@linux.intel.com> | 2014-01-20 13:10:11 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-20 14:19:08 -0500 |
| commit | a761a2d8a7175b7b4e8525e0672e1a8d3c051001 (patch) | |
| tree | 6b5abffcec6275081ba411e04fdd3a993a7b1ac4 | |
| parent | 8a398897ff21f73cb8b15a19514660f032926882 (diff) | |
perf tools: Ensure sscanf does not overrun the "mem" field
Make the parsing robust.
(perf has some other assumptions that BUFSIZE <= MAX_PATH which are
not touched here)
Reported-by: Jackie Chang
Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-g2uoiwbrpiimb63rx32qv8ne@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/util/header.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index bb3e0ede6183..893f8e2df928 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
| @@ -930,7 +930,7 @@ static int write_topo_node(int fd, int node) | |||
| 930 | /* skip over invalid lines */ | 930 | /* skip over invalid lines */ |
| 931 | if (!strchr(buf, ':')) | 931 | if (!strchr(buf, ':')) |
| 932 | continue; | 932 | continue; |
| 933 | if (sscanf(buf, "%*s %*d %s %"PRIu64, field, &mem) != 2) | 933 | if (sscanf(buf, "%*s %*d %31s %"PRIu64, field, &mem) != 2) |
| 934 | goto done; | 934 | goto done; |
| 935 | if (!strcmp(field, "MemTotal:")) | 935 | if (!strcmp(field, "MemTotal:")) |
| 936 | mem_total = mem; | 936 | mem_total = mem; |
