Merge "Fix heap-buffer-overflow detected by ASAN."

am: 3d028f14c8

Change-Id: Ia3c137490fae9da00f73dedd414ba2b8cd04a975
This commit is contained in:
Evgenii Stepanov 2017-03-15 06:52:56 +00:00 committed by android-build-merger
commit 591b09650b

View file

@ -180,8 +180,13 @@ static enum match_type identical(LogBufferElement* elem,
if (!avcr) return DIFFERENT;
lenr -= avcr - msgr;
if (lenl != lenr) return DIFFERENT;
if (fastcmp<memcmp>(avcl + strlen(avc), avcr + strlen(avc), lenl))
// TODO: After b/35468874 is addressed, revisit "lenl > strlen(avc)"
// condition, it might become superflous.
if (lenl > strlen(avc) &&
fastcmp<memcmp>(avcl + strlen(avc), avcr + strlen(avc),
lenl - strlen(avc))) {
return DIFFERENT;
}
return SAME;
}