public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: tar: guard slash-only header names
@ 2026-03-30 17:34 Vansh Choudhary
  2026-03-31  3:34 ` Gao Xiang
  2026-03-31  3:58 ` Yifan Zhao
  0 siblings, 2 replies; 3+ messages in thread
From: Vansh Choudhary @ 2026-03-30 17:34 UTC (permalink / raw)
  To: linux-erofs; +Cc: Vansh Choudhary

Check that the assembled header path is non-empty before trimming
trailing slashes from it.

A malformed tar header name made up only of '/' characters could
otherwise drive the trim loop to read before the start of the buffer.

Signed-off-by: Vansh Choudhary <ch@vnsh.in>
---
 lib/tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tar.c b/lib/tar.c
index 4e97522..39e2321 100644
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -866,7 +866,7 @@ out_eot:
 			path[1] = '\0';
 		} else {
 			*_path = '\0';
-			while (path[j - 1] == '/')
+			while (j && path[j - 1] == '/')
 				path[--j] = '\0';
 		}
 	}
-- 
2.43.0



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

end of thread, other threads:[~2026-03-31  3:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 17:34 [PATCH] erofs-utils: tar: guard slash-only header names Vansh Choudhary
2026-03-31  3:34 ` Gao Xiang
2026-03-31  3:58 ` Yifan Zhao

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