diff options
| author | Nikita Ofitserov <himikof@gmail.com> | 2022-08-24 17:28:04 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 17:28:04 +0300 |
| commit | 42038422f6f43926d4103c27587b5db60ebde747 (patch) | |
| tree | a0809bd4e3bb323ec47cd30789f6b3a856d35693 /src/GZipEncoder.cc | |
| parent | 05f3c479883b3eed34880fbdbd9ec79c535d369c (diff) | |
Fix undefined behavior/crash in GZipEncoder
When the output buffer is full, outbuf[produced] references past the buffer end, leading to UB and a possible assertion failure.
Fixes #1968, #1964
Diffstat (limited to 'src/GZipEncoder.cc')
| -rw-r--r-- | src/GZipEncoder.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/GZipEncoder.cc b/src/GZipEncoder.cc index 884485ee..41cfce5a 100644 --- a/src/GZipEncoder.cc +++ b/src/GZipEncoder.cc @@ -87,7 +87,7 @@ std::string GZipEncoder::encode(const unsigned char* in, size_t length, throw DL_ABORT_EX(fmt("libz::deflate() failed. cause:%s", strm_->msg)); } size_t produced = outbuf.size() - strm_->avail_out; - out.append(&outbuf[0], &outbuf[produced]); + out.append(outbuf.data(), outbuf.data() + produced); if (strm_->avail_out > 0) { break; } |
