Commit 0098d746 by Nelson Elhage

Fix type confusion in git_smart__connect

Nothing verifies that t->refs[0] is a GIT_PKT_REF. A remote can send
another packet type, ultimately resulting in a type confusion in
`git_smart__detect_caps`
parent e212011b
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment