Skip to content

Commit 59bfdfb

Browse files
peffgitster
authored andcommitted
receive-pack: redirect unpack-objects stdout to /dev/null
The unpack-objects command should not generally produce any output on stdout. However, if it's given extra input after the packfile, it will spew the remainder to stdout. When called by receive-pack, this means we will break protocol, since our stdout is connected to the remote send-pack. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8ef2794 commit 59bfdfb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

builtin/receive-pack.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ static const char *unpack(void)
821821

822822
if (ntohl(hdr.hdr_entries) < unpack_limit) {
823823
int code, i = 0;
824+
struct child_process child;
824825
const char *unpacker[5];
825826
unpacker[i++] = "unpack-objects";
826827
if (quiet)
@@ -829,7 +830,11 @@ static const char *unpack(void)
829830
unpacker[i++] = "--strict";
830831
unpacker[i++] = hdr_arg;
831832
unpacker[i++] = NULL;
832-
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
833+
memset(&child, 0, sizeof(child));
834+
child.argv = unpacker;
835+
child.no_stdout = 1;
836+
child.git_cmd = 1;
837+
code = run_command(&child);
833838
if (!code)
834839
return NULL;
835840
return "unpack-objects abnormal exit";

0 commit comments

Comments
 (0)