mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 09:10:55 +07:00
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>
This commit is contained in:
parent
8a398897ff
commit
a761a2d8a7
@ -930,7 +930,7 @@ static int write_topo_node(int fd, int node)
|
|||||||
/* skip over invalid lines */
|
/* skip over invalid lines */
|
||||||
if (!strchr(buf, ':'))
|
if (!strchr(buf, ':'))
|
||||||
continue;
|
continue;
|
||||||
if (sscanf(buf, "%*s %*d %s %"PRIu64, field, &mem) != 2)
|
if (sscanf(buf, "%*s %*d %31s %"PRIu64, field, &mem) != 2)
|
||||||
goto done;
|
goto done;
|
||||||
if (!strcmp(field, "MemTotal:"))
|
if (!strcmp(field, "MemTotal:"))
|
||||||
mem_total = mem;
|
mem_total = mem;
|
||||||
|
Loading…
Reference in New Issue
Block a user