mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 04:50:31 -04:00
Fix bug that could cause reallocation in brotli decompressed blocks
This ultimately could have led to corruption and was caught by ASAN.
This commit is contained in:
parent
10924eb319
commit
18e0027588
@ -19,6 +19,8 @@
|
|||||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <brotli/decode.h>
|
#include <brotli/decode.h>
|
||||||
#include <brotli/encode.h>
|
#include <brotli/encode.h>
|
||||||
|
|
||||||
@ -114,6 +116,15 @@ class brotli_block_decompressor final : public block_decompressor::impl {
|
|||||||
|
|
||||||
bool decompress_frame(size_t frame_size) override {
|
bool decompress_frame(size_t frame_size) override {
|
||||||
size_t pos = decompressed_.size();
|
size_t pos = decompressed_.size();
|
||||||
|
|
||||||
|
if (pos + frame_size > uncompressed_size_) {
|
||||||
|
assert(uncompressed_size_ >= pos);
|
||||||
|
frame_size = uncompressed_size_ - pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pos + frame_size <= uncompressed_size_);
|
||||||
|
assert(frame_size > 0);
|
||||||
|
|
||||||
decompressed_.resize(pos + frame_size);
|
decompressed_.resize(pos + frame_size);
|
||||||
uint8_t* next_out = &decompressed_[pos];
|
uint8_t* next_out = &decompressed_[pos];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user