diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-06-08 18:06:30 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-06-08 18:06:30 -0700 |
| commit | b37fd14beb39b9f545bd72e42e1bdbb00bad4b3d (patch) | |
| tree | 73b0516cbdf8593e0fb045d56809db3285275d05 /fetch-pack.c | |
| parent | ded44afa023c981d803b56f42284ed0597a174ee (diff) | |
| parent | b0df0c16ead4c5512d506dcbbdf31194d992803c (diff) | |
| download | git-b37fd14beb39b9f545bd72e42e1bdbb00bad4b3d.tar.xz | |
Merge branch 'dl/remote-curl-deadlock-fix'
On-the-wire protocol v2 easily falls into a deadlock between the
remote-curl helper and the fetch-pack process when the server side
prematurely throws an error and disconnects. The communication has
been updated to make it more robust.
* dl/remote-curl-deadlock-fix:
stateless-connect: send response end packet
pkt-line: define PACKET_READ_RESPONSE_END
remote-curl: error on incomplete packet
pkt-line: extern packet_length()
transport: extract common fetch_pack() call
remote-curl: remove label indentation
remote-curl: fix typo
Diffstat (limited to 'fetch-pack.c')
| -rw-r--r-- | fetch-pack.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/fetch-pack.c b/fetch-pack.c index 7eaa19d7c1..d8bbf45ee2 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1451,6 +1451,13 @@ enum fetch_state { FETCH_DONE, }; +static void do_check_stateless_delimiter(const struct fetch_pack_args *args, + struct packet_reader *reader) +{ + check_stateless_delimiter(args->stateless_rpc, reader, + _("git fetch-pack: expected response end packet")); +} + static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, int fd[2], const struct ref *orig_ref, @@ -1535,6 +1542,10 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, /* Process ACKs/NAKs */ switch (process_acks(negotiator, &reader, &common)) { case READY: + /* + * Don't check for response delimiter; get_pack() will + * read the rest of this response. + */ state = FETCH_GET_PACK; break; case COMMON_FOUND: @@ -1542,6 +1553,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, seen_ack = 1; /* fallthrough */ case NO_COMMON_FOUND: + do_check_stateless_delimiter(args, &reader); state = FETCH_SEND_REQUEST; break; } @@ -1561,6 +1573,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, process_section_header(&reader, "packfile", 0); if (get_pack(args, fd, pack_lockfile, sought, nr_sought)) die(_("git fetch-pack: fetch failed.")); + do_check_stateless_delimiter(args, &reader); state = FETCH_DONE; break; |
