Skip to content

Commit 1b0eeec

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Ben Toews <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf98a52 commit 1b0eeec

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

gpg-interface.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,19 @@ void set_signing_key(const char *key)
128128
int git_gpg_config(const char *var, const char *value, void *cb)
129129
{
130130
if (!strcmp(var, "user.signingkey")) {
131+
if (!value)
132+
return config_error_nonbool(var);
131133
set_signing_key(value);
134+
return 0;
132135
}
136+
133137
if (!strcmp(var, "gpg.program")) {
134138
if (!value)
135139
return config_error_nonbool(var);
136140
gpg_program = xstrdup(value);
141+
return 0;
137142
}
143+
138144
return 0;
139145
}
140146

0 commit comments

Comments
 (0)