Skip to content

Commit 77e110a

Browse files
committed
transport-helper: check dup() return in get_exporter
get_exporter() duplicates helper->in via dup() and stores the result in fastexport->out. If dup() fails (fd exhaustion), it returns -1. The child_process machinery interprets out = -1 as "create a pipe for stdout", which would silently change the fast-export process's output wiring: instead of sending data back through the helper's input fd, it would write to a new pipe that nobody reads from. Check the return value and report the error before proceeding. Pointed out by Coverity. Assisted-by: Claude Opus 4.6 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 2903d61 commit 77e110a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

transport-helper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ static int get_exporter(struct transport *transport,
491491
/* we need to duplicate helper->in because we want to use it after
492492
* fastexport is done with it. */
493493
fastexport->out = dup(helper->in);
494+
if (fastexport->out < 0)
495+
return error_errno(_("could not dup helper output fd"));
494496
strvec_push(&fastexport->args, "fast-export");
495497
strvec_push(&fastexport->args, "--use-done-feature");
496498
strvec_push(&fastexport->args, data->signed_tags ?

0 commit comments

Comments
 (0)