]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urldata: remove crlf_conversions counter
authorStefan Eissing <stefan@eissing.org>
Wed, 28 Aug 2024 10:54:29 +0000 (12:54 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 29 Aug 2024 12:30:58 +0000 (14:30 +0200)
Since the introduction of client writers, we check the body length in
the PROTOCOL phase and do FTP lineend conversions laster in the
CONTENT_DECODING phase. This means we no longer need to count the
conversions for length checks.

Closes #14709

lib/ftp.c
lib/transfer.c
lib/url.c
lib/urldata.h

index 5406175bbaf7d54c3fffa4c8602c2724a0bad265..38bb4ef4cc5154dab2655c6a04b725e839f701dd 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -369,7 +369,6 @@ static CURLcode ftp_cw_lc_write(struct Curl_easy *data,
       }
       /* either we just wrote the newline or it is part of the next
        * chunk of bytes we write. */
-      data->state.crlf_conversions++;
       ctx->newline_pending = FALSE;
     }
 
@@ -400,7 +399,6 @@ static CURLcode ftp_cw_lc_write(struct Curl_easy *data,
     /* EndOfStream, if we have a trailing cr, now is the time to write it */
     if(ctx->newline_pending) {
       ctx->newline_pending = FALSE;
-      data->state.crlf_conversions++;
       return Curl_cwriter_write(data, writer->next, type, &nl, 1);
     }
     /* Always pass on the EOS type indicator */
@@ -3547,14 +3545,6 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
   else {
     if((-1 != data->req.size) &&
        (data->req.size != data->req.bytecount) &&
-#ifdef CURL_DO_LINEEND_CONV
-       /* Most FTP servers do not adjust their file SIZE response for CRLFs,
-        * so we will check to see if the discrepancy can be explained by the
-        * number of CRLFs we have changed to LFs.
-        */
-       ((data->req.size + data->state.crlf_conversions) !=
-        data->req.bytecount) &&
-#endif /* CURL_DO_LINEEND_CONV */
        (data->req.maxdownload != data->req.bytecount)) {
       failf(data, "Received only partial file: %" CURL_FORMAT_CURL_OFF_T
             " bytes", data->req.bytecount);
index 4c1cba1d21cd5bfdeb4abff548ddbc384978c192..e1923e4e13e10d7a844effeb161ebaaf48d5d428 100644 (file)
@@ -518,15 +518,7 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp)
      * returning.
      */
     if(!(data->req.no_body) && (k->size != -1) &&
-       (k->bytecount != k->size) &&
-#ifdef CURL_DO_LINEEND_CONV
-       /* Most FTP servers do not adjust their file SIZE response for CRLFs,
-          so we will check to see if the discrepancy can be explained
-          by the number of CRLFs we have changed to LFs.
-       */
-       (k->bytecount != (k->size + data->state.crlf_conversions)) &&
-#endif /* CURL_DO_LINEEND_CONV */
-       !k->newurl) {
+       (k->bytecount != k->size) && !k->newurl) {
       failf(data, "transfer closed with %" CURL_FORMAT_CURL_OFF_T
             " bytes remaining to read", k->size - k->bytecount);
       result = CURLE_PARTIAL_FILE;
index 276715509e8f5b519cdb66de0049631fec782db6..88d3ecc9d31686a2501c645d575ff203fbaaafb7 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -3671,10 +3671,6 @@ CURLcode Curl_setup_conn(struct Curl_easy *data,
     return result;
   }
 
-#ifdef CURL_DO_LINEEND_CONV
-  data->state.crlf_conversions = 0; /* reset CRLF conversion counter */
-#endif /* CURL_DO_LINEEND_CONV */
-
   /* set start time here for timeout purposes in the connect procedure, it
      is later set again for the progress meter purpose */
   conn->now = Curl_now();
index 7182f3edc4287c82b44a4fbe73c3bace2ac7fea7..04e03ae9a574b1cc363645dd0727e3cccd87c7b6 100644 (file)
@@ -105,6 +105,11 @@ typedef unsigned int curl_prot_t;
 #define CURL_DEFAULT_USER "anonymous"
 #define CURL_DEFAULT_PASSWORD "ftp@example.com"
 
+#if !defined(_WIN32) && !defined(MSDOS) && !defined(__EMX__)
+/* do FTP line-end conversions on most platforms */
+#define CURL_DO_LINEEND_CONV
+#endif
+
 /* Convenience defines for checking protocols or their SSL based version. Each
    protocol handler should only ever have a single CURLPROTO_ in its protocol
    field. */
@@ -1268,12 +1273,6 @@ struct UrlState {
 
   /* a place to store the most recently set (S)FTP entrypath */
   char *most_recent_ftp_entrypath;
-#if !defined(_WIN32) && !defined(MSDOS) && !defined(__EMX__)
-/* do FTP line-end conversions on most platforms */
-#define CURL_DO_LINEEND_CONV
-  /* for FTP downloads: how many CRLFs did we converted to LFs? */
-  curl_off_t crlf_conversions;
-#endif
   char *range; /* range, if used. See README for detailed specification on
                   this syntax. */
   curl_off_t resume_from; /* continue [ftp] transfer from here */