DOG-014 MED: PACKResolveOfs ping-pong sizing — undocumented invariant, latent heap overflow

dog/git/PACK.c's PACKResolveOfs applies the delta chain bottom-up, ping-ponging the apply result between delta[0]+half and base[0] (PACK.c:265-285), where half = deltalen/2 (:213). Every DELTApply output gauge is {dst,dst,dst+half} (:278), so when dst == base[0] up to half bytes may be written into the base scratch — which is baselen bytes. Safety therefore REQUIRES half <= baselen, i.e. deltalen <= 2*baselen, and NOTHING checks or documents it. A symmetric over-read exists via bsl = {src, src+outsz} (:277). Latent today (keeper KEEP.c:428-429 and the tests size both scratches equally, so half = baselen/2 < baselen), but a future caller giving a larger delta scratch than base scratch gets an attacker-result_sz-driven heap overflow. Distinct from the keeper-side MEM-022/GIT-004 resolver work — this bug is in the surviving OFS apply loop in dog/git. Method: Issues.

Input

Context

Goals

Constraints

WIP

Design decisions

TODOs

Blockers and bummers

Outcome