mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
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: a1645ce12a
("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>
This commit is contained in:
parent
bf6d18cffa
commit
30ba5b0e66
1 changed files with 2 additions and 1 deletions
|
@ -1234,8 +1234,9 @@ static char *get_kernel_version(const char *root_dir)
|
|||
if (!file)
|
||||
return NULL;
|
||||
|
||||
version[0] = '\0';
|
||||
tmp = fgets(version, sizeof(version), file);
|
||||
if (!tmp)
|
||||
*version = '\0';
|
||||
fclose(file);
|
||||
|
||||
name = strstr(version, prefix);
|
||||
|
|
Loading…
Reference in a new issue