Fixing Bug #398921: Sparkle should detect read/write errors on archive extraction

Thanks to Jim Turner for the patch.
This commit is contained in:
Andy Matuschak committed 2009-08-20 23:28:26 -07:00
1 parent 5090d4b3a0
commit b571a3d58d
1 file changed
+11 -1
+11 -1
View File
@@ -62,17 +62,27 @@
setenv("DESTINATION", [[archivePath stringByDeletingLastPathComponent] fileSystemRepresentation], 1);
cmdFP = popen([command fileSystemRepresentation], "w");
long written;
if (!cmdFP) goto reportError;
char buf[32*1024];
long len;
while((len = fread(buf, 1, 32*1024, fp)))
{
fwrite(buf, 1, len, cmdFP);
written = fwrite(buf, 1, len, cmdFP);
if( written < len )
{
pclose(cmdFP);
goto reportError;
}
[self performSelectorOnMainThread:@selector(_notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO];
}
pclose(cmdFP);
if( ferror( fp ) )
goto reportError;
[self performSelectorOnMainThread:@selector(_notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO];
goto finally;