Skip to content

Commit a761a2d

Browse files
Alan Coxacmel
authored andcommitted
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>
1 parent 8a39889 commit a761a2d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/util/header.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ static int write_topo_node(int fd, int node)
930930
/* skip over invalid lines */
931931
if (!strchr(buf, ':'))
932932
continue;
933-
if (sscanf(buf, "%*s %*d %s %"PRIu64, field, &mem) != 2)
933+
if (sscanf(buf, "%*s %*d %31s %"PRIu64, field, &mem) != 2)
934934
goto done;
935935
if (!strcmp(field, "MemTotal:"))
936936
mem_total = mem;

0 commit comments

Comments
 (0)