Commit e6cdd17c846648aa8e1e025fa1988475886a551e

Patrick Steinhardt 2018-06-25T13:57:19

Merge pull request #4695 from nelhage/git_pkt-type-confusion Fix type confusion in git_smart__connect

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 79b5a3e..7a5dd61 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -266,7 +266,12 @@ static int git_smart__connect(
 	/* We now have loaded the refs. */
 	t->have_refs = 1;
 
-	first = (git_pkt_ref *)git_vector_get(&t->refs, 0);
+	pkt = (git_pkt *)git_vector_get(&t->refs, 0);
+	if (pkt && GIT_PKT_REF != pkt->type) {
+		giterr_set(GITERR_NET, "invalid response");
+		return -1;
+	}
+	first = (git_pkt_ref *)pkt;
 
 	if ((error = git_vector_init(&symrefs, 1, NULL)) < 0)
 		return error;