[PATCH i-g-t] lib/igt_dir: Use actual length for string termination
Kamil Konieczny
kamil.konieczny at linux.intel.com
Mon Aug 11 10:21:40 UTC 2025
Hi Peter,
On 2025-08-09 at 15:18:58 +0200, Peter Senna Tschudin wrote:
> Commit 501da513dfb7 ("lib/igt_dir: utilities for directory traversal and
> file handling") introduced a bug where strings were always
> null-terminated at their maximum length rather than at their actual used
> length. This could lead to strings with unintended trailing data or
> improper termination.
>
> This commit fixes the issue by ensuring strings are null-terminated at
> the correct (used) length.
>
> Cc: kamil.konieczny at linux.intel.com
> Cc: katarzyna.piecielska at intel.com
> Cc: zbigniew.kempczynski at intel.com
> Cc: michal.wajdeczko at intel.com
> Cc: karthik.b.s at intel.com
> Cc: jan.sokolowski at intel.com
> Cc: rodrigo.vivi at intel.com
> Fixes: 501da513dfb7 ("lib/igt_dir: utilities for directory traversal and file handling")
> Signed-off-by: Peter Senna Tschudin <peter.senna at linux.intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
> lib/igt_dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/igt_dir.c b/lib/igt_dir.c
> index 1792ba7c1..e232dbda9 100644
> --- a/lib/igt_dir.c
> +++ b/lib/igt_dir.c
> @@ -79,7 +79,7 @@ int igt_dir_get_fd_path(int fd, char *path, size_t path_len)
> if (len == -1)
> return -1;
>
> - path[path_len] = '\0';
> + path[len] = '\0';
>
> return 0;
> }
> --
> 2.43.0
>
More information about the igt-dev
mailing list