Skip to content

Commit 61530c4

Browse files
committed
transports: smart: abort ref announcement on early end of stream
When reading a server's reference announcements via the smart protocol, we expect the server to send multiple flushes before the protocol is finished. If we fail to receive new data from the socket, we will only return an end of stream error if we have not seen any flush yet. This logic is flawed in that we may run into an infinite loop when receiving a server's reference announcement with a bogus flush packet. E.g. assume the last flushing package is changed to not be '0000' but instead any other value. In this case, we will still await one more flush package and ignore the fact that we are not receiving any data from the socket, causing an infinite loop. Fix the issue by always returning `GIT_EEOF` if the socket indicates an end of stream.
1 parent 6502398 commit 61530c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/transports/smart_protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int git_smart__store_refs(transport_smart *t, int flushes)
5050
if ((recvd = gitno_recv(buf)) < 0)
5151
return recvd;
5252

53-
if (recvd == 0 && !flush) {
53+
if (recvd == 0) {
5454
giterr_set(GITERR_NET, "early EOF");
5555
return GIT_EEOF;
5656
}

0 commit comments

Comments
 (0)