1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

fix OutputFile::seek() for SEEK_SET and SEEK_END

This commit is contained in:
John Reiser 2009-10-14 17:44:29 -07:00
parent 0a485eafcb
commit 549c59ecf5

View File

@ -396,6 +396,17 @@ void OutputFile::rewrite(const void *buf, int len)
void OutputFile::seek(off_t off, int whence)
{
assert(!opt->to_stdout);
switch (whence) {
case SEEK_SET: {
if (bytes_written < off) {
bytes_written = off;
}
_length = bytes_written; // cheap, lazy update; needed?
} break;
case SEEK_END: {
_length = bytes_written; // necessary
} break;
}
super::seek(off,whence);
}