• brian m. carlson's avatar
    tree-walk: store object_id in a separate member · ea82b2a0
    brian m. carlson authored
    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: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
notes.c 36.2 KB