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

This commit is contained in:
TreeHugger Robot 2017-03-08 20:24:57 +00:00 committed by Android (Google) Code Review
commit affc6cd0ed

View file

@ -182,7 +182,10 @@ static enum match_type identical(LogBufferElement* elem, LogBufferElement* last)
if (!avcr) return DIFFERENT;
lenr -= avcr - msgr;
if (lenl != lenr) return DIFFERENT;
if (fastcmp<memcmp>(avcl + strlen(avc),
// 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;