mirror of
https://github.com/transmission/transmission
synced 2025-03-20 02:35:43 +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:
parent
61fa6f6088
commit
e0cc4f50e0
1 changed files with 23 additions and 0 deletions
|
@ -210,6 +210,29 @@ BlocklistDownloader* fBLDownloader = nil;
|
||||||
|
|
||||||
- (BOOL)untarFrom:(NSURL*)file to:(NSURL*)destination
|
- (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];
|
NSTask* tarList = [[NSTask alloc] init];
|
||||||
|
|
||||||
tarList.launchPath = @"/usr/bin/tar";
|
tarList.launchPath = @"/usr/bin/tar";
|
||||||
|
|
Loading…
Add table
Reference in a new issue