trace-cmd: Fix possible usage of not null-terminated string
PATCH 1/1 trace-cmd: Fix possible usage of not null-terminated string
According to the
readlink(const char *filename, char *buffer, size_t size);
documentation, the terminating '\0' is not written in the buffer. As the buffer that is passed to this API is not initialized, this can lead to working with not null-terminated string. The problem was detected by valgrind.
Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>
--- lib/trace-cmd/trace-plugin.c | 1 + lib/trace-cmd/trace-util.c | 1 + 2 files changed, 2 insertions(+)
lib/trace-cmd/trace-plugin.c +1 -0
@@ -199,6 +199,7 @@ static char *get_source_plugins_dir(void)if (ret >PATH_MAX || ret <0 )return NULL ; + path[ret] =0 ;dirname (path); p =strrchr (path,'/' );if (!p)
lib/trace-cmd/trace-util.c +1 -0
@@ -269,6 +269,7 @@ static char *get_source_plugins_dir(void)if (ret >PATH_MAX || ret <0 )return NULL ; + path[ret] =0 ;dirname (path); p =strrchr (path,'/' );if (!p)
Signature · 1 line
2.25.1