← Commit list

ba8f8a7f27

Daniel Stenberg
Daniel Stenberg
2026-09-17
SUCCESS Duration: 422s

Subject

ftplistparser: no more overwriting set.write_func

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/cw-out.c+8 -2
@@ -142,8 +142,14 @@ static void cw_get_writefunc(struct Curl_easy *data, cw_out_type otype,
switch(otype) {
case CW_OUT_BODY:
case CW_OUT_BODY_0LEN:
- *pwcb = data->set.fwrite_func;
- *pwcb_data = data->set.out;
+ if(Curl_ftp_listmode(data)) {
+ *pwcb = Curl_ftp_parselist;
+ *pwcb_data = data;
+ }
+ else {
+ *pwcb = data->set.fwrite_func;
+ *pwcb_data = data->set.out;
+ }
*pmax_write = CURL_MAX_WRITE_SIZE;
/* if we ever want buffering of BODY output, we can set `min_write`
* the preferred size. The default should always be to pass data
lib/ftp-int.h+0 -5
@@ -79,11 +79,6 @@ struct ftp_parselist_data; /* defined later in ftplistparser.c */
struct ftp_wc {
struct ftp_parselist_data *parser;
-
- struct {
- curl_write_callback write_function;
- FILE *file_descriptor;
- } backup;
};
/* This FTP struct is used in the Curl_easy. All FTP data that is
lib/ftp.c+0 -13
@@ -4016,15 +4016,6 @@ static CURLcode init_wc_data(struct Curl_easy *data,
goto fail;
}
- /* backup old write_function */
- ftpwc->backup.write_function = data->set.fwrite_func;
- /* parsing write function */
- data->set.fwrite_func = Curl_ftp_parselist;
- /* backup old file descriptor */
- ftpwc->backup.file_descriptor = data->set.out;
- /* let the writefunc callback know the transfer */
- data->set.out = data;
-
infof(data, "Wildcard - Parsing started");
return CURLE_OK;
@@ -4060,10 +4051,6 @@ static CURLcode wc_statemach(struct Curl_easy *data,
/* In this state is LIST response successfully parsed, so lets restore
previous WRITEFUNCTION callback and WRITEDATA pointer */
struct ftp_wc *ftpwc = wildcard->ftpwc;
- data->set.fwrite_func = ftpwc->backup.write_function;
- data->set.out = ftpwc->backup.file_descriptor;
- ftpwc->backup.write_function = ZERO_NULL;
- ftpwc->backup.file_descriptor = NULL;
wildcard->state = CURLWC_DOWNLOADING;
if(Curl_ftp_parselist_geterror(ftpwc->parser)) {
lib/ftplistparser.c+10 -0
@@ -1012,6 +1012,16 @@ static CURLcode parse_winnt(struct Curl_easy *data,
return CURLE_OK;
}
+/* returns TRUE if in wildcard listing mode */
+bool Curl_ftp_listmode(struct Curl_easy *data)
+{
+ if(data->state.wildcardmatch) {
+ struct WildcardData * const wildcard = data->wildcard;
+ return wildcard && (wildcard->state <= CURLWC_MATCHING);
+ }
+ return FALSE;
+}
+
size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
void *connptr)
{
lib/ftplistparser.h+5 -0
@@ -27,6 +27,9 @@
#ifndef CURL_DISABLE_FTP
+/* returns TRUE if in wildcard listing mode */
+bool Curl_ftp_listmode(struct Curl_easy *data);
+
/* WRITEFUNCTION callback for parsing LIST responses */
size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
void *connptr);
@@ -71,6 +74,8 @@ void Curl_wildcard_dtor(struct WildcardData **wcp);
struct Curl_easy;
#else /* CURL_DISABLE_FTP */
+#define Curl_ftp_listmode(x) FALSE
+#define Curl_ftp_parselist ZERO_NULL
#define Curl_wildcard_dtor(x)
#endif /* !CURL_DISABLE_FTP */