Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib/igt_dir: Use actual length for string termination
@ 2025-08-09 13:18 Peter Senna Tschudin
  2025-08-09 14:11 ` ✓ Xe.CI.BAT: success for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Peter Senna Tschudin @ 2025-08-09 13:18 UTC (permalink / raw)
  To: igt-dev
  Cc: Peter Senna Tschudin, kamil.konieczny, katarzyna.piecielska,
	zbigniew.kempczynski, michal.wajdeczko, karthik.b.s,
	jan.sokolowski, rodrigo.vivi

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@linux.intel.com
Cc: katarzyna.piecielska@intel.com
Cc: zbigniew.kempczynski@intel.com
Cc: michal.wajdeczko@intel.com
Cc: karthik.b.s@intel.com
Cc: jan.sokolowski@intel.com
Cc: rodrigo.vivi@intel.com
Fixes: 501da513dfb7 ("lib/igt_dir: utilities for directory traversal and file handling")
Signed-off-by: Peter Senna Tschudin <peter.senna@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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-11 10:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-09 13:18 [PATCH i-g-t] lib/igt_dir: Use actual length for string termination Peter Senna Tschudin
2025-08-09 14:11 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-08-09 14:17 ` ✓ i915.CI.BAT: " Patchwork
2025-08-09 15:35 ` ✗ Xe.CI.Full: failure " Patchwork
2025-08-10  9:42   ` Peter Senna Tschudin
2025-08-09 16:57 ` ✓ i915.CI.Full: success " Patchwork
2025-08-11 10:21 ` [PATCH i-g-t] " Kamil Konieczny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox