Skip to content

Commit e6cdd17

Browse files
authored
Merge pull request libgit2#4695 from nelhage/git_pkt-type-confusion
Fix type confusion in git_smart__connect
2 parents 983f72c + 0098d74 commit e6cdd17

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/transports/smart.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,12 @@ static int git_smart__connect(
266266
/* We now have loaded the refs. */
267267
t->have_refs = 1;
268268

269-
first = (git_pkt_ref *)git_vector_get(&t->refs, 0);
269+
pkt = (git_pkt *)git_vector_get(&t->refs, 0);
270+
if (pkt && GIT_PKT_REF != pkt->type) {
271+
giterr_set(GITERR_NET, "invalid response");
272+
return -1;
273+
}
274+
first = (git_pkt_ref *)pkt;
270275

271276
if ((error = git_vector_init(&symrefs, 1, NULL)) < 0)
272277
return error;

0 commit comments

Comments
 (0)