]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
sendf: fix CRLF conversion of input
authorStefan Eissing <stefan@eissing.org>
Fri, 12 Jul 2024 12:07:29 +0000 (14:07 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 15 Jul 2024 21:47:33 +0000 (23:47 +0200)
When CRLF line end conversion was enabled (--crlf), input after the last
newline in the upload buffer was not sent, if the buffer contained a
newline.

Reported-by: vuonganh1993 on github
Fixes #14165
Closes #14169

lib/sendf.c
tests/data/test941
tests/runtests.pl
tests/testutil.pm

index c80ffc640e1e4275bc2bbd9a9aeec4efc44ee81c..24b90d2ad044886d8052e30ab2865b258534888b 100644 (file)
@@ -1025,6 +1025,12 @@ static CURLcode cr_lc_read(struct Curl_easy *data,
          * the content length after having started the request... */
       }
     }
+
+    if(start < i) { /* leftover */
+      result = Curl_bufq_cwrite(&ctx->buf, buf + start, i - start, &n);
+      if(result)
+        return result;
+    }
   }
 
   DEBUGASSERT(!Curl_bufq_is_empty(&ctx->buf));
index 7c87f50280c356221fc21c6f421a55a506b712fe..79f88a67409f47af5364bd0f04d80fe5336711b7 100644 (file)
@@ -32,6 +32,7 @@ converted
 with
 the
 --crlf option
+%repeat[650 x 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789%0a]%
 </file>
 <command>
 smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -T %LOGDIR/upload%TESTNUMBER --crlf
@@ -60,6 +61,7 @@ converted
 with\r
 the\r
 --crlf option\r
+%repeat[650 x 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\r%0a]%\r
 .\r
 </upload>
 </verify>
index 059c8405799ed4109f1df8bc791e39bfbb006d20..f8144798205864bd8352e5f683a49b86e3451646 100755 (executable)
@@ -1460,6 +1460,9 @@ sub singletest_check {
             # cut off the final newline from the final line of the upload data
             chomp($upload[-1]);
         }
+        for my $line (@upload) {
+            subbase64(\$line);
+        }
 
         # verify uploaded data
         my @out = loadarray("$logdir/upload.$testnum");
index 1a44083e1bf24bb579b972ab084aeb922310e9e8..36bbe513cd10972362b38110d0aac6c93b4ee7f5 100644 (file)
@@ -127,6 +127,7 @@ sub subbase64 {
         # decode %NN characters
         my ($d, $n) = ($2, $1);
         $d =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+        $n =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
         my $all = $d x $n;
         $$thing =~ s/%%REPEAT%%/$all/;
     }