Skip to content

Fix type confusion in git_smart__connect#4695

Merged
pks-t merged 1 commit intolibgit2:masterfrom
nelhage:git_pkt-type-confusion
Jun 25, 2018
Merged

Fix type confusion in git_smart__connect#4695
pks-t merged 1 commit intolibgit2:masterfrom
nelhage:git_pkt-type-confusion

Conversation

@nelhage
Copy link
Copy Markdown
Contributor

@nelhage nelhage commented Jun 24, 2018

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.

This was found by an oss-fuzz integration I'm working on.

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`

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually check the other way round, with the constant on the right-hand side. But here you seem to simply be adhering to style of surrounding code, so this is okay

@pks-t pks-t merged commit e6cdd17 into libgit2:master Jun 25, 2018
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 25, 2018

Thanks for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants