Skip to content

Remove GIT_PKT_PACK entirely#4704

Merged
pks-t merged 5 commits into
libgit2:masterfrom
nelhage:no-pkt-pack
Jul 19, 2018
Merged

Remove GIT_PKT_PACK entirely#4704
pks-t merged 5 commits into
libgit2:masterfrom
nelhage:no-pkt-pack

Conversation

@nelhage
Copy link
Copy Markdown
Contributor

@nelhage nelhage commented Jun 26, 2018

This is a heavier-handed alternative to #4694

git_pkt_pack/GIT_PKT_PACK are, as best I can tell, never used by any client of the pack APIs. Futhermore, they are incredibly dangerous; Because https://github.com/libgit2/libgit2/blob/master/src/transports/smart_pkt.c#L419-L423 does not advance out, any client is required to check for GIT_PKT_PACK and bail out, or else go into an infinite loop calling git_pkt_parse_line to get a new packet, which will from that point forward always return a GIT_PKT_PACK.

My fuzzer has found at least two callers that can be forced into an infinite loop via a misplaced PACK, and I suspect there are more.

@ethomson
Copy link
Copy Markdown
Member

This seems reasonable to me, but getting 👀 on it by @carlosmn would be nice.

Comment thread src/transports/smart_pkt.c Outdated
}

return (int)len;
return GIT_ERROR;
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 should set an error message here, perhaps:

giterr_set(GITERR_NET, "unexpected pack file");
return -1;

(We usually do return -1 instead of return GIT_ERROR out of convention. I'd like to keep that moving forward.)

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jul 13, 2018

Looks good to me. @ethomson, any further comments on this?

Copy link
Copy Markdown
Member

@carlosmn carlosmn left a comment

Choose a reason for hiding this comment

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

Looks fine other than the place-holder value.

Comment thread src/transports/smart.h Outdated
GIT_PKT_ACK,
GIT_PKT_NAK,
GIT_PKT_PACK,
GIT_PKT_PACK__UNUSED,
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.

This is a private struct, we don't need place-holders for deleted values.

@nelhage
Copy link
Copy Markdown
Contributor Author

nelhage commented Jul 16, 2018

@carlosmn Thanks, removed the placeholder.

@pks-t pks-t merged commit fa401a3 into libgit2:master Jul 19, 2018
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jul 19, 2018

Thanks @nelhage!

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.

4 participants