]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
sendf: fix CR detection if no LF is in the chunk
authorDaniel Stenberg <daniel@haxx.se>
Sat, 4 Apr 2026 16:10:31 +0000 (18:10 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 4 Apr 2026 20:32:54 +0000 (22:32 +0200)
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

index ab67da26ca82b37e6019c646e56e5a825c36300e..74e7038a7fa674462ae8078b8f223c436ca76bf4 100644 (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;