From 2e5d219205ebec64a66bfd29bba73dd5049c434f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 4 Apr 2026 18:10:31 +0200 Subject: [PATCH] sendf: fix CR detection if no LF is in the chunk 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 #21221 --- lib/sendf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sendf.c b/lib/sendf.c index ab67da26ca..74e7038a7f 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -1009,6 +1009,8 @@ static CURLcode cr_lc_read(struct Curl_easy *data, if(!nread || !memchr(buf, '\n', nread)) { /* nothing to convert, return this right away */ + if(nread) + ctx->prev_cr = (buf[nread - 1] == '\r'); if(ctx->read_eos) ctx->eos = TRUE; *pnread = nread;