Change file extraction to explicitly NUL-fill gaps

Instead of expecting pwrite to do it.
This commit is contained in:
Jon Siwek 2014-12-16 20:56:15 -06:00
parent cbbe7b52dc
commit f6257618e5

View file

@ -103,7 +103,7 @@ bool Extract::DeliverStream(const u_char* data, uint64 len)
if ( towrite > 0 )
{
safe_pwrite(fd, (const u_char *) data, towrite, depth);
safe_write(fd, reinterpret_cast<const char*>(data), towrite);
depth += towrite;
}
@ -112,6 +112,13 @@ bool Extract::DeliverStream(const u_char* data, uint64 len)
bool Extract::Undelivered(uint64 offset, uint64 len)
{
if ( depth == offset )
{
char* tmp = new char[len]();
safe_write(fd, tmp, len);
delete [] tmp;
depth += len;
}
return true;
}