Fix fuzzer-found inconsistency in AEC3 config json parsing

Type mismatches will silently fail and skip reading a parameter
in the JSON parsing, except when parsing a size_t from a negative int.

This CL updates the parsing to silently ignore negative values provided
for size_t config parameters, instead of explicitly DCHECKing.

Tested: Ran the fuzzer on the crash test case with + without this fix.

Bug: chromium:1016139
Change-Id: I3899e81e1183aa54b708030efeb6e0006b8cd881
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157894
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29568}
This commit is contained in:
Sam Zackrisson 2019-10-22 11:36:17 +02:00 committed by Commit Bot
parent 5f2fc41fb5
commit 528a03441e

View File

@ -32,8 +32,7 @@ void ReadParam(const Json::Value& root, std::string param_name, bool* param) {
void ReadParam(const Json::Value& root, std::string param_name, size_t* param) {
RTC_DCHECK(param);
int v;
if (rtc::GetIntFromJsonObject(root, param_name, &v)) {
RTC_DCHECK_GE(v, 0);
if (rtc::GetIntFromJsonObject(root, param_name, &v) && v >= 0) {
*param = v;
}
}