Skip to content
  • brian m. carlson's avatar
    tree-walk: store object_id in a separate member · ea82b2a0
    brian m. carlson authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    When parsing a tree, we read the object ID directly out of the tree
    buffer. This is normally fine, but such an object ID cannot be used with
    oidcpy, which copies GIT_MAX_RAWSZ bytes, because if we are using SHA-1,
    there may not be that many bytes to copy.
    
    Instead, store the object ID in a separate struct member. Since we can
    no longer efficiently compute the path length, store that information as
    well in struct name_entry. Ensure we only copy the object ID into the
    new buffer if the path length is nonzero, as some callers will pass us
    an empty path with no object ID following it, and we will not want to
    read past the end of the buffer.
    
    Signed-off-by: default avatarbrian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    ea82b2a0