tar: skip leading / and handle names like abc/..////def -> def (not ///def)
function old new delta
strip_unsafe_prefix - 105 +105
writeFileToTarball 557 520 -37
get_header_tar 1545 1462 -83
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/archival/tar.c b/archival/tar.c
index 1e3cecf..d43c8de 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -397,17 +397,8 @@
DBG("writeFileToTarball('%s')", fileName);
- /* Strip leading '/' (must be before memorizing hardlink's name) */
- header_name = fileName;
- while (header_name[0] == '/') {
- static smallint warned;
-
- if (!warned) {
- bb_error_msg("removing leading '/' from member names");
- warned = 1;
- }
- header_name++;
- }
+ /* Strip leading '/' and such (must be before memorizing hardlink's name) */
+ header_name = strip_unsafe_prefix(fileName);
if (header_name[0] == '\0')
return TRUE;