summaryrefslogtreecommitdiff
path: root/gpg-interface.c
diff options
context:
space:
mode:
authorHenning Schild <henning.schild@siemens.com>2018-07-17 12:50:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-18 17:02:20 (GMT)
commit42149d7f4b1424b29c0bae4f564d5f50a856bcea (patch)
tree960c1960971d40bd541a239fa51ffcefe05d396b /gpg-interface.c
parent58af57e1c886a7c9fed7fb35f2dd8dd14cc5e4e0 (diff)
downloadgit-42149d7f4b1424b29c0bae4f564d5f50a856bcea.zip
git-42149d7f4b1424b29c0bae4f564d5f50a856bcea.tar.gz
git-42149d7f4b1424b29c0bae4f564d5f50a856bcea.tar.bz2
gpg-interface: do not hardcode the key string len anymore
gnupg does print the keyid followed by a space and the signer comes next. The same pattern is also used in gpgsm, but there the key length would be 40 instead of 16. Instead of hardcoding the expected length, find the first space and calculate it. Input that does not match the expected format will be ignored now, before we jumped to found+17 which might have been behind the end of an unexpected string. Signed-off-by: Henning Schild <henning.schild@siemens.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index a02db76..51cad90 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -95,10 +95,11 @@ static void parse_gpg_output(struct signature_check *sigc)
sigc->result = sigcheck_gpg_status[i].result;
/* The trust messages are not followed by key/signer information */
if (sigc->result != 'U') {
- sigc->key = xmemdupz(found, 16);
+ next = strchrnul(found, ' ');
+ sigc->key = xmemdupz(found, next - found);
/* The ERRSIG message is not followed by signer information */
- if (sigc-> result != 'E') {
- found += 17;
+ if (*next && sigc-> result != 'E') {
+ found = next + 1;
next = strchrnul(found, '\n');
sigc->signer = xmemdupz(found, next - found);
}