mirror of
https://github.com/git/git.git
synced 2026-03-17 04:00:11 +01:00
parse_signed_commit: really use the entire commit log message
... even beyond the first NUL in the buffer, when checking the commit against the detached signature in the header. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
21
commit.c
21
commit.c
@@ -854,28 +854,31 @@ int parse_signed_commit(const unsigned char *sha1,
|
||||
unsigned long size;
|
||||
enum object_type type;
|
||||
char *buffer = read_sha1_file(sha1, &type, &size);
|
||||
int in_header, saw_signature = -1;
|
||||
char *line;
|
||||
int saw_signature = -1;
|
||||
char *line, *tail;
|
||||
|
||||
if (!buffer || type != OBJ_COMMIT)
|
||||
goto cleanup;
|
||||
|
||||
line = buffer;
|
||||
in_header = 1;
|
||||
tail = buffer + size;
|
||||
saw_signature = 0;
|
||||
while (*line) {
|
||||
char *next = strchrnul(line, '\n');
|
||||
if (*next)
|
||||
while (line < tail) {
|
||||
char *next = memchr(line, '\n', tail - line);
|
||||
if (!next)
|
||||
next = tail;
|
||||
else
|
||||
next++;
|
||||
if (in_header && !prefixcmp(line, gpg_sig_header)) {
|
||||
if (!prefixcmp(line, gpg_sig_header)) {
|
||||
const char *sig = line + gpg_sig_header_len;
|
||||
strbuf_add(signature, sig, next - sig);
|
||||
saw_signature = 1;
|
||||
} else {
|
||||
if (*line == '\n')
|
||||
/* dump the whole remainder of the buffer */
|
||||
next = tail;
|
||||
strbuf_add(payload, line, next - line);
|
||||
}
|
||||
if (*line == '\n')
|
||||
in_header = 0;
|
||||
line = next;
|
||||
}
|
||||
cleanup:
|
||||
|
||||
Reference in New Issue
Block a user