summaryrefslogtreecommitdiff
path: root/gpg-interface.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-04-13 21:18:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-16 05:15:02 (GMT)
commit1b0eeec3f359888f8a638de8af253f621a5b836e (patch)
treee6fca8ffe4624b808ced2ea3add8c7e4f07d7ef4 /gpg-interface.c
parentcf98a52ba4d8176a3ec73c72d296275999ecb52d (diff)
downloadgit-1b0eeec3f359888f8a638de8af253f621a5b836e.zip
git-1b0eeec3f359888f8a638de8af253f621a5b836e.tar.gz
git-1b0eeec3f359888f8a638de8af253f621a5b836e.tar.bz2
gpg-interface: handle bool user.signingkey
The config handler for user.signingkey does not check for a boolean value, and thus: git -c user.signingkey tag will segfault. We could fix this and even shorten the code by using git_config_string(). But our set_signing_key() helper is used by other code outside of gpg-interface.c, so we must keep it (and we may as well use it, because unlike git_config_string() it does not leak when we overwrite an old value). Ironically, the handler for gpg.program just below _could_ use git_config_string() but doesn't. But since we're going to touch that in a future patch, we'll leave it alone for now. We will add some whitespace and returns in preparation for adding more config keys, though. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Ben Toews <mastahyeti@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index 4feacf1..61c0690 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -128,13 +128,19 @@ void set_signing_key(const char *key)
int git_gpg_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "user.signingkey")) {
+ if (!value)
+ return config_error_nonbool(var);
set_signing_key(value);
+ return 0;
}
+
if (!strcmp(var, "gpg.program")) {
if (!value)
return config_error_nonbool(var);
gpg_program = xstrdup(value);
+ return 0;
}
+
return 0;
}