Skip to content
  • Junio C Hamano's avatar
    git-apply: do not read past the end of buffer · 6b763c42
    Junio C Hamano authored
    
    
    When the preimage we are patching is shorter than what the patch
    text expects, we tried to match the buffer contents at the
    "original" line with the fragment in full, without checking we
    have enough data to match in the preimage.  This caused the size
    of a later memmove() to wrap around and attempt to scribble
    almost the entire address space.  Not good.
    
    The code that follows the part this patch touches tries to match
    the fragment with line offsets.  Curiously, that code does not
    have the problem --- it guards against reading past the end of
    the preimage.
    
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    6b763c42