Skip to content

Commit

Permalink
Fix possible heap-buffer-overflow (#1779)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4465d88)
  • Loading branch information
Avogar authored and martin-g committed Jul 25, 2022
1 parent 0e89c57 commit 565a8f7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lang/c++/impl/DataFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ void DataFileReaderBase::readDataBlock() {
compressed_.insert(compressed_.end(), data, data + len);
}
len = compressed_.size();
if (len < 4)
throw Exception("Cannot read compressed data, expected at least 4 bytes, got " + std::to_string(len));

int b1 = compressed_[len - 4] & 0xFF;
int b2 = compressed_[len - 3] & 0xFF;
int b3 = compressed_[len - 2] & 0xFF;
Expand Down

0 comments on commit 565a8f7

Please sign in to comment.