{"thread":{"id":"48860","subject":"[PATCH 1/2] builtin/receive-pack: use check_signature from gpg-interface","startedAt":"2018-07-11T08:38:32Z","lastAt":"2018-07-11T08:38:35Z","messageCount":2,"participants":["Henning Schild"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"352215","messageId":"f9e371c8dd2a17ddb5fd5989a7fdad1c0d1bb6e7.1531298241.git.henning.schild@siemens.com","threadId":"48860","inReplyTo":null,"subject":"[PATCH 1/2] builtin/receive-pack: use check_signature from gpg-interface","fromName":"Henning Schild","fromEmail":"henning.schild@siemens.com","sentAt":"2018-07-11T08:38:24Z","receivedAt":"2018-07-11T08:38:32Z","isPatch":true,"sender":{"key":"henning.schild@siemens.com","avatar":"https://avatars.githubusercontent.com/u/7237877?v=4"},"body":"The combination of verify_signed_buffer followed by parse_gpg_output is\navailable as check_signature. Use that instead of implementing it again.\n\nSigned-off-by: Henning Schild <henning.schild@siemens.com>\n---\n builtin/receive-pack.c | 17 ++---------------\n 1 file changed, 2 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 68d36e0a5..9f0583deb 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -629,8 +629,6 @@ static void prepare_push_cert_sha1(struct child_process *proc)\n \t\treturn;\n \n \tif (!already_done) {\n-\t\tstruct strbuf gpg_output = STRBUF_INIT;\n-\t\tstruct strbuf gpg_status = STRBUF_INIT;\n \t\tint bogs /* beginning_of_gpg_sig */;\n \n \t\talready_done = 1;\n@@ -639,22 +637,11 @@ static void prepare_push_cert_sha1(struct child_process *proc)\n \t\t\toidclr(&push_cert_oid);\n \n \t\tmemset(&sigcheck, '\\0', sizeof(sigcheck));\n-\t\tsigcheck.result = 'N';\n \n \t\tbogs = parse_signature(push_cert.buf, push_cert.len);\n-\t\tif (verify_signed_buffer(push_cert.buf, bogs,\n-\t\t\t\t\t push_cert.buf + bogs, push_cert.len - bogs,\n-\t\t\t\t\t &gpg_output, &gpg_status) < 0) {\n-\t\t\t; /* error running gpg */\n-\t\t} else {\n-\t\t\tsigcheck.payload = push_cert.buf;\n-\t\t\tsigcheck.gpg_output = gpg_output.buf;\n-\t\t\tsigcheck.gpg_status = gpg_status.buf;\n-\t\t\tparse_gpg_output(&sigcheck);\n-\t\t}\n+\t\tcheck_signature(push_cert.buf, bogs, push_cert.buf + bogs,\n+\t\t\t\tpush_cert.len - bogs, &sigcheck);\n \n-\t\tstrbuf_release(&gpg_output);\n-\t\tstrbuf_release(&gpg_status);\n \t\tnonce_status = check_nonce(push_cert.buf, bogs);\n \t}\n \tif (!is_null_oid(&push_cert_oid)) {\n-- \n2.16.4\n\n"},{"id":"352216","messageId":"b568214bffb7f2dcaf2495990c5a6b478863d157.1531298241.git.henning.schild@siemens.com","threadId":"48860","inReplyTo":"f9e371c8dd2a17ddb5fd5989a7fdad1c0d1bb6e7.1531298241.git.henning.schild@siemens.com","subject":"[PATCH 2/2] gpg-interface: make parse_gpg_output static and remove from interface header","fromName":"Henning Schild","fromEmail":"henning.schild@siemens.com","sentAt":"2018-07-11T08:38:25Z","receivedAt":"2018-07-11T08:38:35Z","isPatch":true,"sender":{"key":"henning.schild@siemens.com","avatar":"https://avatars.githubusercontent.com/u/7237877?v=4"},"body":"Turn parse_gpg_output into a static function, the only outside user was\nmigrated in an earlier commit.\n\nSigned-off-by: Henning Schild <henning.schild@siemens.com>\n---\n gpg-interface.c | 2 +-\n gpg-interface.h | 2 --\n 2 files changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/gpg-interface.c b/gpg-interface.c\nindex 0647bd634..09ddfbc26 100644\n--- a/gpg-interface.c\n+++ b/gpg-interface.c\n@@ -35,7 +35,7 @@ static struct {\n \t{ 'R', \"\\n[GNUPG:] REVKEYSIG \"},\n };\n \n-void parse_gpg_output(struct signature_check *sigc)\n+static void parse_gpg_output(struct signature_check *sigc)\n {\n \tconst char *buf = sigc->gpg_status;\n \tint i;\ndiff --git a/gpg-interface.h b/gpg-interface.h\nindex a5e6517ae..5ecff4aa0 100644\n--- a/gpg-interface.h\n+++ b/gpg-interface.h\n@@ -33,8 +33,6 @@ void signature_check_clear(struct signature_check *sigc);\n  */\n size_t parse_signature(const char *buf, size_t size);\n \n-void parse_gpg_output(struct signature_check *);\n-\n /*\n  * Create a detached signature for the contents of \"buffer\" and append\n  * it after \"signature\"; \"buffer\" and \"signature\" can be the same\n-- \n2.16.4\n\n"}]}