summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transports/http.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/transports/http.c b/src/transports/http.c
index 061c9d091..1d9b807a3 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -1102,6 +1102,7 @@ static int http_stream_read(
http_subtransport *t = OWNING_SUBTRANSPORT(s);
parser_context ctx;
size_t bytes_parsed;
+ int connected = 1;
bool auth_replay;
replay:
@@ -1150,7 +1151,7 @@ replay:
s->received_response = 1;
}
- while (!*bytes_read && !t->parse_finished) {
+ while (connected && !*bytes_read && !t->parse_finished) {
size_t data_offset;
/*
@@ -1169,7 +1170,7 @@ replay:
data_offset = t->parse_buffer.offset;
- if (gitno_recv(&t->parse_buffer) < 0)
+ if ((connected = gitno_recv(&t->parse_buffer)) < 0)
return -1;
/*
@@ -1212,6 +1213,12 @@ replay:
}
}
+ /* read returned 0; we got an eof before a complete message */
+ if (!*bytes_read && !t->parse_finished) {
+ git_error_set(GIT_ERROR_NET, "premature end of file");
+ return -1;
+ }
+
if (auth_replay) {
int error;