diff options
author | Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com> | 2018-07-07 20:23:53 -0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2018-07-11 15:37:32 +0300 |
commit | 8d8ebe2ba4610fd5ffeade653b66eeec54781f34 (patch) | |
tree | ab35a1c6e25ac7c6d7ed03f179165835a8326e37 /tools | |
parent | d0f8fc9c88cbeec01486477007effc3b7914a8be (diff) |
Avoid truncate string in __igt_lsof_fds
Note that 'proc_path' parameter in __igt_lsof_fds receives a string
which was initialized with the size of PATH_MAX and the local variable
'path' has the same size, but it also have to append: '/', '\0', and the
directory name. This situation caused the warning described below.
warning: ‘%s’ directive output may be truncated writing up to 255 bytes
into a region of size between 0 and 4095 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", proc_path, d->d_name);
note: ‘snprintf’ output between 2 and 4352 bytes into a destination of
size 4096 [..]
This commit fixes this problem by changing the string size passed by
__igt_lsoft to __igt_lsof_fds. The max size for the string is
strlen("/proc/%d/cwd")+1 where "%d" can be estimated with
CEILING(LOG_10(INT_MAX)), in this sense, it is safe to define a path
size of 30 characters.
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions