Skip to content
  • Jeff King's avatar
    patch-delta: handle truncated copy parameters · 9514b0b2
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    When we see a delta command instructing us to copy bytes
    from the base, we have to read the offset and size from the
    delta stream. We do this without checking whether we're at
    the end of the stream, meaning we may read past the end of
    the buffer.
    
    In practice this isn't exploitable in any interesting way
    because:
    
      1. Deltas are always in packfiles, so we have at least a
         20-byte trailer that we'll end up reading.
    
      2. The worst case is that we try to perform a nonsense
         copy from the base object into the result, based on
         whatever was in the pack stream next. In most cases
         this will simply fail due to our bounds-checks against
         the base or the result.
    
         But even if you carefully constructed a pack stream for
         which it succeeds, it wouldn't perform any delta
         operation that you couldn't have simply included in a
         non-broken form.
    
    But obviously it's poor form to read past the end of the
    buffer we've been given. Unfortunat...
    9514b0b2