perf: header: Check read return
PATCH 1/1 perf: header: Check read return
Check the readn() return value in read_attr() if there are remaining header bytes to read (previously, the return value was being ignored).
Fixes 69996df486fc3 ("perf tools: Enable reading of perf.data files from different ABI rev")
Signed-off-by James O. D. Hunt <[email protected]>
--- tools/perf/util/header.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/util/header.c +5 -0
@@ -4161,6 +4161,11 @@ static int read_attr(int fd, struct perf_header *ph, ptr +=PERF_ATTR_SIZE_VER0 ; ret =readn (fd, ptr, left); +if (ret <=0 ) { +pr_debug ("cannot read %zu remaining bytes of header attr\n" , + left); +return -1 ; + } }/* read perf_file_section, ids are read in caller */ ret =readn (fd, &f_attr->ids,sizeof (f_attr->ids));
Signature · 1 line
2.49.0