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

codec: fix incorrect handling of invalid utf-8 in LinesCodec::decode_eof #7011

Merged

Conversation

Zettroke
Copy link
Contributor

@Zettroke Zettroke commented Dec 4, 2024

Motivation

LinesCodec is not resetting internal state in decode_eof in case there is utf8 decoding error.
This causes the following panic in subsequent decode calls: slice index starts at 8 but ends at 0

Solution

Reset next_index at the start of decode_eof.

@Darksonn Darksonn added A-tokio-util Area: The tokio-util crate M-codec Module: tokio-util/codec labels Dec 4, 2024
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks.

@Darksonn Darksonn changed the title fix: LinesCodec panic when handling invalid utf-8 input codec: fix incorrect handling of invalid utf-8 in LinesCodec::decode_eof Dec 4, 2024
@Darksonn Darksonn enabled auto-merge (squash) December 4, 2024 10:17
@Darksonn Darksonn merged commit 129f9fc into tokio-rs:master Dec 4, 2024
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate M-codec Module: tokio-util/codec
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants