• Jeff King's avatar
    commit: record buffer length in cache · 8597ea3a
    Jeff King authored
    Most callsites which use the commit buffer try to use the
    cached version attached to the commit, rather than
    re-reading from disk. Unfortunately, that interface provides
    only a pointer to the NUL-terminated buffer, with no
    indication of the original length.
    For the most part, this doesn't matter. People do not put
    NULs in their commit messages, and the log code is happy to
    treat it all as a NUL-terminated string. However, some code
    paths do care. For example, when checking signatures, we
    want to be very careful that we verify all the bytes to
    avoid malicious trickery.
    This patch just adds an optional "size" out-pointer to
    get_commit_buffer and friends. The existing callers all pass
    NULL (there did not seem to be any obvious sites where we
    could avoid an immediate strlen() call, though perhaps with
    some further refactoring we could).
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
notes-merge.c 22.7 KB