Add safety check to extracting
This commit is contained in:
parent
791690fd5a
commit
f365f8710d
1 changed files with 11 additions and 1 deletions
|
|
@ -124,7 +124,17 @@ Result extractArchive(const std::string &archivePath, const std::string &wantedF
|
|||
return EXTRACT_ERROR_ARCHIVE;
|
||||
}
|
||||
|
||||
fwrite(buf, 1, size, file);
|
||||
size_t written = fwrite(buf, 1, size, file);
|
||||
|
||||
/* Failed to write, likely out of space. */
|
||||
if (written != size) {
|
||||
fclose(file);
|
||||
delete[] buf;
|
||||
archive_read_close(a);
|
||||
archive_read_free(a);
|
||||
return EXTRACT_ERROR_WRITEFILE;
|
||||
}
|
||||
|
||||
sizeLeft -= size;
|
||||
writeOffset += size;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue