diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-11-02 09:38:40 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2016-11-02 09:42:56 +0100 |
commit | 62494bf234919e04a6e145d59942d2a05c96ae0d (patch) | |
tree | 8f9e28050fd6d93cdb7a3b72b73225c4035af71b /src/transports | |
parent | 61530c497dc23f6140557059ca9a55805c21b5fc (diff) | |
download | libgit2-62494bf234919e04a6e145d59942d2a05c96ae0d.tar.gz |
transports: smart: abort receiving packets on end of stream
When trying to receive packets from the remote, we loop until
either an error distinct to `GIT_EBUFS` occurs or until we
successfully parsed the packet. This does not honor the case
where we are looping over an already closed socket which has no
more data, leaving us in an infinite loop if we got a bogus
packet size or if the remote hang up.
Fix the issue by returning `GIT_EEOF` when we cannot read data
from the socket anymore.
Diffstat (limited to 'src/transports')
-rw-r--r-- | src/transports/smart_protocol.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index 5db4dda9a..c1e412436 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -222,8 +222,12 @@ static int recv_pkt(git_pkt **out, gitno_buffer *buf) if (error < 0 && error != GIT_EBUFS) return error; - if ((ret = gitno_recv(buf)) < 0) + if ((ret = gitno_recv(buf)) < 0) { return ret; + } else if (ret == 0) { + giterr_set(GITERR_NET, "early EOF"); + return GIT_EEOF; + } } while (error); gitno_consume(buf, line_end); |