1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-23 14:40:43 +00:00

fix: Add precheck for tar archive test. ()

Recently we discovered we do not properly handle broken tar archives.

The problem is running tar (in linting mode) on invalid archive and
piping stdout to NSPipe introduces a hang as NSPipe cannot process
such huge data amounts.

Fixing this problem by adding a precheck with tar (listing mode) with
piping stdout to /dev/null.

Fixes: 
This commit is contained in:
Dzmitry Neviadomski 2023-02-02 00:05:32 +03:00 committed by GitHub
parent 61fa6f6088
commit e0cc4f50e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -210,6 +210,29 @@ BlocklistDownloader* fBLDownloader = nil;
- (BOOL)untarFrom:(NSURL*)file to:(NSURL*)destination
{
// We need to check validity of archive before listing or unpacking.
NSTask* tarListCheck = [[NSTask alloc] init];
tarListCheck.launchPath = @"/usr/bin/tar";
tarListCheck.arguments = @[ @"--list", @"--file", file.path ];
tarListCheck.standardOutput = nil;
tarListCheck.standardError = nil;
@try
{
[tarListCheck launch];
[tarListCheck waitUntilExit];
if (tarListCheck.terminationStatus != 0)
{
return NO;
}
}
@catch (NSException* exception)
{
return NO;
}
NSTask* tarList = [[NSTask alloc] init];
tarList.launchPath = @"/usr/bin/tar";