erofs-utils: tar: guard slash-only header names
PATCH 1/1 erofs-utils: tar: guard slash-only header names
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.
--- lib/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tar.c +1 -1
@@ -866,7 +866,7 @@ out_eot: path[1 ] ='\0' ; }else { *_path ='\0' ; -while (path[j -1 ] =='/' ) +while (j && path[j -1 ] =='/' ) path[--j] ='\0' ; } }
Signature · 1 line
2.43.0
Quoted 7 lines · 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 <[email protected]>
I don't think it's a valid one.
Quoted 17 lines
--- lib/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/tar.c +1
-1@@ -866,7 +866,7 @@ out_eot: path[1 ] ='\0' ; }else { *_path ='\0' ; -while (path[j -1 ] =='/' ) +while (j && path[j -1 ] =='/' ) path[--j] ='\0' ; } }
Quoted 16 lines · 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 <[email protected]>--- lib/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/tar.c +0
-0
lib/tar.c out_eot: · line 867
Quoted 2 lines
lib/tar.c +0
-0@@ -866,7 +866,7 @@ out_eot: path[1 ] ='\0' ; }else {
I think this else branch has ensured j != 0.
Quoted 6 lines
lib/tar.c +1
-1*_path ='\0' ; -while (path[j -1 ] =='/' ) +while (j && path[j -1 ] =='/' ) path[--j] ='\0' ; } }