Skip to content
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

Invalid end of chunk (parse_chunk_size) #149

Open
caobug opened this issue Oct 19, 2023 · 2 comments
Open

Invalid end of chunk (parse_chunk_size) #149

caobug opened this issue Oct 19, 2023 · 2 comments

Comments

@caobug
Copy link

caobug commented Oct 19, 2023

Hello, the end of the chunk should be ended by two sets of \r\n. but parse_chunk_size considers that one set is enough, which results in the inability to know the completion of message transmission in the TCP stream.

for example:

correct:

let buf = b"0\r\n\r\n";
assert_eq!(httparse::parse_chunk_size(buf), Ok(httparse::Status::Complete((3, 0))));

unexp:

let buf = b"0\r\n";
assert_eq!(httparse::parse_chunk_size(buf), Ok(httparse::Status::Partial));

let buf = b"0\r\n\r";
assert_eq!(httparse::parse_chunk_size(buf), Ok(httparse::Status::Partial));
@seanmonstar
Copy link
Owner

The unexpected ones look correct to me. Those are partial ends.

The top example looks wrong, though. It should be complete, and report that the end is at byte 5, no?

@caobug
Copy link
Author

caobug commented Oct 20, 2023

No. The function parse_chunk_size reads \r, then \n, then breaks and returns Complete.

Therefore correct only reads 3 bytes. The unexpected below will always read only the first 3 bytes.

https://github.com/seanmonstar/httparse/blob/a3c10fd3281d3b70becc1aa54a995b617f502045/src/lib.rs#L1300C36-L1300C36

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

No branches or pull requests

2 participants