Skip to content

Commit 8b35542

Browse files
glandiumgitster
authored andcommitted
dup() the input fd for fast-import used for remote helpers
When a remote helper exposes the "import" capability, stdout of the helper is sent to stdin of a new fast-import process. This is done by setting the corresponding child_process's in field to the value of the out field of the helper child_process. The child_process API is defined to close the file descriptors it's given when calling start_command. This means when start_command is called for the fast-import process, its input fd (the output fd of the helper), is closed. But when the transport helper is later destroyed, in disconnect_helper, its input and output are closed, which means close() is called with an invalid fd (since it was already closed as per above). Or worse, with a valid fd owned by something else (since fd numbers can be reused). Signed-off-by: Mike Hommey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aeb582a commit 8b35542

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

transport-helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static int get_importer(struct transport *transport, struct child_process *fasti
421421
struct helper_data *data = transport->data;
422422
int cat_blob_fd, code;
423423
child_process_init(fastimport);
424-
fastimport->in = helper->out;
424+
fastimport->in = xdup(helper->out);
425425
argv_array_push(&fastimport->args, "fast-import");
426426
argv_array_push(&fastimport->args, debug ? "--stats" : "--quiet");
427427

0 commit comments

Comments
 (0)