trace-cmd: Fixed a potential problem with non-terminated string, returned by readlink()
PATCH 1/1 trace-cmd: Fixed a potential problem with non-terminated string, returned by readlink()
From: "Tzvetomir Stoyanov (VMware)" <[email protected]>
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.
--- lib/trace-cmd/trace-util.c | 1 + 1 file changed, 1 insertion(+)
lib/trace-cmd/trace-util.c +1 -0
@@ -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,'/' );
Signature · 1 line
2.21.0
Quoted 17 lines · On 3.07.19 г. 15:16 ч., [email protected] wrote:
From: "Tzvetomir Stoyanov (VMware)" <[email protected]>
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.Signed-off-by Tzvetomir Stoyanov (VMware) <[email protected]>--- lib/trace-cmd/trace-util.c | 1 + 1 file changed, 1 insertion(+)lib/trace-cmd/trace-util.c +0
-0
lib/trace-cmd/trace-util.c static char *trace_util_get_source_plugins_dir(void) · line 1379
Quoted 7 lines
lib/trace-cmd/trace-util.c +1
-0@@ -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,'/' );
Thanks!