From 922bdeb57a43738e4c137bdb206924aaa80da19c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 5 Nov 2023 10:51:41 -0600 Subject: [PATCH] Catch corrupted tarballs so we don't set a nonsense mode. --- toys/posix/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/posix/tar.c b/toys/posix/tar.c index 35554d7c..e760a43a 100644 --- a/toys/posix/tar.c +++ b/toys/posix/tar.c @@ -799,7 +799,7 @@ static void unpack_tar(char *first) // At this point, we have something to output. Convert metadata. TT.hdr.mode = OTOI(tar.mode)&0xfff; - if (tar.type == 'S' || !tar.type) TT.hdr.mode |= 0x8000; + if (tar.type == 'S' || !tar.type || !*tar.magic) 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); -- 2.39.2