• R
    merge: fix out-of-bounds memory access · c7cddc1a
    René Scharfe 提交于
    The parameter n of unpack_callback() can have a value of up to
    MAX_UNPACK_TREES.  The check at the top of unpack_trees() (its only
    (indirect) caller) makes sure it cannot exceed this limit.
    
    unpack_callback() passes it and the array src to unpack_nondirectories(),
    which has this loop:
    
    	for (i = 0; i < n; i++) {
    		/* ... */
    		src[i + o->merge] = o->df_conflict_entry;
    
    o->merge can be 0 or 1, so unpack_nondirectories() potentially accesses
    the array src at index MAX_UNPACK_TREES.  This patch makes it big enough.
    Reported-by: NIngo Molnar <mingo@elte.hu>
    Signed-off-by: NRené Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    c7cddc1a
unpack-trees.c 24.4 KB