Skip to content

Avoid blocking forever when fetching from misbehaving servers #135

@kim

Description

@kim

Following up a conversation elsewhere, the following situation can legitimately occur:

11:18:08.860027 pkt-line.c:80           packet:  upload-pack> version 2
11:18:08.860139 pkt-line.c:80           packet:  upload-pack> agent=git/2.20.1
11:18:08.860154 pkt-line.c:80           packet:  upload-pack> ls-refs
11:18:08.860483 pkt-line.c:80           packet:  upload-pack> fetch=shallow ref-in-want
11:18:08.860504 pkt-line.c:80           packet:  upload-pack> server-option
11:18:08.860514 pkt-line.c:80           packet:  upload-pack> 0000
11:18:08.867555 pkt-line.c:80           packet:  upload-pack< command=ls-refs
11:18:08.867581 pkt-line.c:80           packet:  upload-pack< agent=git/oxide-0.8.0
11:18:08.867696 pkt-line.c:80           packet:  upload-pack< 0001
11:18:08.867731 pkt-line.c:80           packet:  upload-pack< symrefs
11:18:08.867751 pkt-line.c:80           packet:  upload-pack< peel
11:18:08.867764 pkt-line.c:80           packet:  upload-pack< ref-prefix refs/heads/
11:18:08.867777 pkt-line.c:80           packet:  upload-pack< ref-prefix refs/pulls/
11:18:08.867916 pkt-line.c:80           packet:  upload-pack< 0000
11:18:08.868519 pkt-line.c:80           packet:  upload-pack> 0000
11:18:08.871748 pkt-line.c:80           packet:  upload-pack< command=fetch
11:18:08.871784 pkt-line.c:80           packet:  upload-pack< agent=git/oxide-0.8.0
11:18:08.871796 pkt-line.c:80           packet:  upload-pack< 0001
11:18:08.871839 pkt-line.c:80           packet:  upload-pack< thin-pack
11:18:08.871851 pkt-line.c:80           packet:  upload-pack< include-tag
11:18:08.871863 pkt-line.c:80           packet:  upload-pack< ofs-delta
11:18:08.871874 pkt-line.c:80           packet:  upload-pack< done
11:18:08.871881 pkt-line.c:80           packet:  upload-pack< 0000

Here, the client did not send any wants or haves, and the want-refs did not match any refs on the remote side (due to a bug in git, but this could happen legitimately). The server thus determines that no packfile can be built from this information, and sends done. A packfile section is never sent.

The fetch function in this case blocks indefinitely, waiting for negotiation messages or a packfile. Instead, it should consider the done, break the loop, and terminate the conversation by sending a flush packet (as per normal behaviour).

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedan issue is accepted as shortcoming to be fixed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions