mirror of
https://github.com/torvalds/linux.git
synced 2026-11-26 08:23:17 +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 <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Avi Kivity <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Yanmin Zhang <[email protected]>
Fixes: a1645ce12a ("perf: 'perf kvm' tool for monitoring guest performance from host")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
bf6d18cffa
commit
30ba5b0e66
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user