summaryrefslogtreecommitdiff
path: root/src/transports/smart_protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transports/smart_protocol.c')
-rw-r--r--src/transports/smart_protocol.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 8a094b698..948b93bdd 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -70,6 +70,12 @@ int git_smart__store_refs(transport_smart *t, int flushes)
return -1;
}
+ if (pkt->type == GIT_PKT_PACK) {
+ giterr_set(GITERR_NET, "unexpected packfile");
+ git__free(pkt);
+ return -1;
+ }
+
if (pkt->type != GIT_PKT_FLUSH && git_vector_insert(refs, pkt) < 0)
return -1;
@@ -317,27 +323,30 @@ on_error:
static int wait_while_ack(gitno_buffer *buf)
{
int error;
- git_pkt_ack *pkt = NULL;
+ git_pkt *pkt = NULL;
+ git_pkt_ack *ack = NULL;
while (1) {
- git__free(pkt);
+ git_pkt_free(pkt);
- if ((error = recv_pkt((git_pkt **)&pkt, NULL, buf)) < 0)
+ if ((error = recv_pkt(&pkt, NULL, buf)) < 0)
return error;
if (pkt->type == GIT_PKT_NAK)
break;
+ if (pkt->type != GIT_PKT_ACK)
+ continue;
- if (pkt->type == GIT_PKT_ACK &&
- (pkt->status != GIT_ACK_CONTINUE &&
- pkt->status != GIT_ACK_COMMON &&
- pkt->status != GIT_ACK_READY)) {
- git__free(pkt);
- return 0;
+ ack = (git_pkt_ack*)pkt;
+
+ if (ack->status != GIT_ACK_CONTINUE &&
+ ack->status != GIT_ACK_COMMON &&
+ ack->status != GIT_ACK_READY) {
+ break;
}
}
- git__free(pkt);
+ git_pkt_free(pkt);
return 0;
}
@@ -615,7 +624,8 @@ int git_smart__download_pack(
}
}
- git__free(pkt);
+ git_pkt_free(pkt);
+
if (error < 0)
goto done;