From: Stefan Eissing Date: Wed, 28 Aug 2024 10:54:29 +0000 (+0200) Subject: urldata: remove crlf_conversions counter X-Git-Tag: curl-8_10_0~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64ab0ace274070a3bc39ef40f6e3671bf5d8ef1e;p=thirdparty%2Fcurl.git urldata: remove crlf_conversions counter 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 --- diff --git a/lib/ftp.c b/lib/ftp.c index 5406175bba..38bb4ef4cc 100644 --- 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); diff --git a/lib/transfer.c b/lib/transfer.c index 4c1cba1d21..e1923e4e13 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -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; diff --git a/lib/url.c b/lib/url.c index 276715509e..88d3ecc9d3 100644 --- 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(); diff --git a/lib/urldata.h b/lib/urldata.h index 7182f3edc4..04e03ae9a5 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -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 */