summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2021-02-11 02:08:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-11 07:35:42 (GMT)
commit88bce0e24c8f777fce1f726b4553bd32286bba04 (patch)
treec9461dfdbe2633707234f9bbe512f6db3b16877d
parent937032e14aaf1eab59c96dd78938be1c48c648e1 (diff)
downloadgit-88bce0e24c8f777fce1f726b4553bd32286bba04.zip
git-88bce0e24c8f777fce1f726b4553bd32286bba04.tar.gz
git-88bce0e24c8f777fce1f726b4553bd32286bba04.tar.bz2
ref-filter: hoist signature parsing
When we parse a signature in the ref-filter code, we continually increment the buffer pointer. Hoist the signature parsing above the blank line delimiting headers and body so we can find the signature when using a header to sign the buffer. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--ref-filter.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ref-filter.c b/ref-filter.c
index a4c68cf..5f8a443 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1221,6 +1221,8 @@ static void find_subpos(const char *buf,
const char *end = buf + strlen(buf);
const char *sigstart;
+ /* parse signature first; we might not even have a subject line */
+ parse_signature(buf, end - buf, &payload, &signature);
/* skip past header until we hit empty line */
while (*buf && *buf != '\n') {
@@ -1232,9 +1234,6 @@ static void find_subpos(const char *buf,
/* skip any empty lines */
while (*buf == '\n')
buf++;
-
- /* parse signature first; we might not even have a subject line */
- parse_signature(buf, end - buf, &payload, &signature);
*sig = strbuf_detach(&signature, siglen);
sigstart = buf + parse_signed_buffer(buf, strlen(buf));
@@ -1330,7 +1329,7 @@ static void grab_sub_body_contents(struct atom_value *val, int deref, void *buf)
v->s = xmemdupz(sigpos, siglen);
else if (atom->u.contents.option == C_LINES) {
struct strbuf s = STRBUF_INIT;
- const char *contents_end = bodylen + bodypos - siglen;
+ const char *contents_end = bodypos + nonsiglen;
/* Size is the length of the message after removing the signature */
append_lines(&s, subpos, contents_end - subpos, atom->u.contents.nlines);