-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Remove GIT_PKT_PACK entirely #4704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This seems reasonable to me, but getting 👀 on it by @carlosmn would be nice. |
src/transports/smart_pkt.c
Outdated
} | ||
|
||
return (int)len; | ||
return GIT_ERROR; |
There was a problem hiding this comment.
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.)
Looks good to me. @ethomson, any further comments on this? |
There was a problem hiding this 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.
src/transports/smart.h
Outdated
@@ -40,7 +40,7 @@ typedef enum { | |||
GIT_PKT_HAVE, | |||
GIT_PKT_ACK, | |||
GIT_PKT_NAK, | |||
GIT_PKT_PACK, | |||
GIT_PKT_PACK__UNUSED, |
There was a problem hiding this comment.
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.
@carlosmn Thanks, removed the placeholder. |
Thanks @nelhage! |
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 advanceout
, any client is required to check forGIT_PKT_PACK
and bail out, or else go into an infinite loop callinggit_pkt_parse_line
to get a new packet, which will from that point forward always return aGIT_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.