Skip to content
  • Jeff King's avatar
    write_untracked_extension: use FLEX_ALLOC helper · e0b83735
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    We perform unchecked additions when computing the size of a
    "struct ondisk_untracked_cache". This is unlikely to have an
    integer overflow in practice, but we'd like to avoid this
    dangerous pattern to make further audits easier.
    
    Note that there's one subtlety here, though.  We protect
    ourselves against a NULL exclude_per_dir entry in our
    source, and avoid calling strlen() on it, keeping "len" at
    0. But later, we unconditionally memcpy "len + 1" bytes to
    get the trailing NUL byte. If we did have a NULL
    exclude_per_dir, we would read from bogus memory.
    
    As it turns out, though, we always create this field
    pointing to a string literal, so there's no bug. We can just
    get rid of the pointless extra conditional.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    e0b83735