summaryrefslogtreecommitdiff
path: root/credential.c
diff options
context:
space:
mode:
authorErik E Brady <brady@cisco.com>2018-03-29 18:00:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-29 22:33:55 (GMT)
commita0d51e8d0e866538632b16e13a5f51bc80eacf48 (patch)
tree6eef9f98aac9dc3f3c86e7009d5aac6378b78c39 /credential.c
parentd32eb83c1db7d0a8bb54fe743c6d1dd674d372c5 (diff)
downloadgit-a0d51e8d0e866538632b16e13a5f51bc80eacf48.zip
git-a0d51e8d0e866538632b16e13a5f51bc80eacf48.tar.gz
git-a0d51e8d0e866538632b16e13a5f51bc80eacf48.tar.bz2
credential: ignore SIGPIPE when writing to credential helpers
The credential subsystem can trigger SIGPIPE when writing to an external helper if that helper closes its stdin before reading the whole input. Normally this is rare, since helpers would need to read that input to make a decision about how to respond, but: 1. It's reasonable to configure a helper which only handles "get" while ignoring "store". Such a handler might not read stdin for "store", thereby rapidly closing stdin upon helper exit. 2. A broken or misbehaving helper might exit immediately. That's an error, but it's not reasonable for it to take down the parent Git process with SIGPIPE. Even with such a helper, seeing this problem should be rare. Getting SIGPIPE requires the helper racily exiting before we've written the fairly small credential output. Signed-off-by: Erik E Brady <brady@cisco.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'credential.c')
-rw-r--r--credential.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/credential.c b/credential.c
index 9747f47..62be651 100644
--- a/credential.c
+++ b/credential.c
@@ -5,6 +5,7 @@
#include "run-command.h"
#include "url.h"
#include "prompt.h"
+#include "sigchain.h"
void credential_init(struct credential *c)
{
@@ -227,8 +228,10 @@ static int run_credential_helper(struct credential *c,
return -1;
fp = xfdopen(helper.in, "w");
+ sigchain_push(SIGPIPE, SIG_IGN);
credential_write(c, fp);
fclose(fp);
+ sigchain_pop(SIGPIPE);
if (want_output) {
int r;