diff options
author | Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> | 2019-07-03 15:16:44 +0300 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-07-05 10:20:38 -0400 |
commit | 7b0abc9a4168a8fe0a258e0ec76b3173215ab019 (patch) | |
tree | e922c6cb6c8997d79987f37d3d5d165f82cc67d9 | |
parent | a898ee06d331c9c056c85cd19bf6c6750861d2c3 (diff) | |
download | trace-cmd-7b0abc9a4168a8fe0a258e0ec76b3173215ab019.tar.gz |
trace-cmd: Fixed a potential problem with non-terminated string, returned by readlink()
The buffer, returned by readlink() API, is not guaranteed to be a null terminated string.
Explicitly adding '\0' at the end of the buffer is recommended, to ensure the string is
null terminated and to avoid possible buffer overruns.
Link: http://lore.kernel.org/linux-trace-devel/20190703121644.18680-1-tz.stoyanov@gmail.com
Reviewed-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Tested-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | lib/trace-cmd/trace-util.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 190cf746..7c74baec 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -1373,6 +1373,7 @@ static char *trace_util_get_source_plugins_dir(void) ret = readlink("/proc/self/exe", path, PATH_MAX); if (ret > PATH_MAX || ret < 0) return NULL; + path[ret] = 0; dirname(path); p = strrchr(path, '/'); |