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

This commit is contained in:
Treehugger Robot 2017-03-15 06:46:27 +00:00 committed by Gerrit Code Review
commit 3d028f14c8
1 changed files with 6 additions and 1 deletions

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;
}