Skip to content

sendf: fix CR detection if no LF is in the chunk#21221

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/crlf-conversion-fix
Closed

sendf: fix CR detection if no LF is in the chunk#21221
bagder wants to merge 1 commit intomasterfrom
bagder/crlf-conversion-fix

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Apr 4, 2026

When doing line ending conversions, and a chunk contains no '\n', the function returned early without updating prev_cr to reflect the last byte. It could then lead to CRLFs sequences not get converted when occuring right on the boundary border.

Found by Codex Security

When doing line ending conversions, and a chunk contains no '\n', the
function returned early without updating prev_cr to reflect the last
byte. It could then lead to CRLFs sequences not get converted when
occuring right on the boundary border.

Found by Codex Security
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a boundary-condition bug in the client-side line-ending conversion reader (cr_lc_read) where prev_cr was not updated when a read chunk contained no \n, which could prevent correct CRLF handling across read boundaries.

Changes:

  • Update ctx->prev_cr based on the last byte of the chunk in the “no \n found” fast path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder marked this pull request as ready for review April 4, 2026 16:26
@testclutch
Copy link
Copy Markdown

Analysis of PR #21221 at eb61b214:

Test 2089 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 12 different CI jobs (the link just goes to one of them). Note that this CI job has had a number of other flaky tests recently (3, to be exact) so it may be that this failure is rather a systemic issue with this job and not with this specific PR.

Generated by Testclutch

@bagder bagder closed this in 2e5d219 Apr 4, 2026
@bagder bagder deleted the bagder/crlf-conversion-fix branch April 4, 2026 20:33
dkarpov1970 pushed a commit to dkarpov1970/curl that referenced this pull request Apr 7, 2026
When doing line ending conversions, and a chunk contains no '\n', the
function returned early without updating prev_cr to reflect the last
byte. It could then lead to CRLFs sequences not get converted when
occuring right on the boundary border.

Found by Codex Security

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants