1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-30 19:03:04 +00:00

fix: Add precheck for tar archive test. (#4705)

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: #4702
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";