From 2301071e2b7f9c18ac2c6c05ddd5b3325352f5e6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 4 Oct 2019 15:19:28 -0500 Subject: Fix extracting old tarballs, not just -tv of them. --- toys/posix/tar.c | 7 +++---- 1 file 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); -- cgit v1.2.3