Fixes Oss-Fuzz issue: 21916 (#1180)

* Fix heap-buffer-overflow in json_reader
This commit is contained in:
kabeer27 2020-05-29 19:20:26 +05:30 committed by chenguoping
parent 1d38f0d6b4
commit 3228be44b0

View File

@ -1287,7 +1287,7 @@ void OurReader::skipSpaces() {
void OurReader::skipBom(bool skipBom) { void OurReader::skipBom(bool skipBom) {
// The default behavior is to skip BOM. // The default behavior is to skip BOM.
if (skipBom) { if (skipBom) {
if (strncmp(begin_, "\xEF\xBB\xBF", 3) == 0) { if ((end_ - begin_) >= 3 && strncmp(begin_, "\xEF\xBB\xBF", 3) == 0) {
begin_ += 3; begin_ += 3;
current_ = begin_; current_ = begin_;
} }