Make ZlibInStream more robust against failures
Move the checks around to avoid missing cases where we might access memory that is no longer valid. Also avoid touching the underlying stream implicitly (e.g. via the destructor) as it might also no longer be valid. A malicious server could theoretically use this for remote code execution in the client. Issue found by Pavel Cheremushkin from Kaspersky Lab
This commit is contained in:
committed by
Lauri Kasanen
parent
ac06594b12
commit
3282836baf
@@ -340,7 +340,8 @@ void TightDecoder::decodeRect(const Rect& r, const void* buffer,
|
||||
|
||||
zis[streamId].readBytes(netbuf, dataSize);
|
||||
|
||||
zis[streamId].removeUnderlying();
|
||||
zis[streamId].flushUnderlying();
|
||||
zis[streamId].setUnderlying(NULL, 0);
|
||||
delete ms;
|
||||
|
||||
bufptr = netbuf;
|
||||
|
||||
@@ -174,7 +174,8 @@ void ZRLE_DECODE (const Rect& r, rdr::InStream* is,
|
||||
}
|
||||
}
|
||||
|
||||
zis->removeUnderlying();
|
||||
zis->flushUnderlying();
|
||||
zis->setUnderlying(NULL, 0);
|
||||
}
|
||||
|
||||
#undef ZRLE_DECODE
|
||||
|
||||
Reference in New Issue
Block a user