git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, ZhenTian <loooseleaves@gmail.com>
Subject: [PATCH] gpg-interface: check gpg signature for correct header
Date: Tue, 14 Jun 2016 13:11:19 +0200	[thread overview]
Message-ID: <2f473a993b6bc951dec76d38c11d0e600b59b8d3.1465902530.git.git@drmicha.warpmail.net> (raw)
In-Reply-To: <e129da8e-4e1d-c535-ca62-d2a4c2e23799@drmicha.warpmail.net>

When we create a signature, it may happen that gpg returns with
"success" but not with an actual detached signature on stdout.

Check for the correct header to catch these cases better.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
This catches at least my echo example.

We could do a full blown gpg signature check, of course.

 gpg-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gpg-interface.c b/gpg-interface.c
index c4b1e8c..664796f 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -185,7 +185,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
 
 	sigchain_pop(SIGPIPE);
 
-	if (finish_command(&gpg) || !len || len < 0)
+	if (finish_command(&gpg) || !len || len < 0 || strncmp(signature->buf, PGP_SIGNATURE, strlen(PGP_SIGNATURE)))
 		return error(_("gpg failed to sign the data"));
 
 	/* Strip CR from the line endings, in case we are on Windows. */
-- 
2.9.0.382.g87fd384

  reply	other threads:[~2016-06-14 11:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14  7:50 I lost my commit signature ZhenTian
2016-06-14  7:58 ` Jeff King
2016-06-14  8:09   ` ZhenTian
2016-06-14  8:18     ` Jeff King
2016-06-14  8:39       ` ZhenTian
2016-06-14  9:41         ` Jeff King
2016-06-14  9:56           ` ZhenTian
2016-06-14 10:57           ` Michael J Gruber
2016-06-14 11:11             ` Michael J Gruber [this message]
2016-06-14 11:20               ` [PATCH] gpg-interface: check gpg signature for correct header Jeff King
2016-06-14 11:34                 ` Michael J Gruber
2016-06-14 11:58                   ` Michael J Gruber
2016-06-14 12:05                     ` [PATCHv2] " Michael J Gruber
2016-06-14 14:44                     ` [PATCHv3] gpg-interface: check gpg signature creation status Michael J Gruber
2016-06-14 18:13                       ` Junio C Hamano
2016-06-14 21:50                         ` Jeff King
2016-06-14 22:26                           ` Jeff King
2016-06-14 23:47                             ` Junio C Hamano
2016-06-15  0:56                               ` Jeff King
2016-06-15  7:17                                 ` Michael J Gruber
2016-06-16  9:25                                   ` Jeff King
2016-06-16 11:30                                     ` Michael J Gruber
2016-06-15  3:28                             ` Jeff King
2016-06-15  4:27             ` I lost my commit signature ZhenTian
2016-06-15  4:34               ` Jeff King
2016-06-15  7:07                 ` Michael J Gruber
2016-06-15 10:36                   ` ZhenTian
2016-06-16  7:34                   ` Jeff King
2016-06-16 17:06                     ` Junio C Hamano
2016-06-17  8:18                       ` Michael J Gruber
2016-06-17 16:39                         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f473a993b6bc951dec76d38c11d0e600b59b8d3.1465902530.git.git@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=loooseleaves@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).