accounting for un-matched utf8 bytes in json parsing (#28203)

pull/28212/head
Vignesh Babu 3 years ago committed by GitHub
parent 851ad13313
commit 71374e7375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/core/lib/json/json_reader.cc
  2. 1
      test/core/json/corpus/testcase-4778708900904960

@ -471,6 +471,11 @@ JsonReader::Status JsonReader::Run() {
}
if (c == '"') {
state_ = State::GRPC_JSON_STATE_OBJECT_KEY_END;
// Once the key is parsed, there should no un-matched utf8
// encoded bytes.
if (utf8_bytes_remaining_ != 0) {
return Status::GRPC_JSON_PARSE_ERROR;
}
SetKey();
} else {
if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;
@ -484,6 +489,11 @@ JsonReader::Status JsonReader::Run() {
}
if (c == '"') {
state_ = State::GRPC_JSON_STATE_VALUE_END;
// Once the value is parsed, there should no un-matched utf8
// encoded bytes.
if (utf8_bytes_remaining_ != 0) {
return Status::GRPC_JSON_PARSE_ERROR;
}
SetString();
} else {
if (c < 32) return Status::GRPC_JSON_PARSE_ERROR;

Loading…
Cancel
Save