perf machine: Null-terminate version char array upon fgets(/proc/version) error
authorDonald Yandt <donald.yandt@gmail.com>
Tue, 14 May 2019 11:01:00 +0000 (07:01 -0400)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 15 May 2019 19:36:47 +0000 (16:36 -0300)
commit30ba5b0e66c872faa416a458d32cc3956ecb548a
tree646052ffc2fe8738b9b2de1b7307ce02587b99cc
parentbf6d18cffa5f26bd5dc71485c2a2ad0c42a0ce60
perf machine: Null-terminate version char array upon fgets(/proc/version) error

If fgets() fails due to any other error besides end-of-file, the version
char array may not even be null-terminated.

Signed-off-by: Donald Yandt <donald.yandt@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Avi Kivity <avi@scylladb.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yanmin Zhang <yanmin_zhang@linux.intel.com>
Fixes: a1645ce12adb ("perf: 'perf kvm' tool for monitoring guest performance from host")
Link: http://lkml.kernel.org/r/20190514110100.22019-1-donald.yandt@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/machine.c