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
This commit is contained in:
Daniel Stenberg 2026-04-04 18:10:31 +02:00
parent ec22ea2502
commit 2e5d219205
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -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;