]> git.ipfire.org Git - thirdparty/git.git/commit - notes-merge.c
commit: record buffer length in cache
authorJeff King <peff@peff.net>
Tue, 10 Jun 2014 21:44:13 +0000 (17:44 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jun 2014 19:09:38 +0000 (12:09 -0700)
commit8597ea3afea067b39ba7d4adae7ec6c1ee0e7c91
tree01419168b4f08949baeabe5b8650066e6a92732c
parentc1b3c71f4b4571abb2b2a457122fd100dc9f7eb0
commit: record buffer length in cache

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: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 files changed:
builtin/blame.c
builtin/fast-export.c
builtin/fmt-merge-msg.c
builtin/index-pack.c
builtin/log.c
builtin/rev-list.c
commit.c
commit.h
fsck.c
log-tree.c
merge-recursive.c
notes-merge.c
object.c
pretty.c
sequencer.c
sha1_name.c