aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-10-04 15:19:28 -0500
committerRob Landley <rob@landley.net>2019-10-04 15:19:28 -0500
commit2301071e2b7f9c18ac2c6c05ddd5b3325352f5e6 (patch)
tree49253424119c95930612571aa30854a9ba22bf96
parent46c40a7adee50a92a3eb8ed1d94ac2c9aa72591f (diff)
downloadtoybox-2301071e2b7f9c18ac2c6c05ddd5b3325352f5e6.tar.gz
Fix extracting old tarballs, not just -tv of them.
-rw-r--r--toys/posix/tar.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/toys/posix/tar.c b/toys/posix/tar.c
index 019643c1..78ff9a1e 100644
--- a/toys/posix/tar.c
+++ b/toys/posix/tar.c
@@ -643,10 +643,9 @@ static void unpack_tar(char *first)
}
// At this point, we have something to output. Convert metadata.
- TT.hdr.mode = OTOI(tar.mode);
- if (tar.type == 'S') TT.hdr.mode |= 0x8000;
- else if (tar.type)
- TT.hdr.mode |= (char []){8,8,10,2,6,4,1,8}[tar.type-'0']<<12;
+ TT.hdr.mode = OTOI(tar.mode)&0xfff;
+ if (tar.type == 'S' || !tar.type) TT.hdr.mode |= 0x8000;
+ else TT.hdr.mode |= (char []){8,8,10,2,6,4,1,8}[tar.type-'0']<<12;
TT.hdr.uid = OTOI(tar.uid);
TT.hdr.gid = OTOI(tar.gid);
TT.hdr.mtime = OTOI(tar.mtime);