Skip to content

Commit 832ee79

Browse files
committed
Merge branch 'jl/pack-transfer-avoid-double-close'
The codepath that send_pack() calls pack_objects() mistakenly closed the same file descriptor twice, leading to potentially closing a wrong file descriptor that was opened in the meantime. * jl/pack-transfer-avoid-double-close: Clear fd after closing to avoid double-close error
2 parents 02882bc + 37cb1dd commit 832ee79

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

fetch-pack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ static int get_pack(struct fetch_pack_args *args,
747747
close(cmd.out);
748748
}
749749

750+
if (!use_sideband)
751+
/* Closed by start_command() */
752+
xd[0] = -1;
753+
750754
ret = finish_command(&cmd);
751755
if (!ret || (args->check_self_contained_and_connected && ret == 1))
752756
args->self_contained_and_connected =

send-pack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,12 @@ int send_pack(struct send_pack_args *args,
302302
shutdown(fd[0], SHUT_WR);
303303
if (use_sideband)
304304
finish_async(&demux);
305+
fd[1] = -1;
305306
return -1;
306307
}
308+
if (!args->stateless_rpc)
309+
/* Closed by pack_objects() via start_command() */
310+
fd[1] = -1;
307311
}
308312
if (args->stateless_rpc && cmds_sent)
309313
packet_flush(out);

0 commit comments

Comments
 (0)