summaryrefslogtreecommitdiff
path: root/lib/ftp.c
Commit message (Collapse)AuthorAgeFilesLines
* checksrc: find bad indentation in conditions without open braceDaniel Stenberg2023-04-281-1/+1
| | | | | | | | | | | If the previous line starts with if/while/for AND ends with a closed parenthesis and there's an equal number of open and closed parentheses on that line, verify that this line is indented $indent more steps, if not a cpp line. Also adjust the fall-out from this fix. Closes #11054
* checksrc: fix SPACEBEFOREPAREN for conditions starting with "*"Daniel Stenberg2023-04-271-1/+1
| | | | | | | | | | | | | | | The open paren check wants to warn for spaces before open parenthesis for if/while/for but also for any function call. In order to avoid catching function pointer declarations, the logic allows a space if the first character after the open parenthesis is an asterisk. I also spotted what we did not include "switch" in the check but we should. This check is a little lame, but we reduce this problem by not allowing that space for if/while/for/switch. Reported-by: Emanuele Torre Closes #11044
* lib: unify the upload/method handlingDaniel Stenberg2023-04-251-4/+4
| | | | | | | | By making sure we set state.upload based on the set.method value and not independently as set.upload, we reduce confusion and mixup risks, both internally and externally. Closes #11017
* ftp: fix 'portsock' variable was assigned the same valueDaniel Stenberg2023-04-131-2/+0
| | | | | | | Pointed out by PVS Ref: #10929 Closes #10955
* ftp: remove dead codeDaniel Stenberg2023-04-131-8/+2
| | | | | | | | | | This condition can never be true here since it is handled already 28 lines above. Pointed out by PVS. Ref: #10929 Closes #10957
* multi: remove PENDING + MSGSENT handles from the main linked listDaniel Stenberg2023-03-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | As they are not driving transfers or any socket activity, the main loop does not need to iterate over these handles. A performance improvement. They are instead only held in their own separate lists. 'data->multi' is kept a pointer to the multi handle as long as the easy handle is actually part of it even when the handle is moved to the pending/msgsent lists. It needs to know which multi handle it belongs to, if for example curl_easy_cleanup() is called before the handle is removed from the multi handle. Alll 'data->multi' pointers of handles still part of the multi handle gets cleared by curl_multi_cleanup() which "orphans" all previously attached easy handles. This is take 2. The first version was reverted for the 8.0.1 release. Assisted-by: Stefan Eissing Closes #10801
* ftp: add more conditions for connection reuseDaniel Stenberg2023-03-131-2/+26
| | | | | Reported-by: Harry Sintonen Closes #10730
* ftp: make the 'ftpauth' a more normal 'char *'-arrayDaniel Stenberg2023-03-081-1/+1
| | | | Closes #10703
* ftp: active mode with SSL, add the damn filterStefan Eissing2023-03-071-0/+6
| | | | | | | | | | - since 7.87.0 we lost adding the SSL filter for an active FTP connection that uses SSL. This leads to hangers and timeouts as reported in #10666. Reported-by: SandakovMM on github Fixes #10666 Closes #10669
* ftp: allocate the wildcard struct on demandDaniel Stenberg2023-03-031-9/+9
| | | | | | | | | | The feature is rarely used so this frees up data for the vast majority of easy handles that don't use it. Rename "protdata" to "ftpwc" since it is always an FTP wildcard struct pointer. Made the state struct field an unsigned char to save space. Closes #10639
* setopt: move the CURLOPT_CHUNK_DATA pointer to the set structDaniel Stenberg2023-02-281-3/+3
| | | | | | To make duphandle work etc Closes #10635
* ftp: replace sscanf for MDTM 213 response parsingDaniel Stenberg2023-02-241-2/+26
| | | | Closes #10590
* ftp: replace sscanf for PASV parsingDaniel Stenberg2023-02-241-8/+27
| | | | Closes #10590
* ftp: make the EPSV response parser not use sscanfDaniel Stenberg2023-02-241-20/+11
| | | | Closes #10590
* lib: fix typosSergey Bronnikov2023-01-171-2/+2
| | | | Closes https://github.com/curl/curl/pull/10307
* misc: reduce struct and struct field sizesDaniel Stenberg2023-01-041-5/+3
| | | | | | | | | | | | - by using BIT() instead of bool - imap: shrink struct - ftp: make state 'unsigned char' - ftp: sort ftp_conn struct entries on size - urldata: use smaller fields for SSL version info storage - pop3: reduce the pop3_conn struct size - smtp: reduce the size of the smtp structs Closes #10186
* cf-socket: keep sockaddr local in the socket filtersStefan Eissing2023-01-031-2/+2
| | | | | | | | | | | | | - copy `struct Curl_addrinfo` on filter setup into context - remove `struct Curl_addrinfoi *` with `struct Curl_sockaddr_ex *` in connectdata that is set and NULLed by the socket filter - this means we have no reference to the resolver info in connectdata or its filters - trigger the CF_CTRL_CONN_INFO_UPDATE event when the complete filter chain reaches connected status - update easy handle connection information on CF_CTRL_DATA_SETUP event. Closes #10213
* copyright: update all copyright lines and remove year rangesDaniel Stenberg2023-01-031-1/+1
| | | | | | | | | | | | - they are mostly pointless in all major jurisdictions - many big corporations and projects already don't use them - saves us from pointless churn - git keeps history for us - the year range is kept in COPYING checksrc is updated to allow non-year using copyright statements Closes #10205
* lib: connect/h2/h3 refactorStefan Eissing2022-12-301-25/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactoring of connection setup and happy eyeballing. Move nghttp2. ngtcp2, quiche and msh3 into connection filters. - eyeballing cfilter that uses sub-filters for performing parallel connects - socket cfilter for all transport types, including QUIC - QUIC implementations in cfilter, can now participate in eyeballing - connection setup is more dynamic in order to adapt to what filter did really connect. Relevant to see if a SSL filter needs to be added or if SSL has already been provided - HTTP/3 test cases similar to HTTP/2 - multiuse of parallel transfers for HTTP/3, tested for ngtcp2 and quiche - Fix for data attach/detach in VTLS filters that could lead to crashes during parallel transfers. - Eliminating setup() methods in cfilters, no longer needed. - Improving Curl_conn_is_alive() to replace Curl_connalive() and integrated ssl alive checks into cfilter. - Adding CF_CNTRL_CONN_INFO_UPDATE to tell filters to update connection into and persist it at the easy handle. - Several more cfilter related cleanups and moves: - stream_weigth and dependency info is now wrapped in struct Curl_data_priority - Curl_data_priority members depend is available in HTTP2|HTTP3 - Curl_data_priority members depend on NGHTTP2 support - handling init/reset/cleanup of priority part of url.c - data->state.priority same struct, but shallow copy for compares only - PROTOPT_STREAM has been removed - Curl_conn_is_mulitplex() now available to check on capability - Adding query method to connection filters. - ngtcp2+quiche: implementing query for max concurrent transfers. - Adding is_alive and keep_alive cfilter methods. Adding DATA_SETUP event. - setting keepalive timestamp on connect - DATA_SETUP is called after the connection has been completely setup (but may not connected yet) to allow filters to initialize data members they use. - there is no socket to be had with msh3, it is unclear how select shall work - manual test via "curl --http3 https://curl.se" fail with "empty reply from server". - Various socket/conn related cleanups: - Curl_socket is now Curl_socket_open and in cf-socket.c - Curl_closesocket is now Curl_socket_close and in cf-socket.c - Curl_ssl_use has been replaced with Cur_conn_is_ssl - Curl_conn_tcp_accepted_set has been split into Curl_conn_tcp_listen_set and Curl_conn_tcp_accepted_set with a clearer purpose Closes #10141
* misc: fix grammar and spellingJohn Bampton2022-12-221-2/+2
| | | | Closes #10137
* tls: backends use connection filters for IO, enabling HTTPS-proxyStefan Eissing2022-11-281-1/+1
| | | | | | | | | | | | | | | | | | - OpenSSL (and compatible) - BearSSL - gnutls - mbedtls - rustls - schannel - secure-transport - wolfSSL (v5.0.0 and newer) This leaves only the following without HTTPS-proxy support: - gskit - nss - wolfSSL (versions earlier than v5.0.0) Closes #9962
* ftp: support growing files with CURLOPT_IGNORE_CONTENT_LENGTHfractal-access2022-11-261-0/+1
| | | | | | | | | | | | | | | When using the option CURLOPT_IGNORE_CONTENT_LENGTH (set.ignorecl in code) to support growing files in FTP, the code should ignore the initial size it gets from the server as this will not be the final size of the file. This is done in ftp_state_quote() to prevent a size request being issued in the initial sequence. However, in a later call to ftp_state_get_resp() the code attempts to get the size of the content again if it doesn't already have it, by parsing the response from the RETR request. This fix prevents this parsing of the response to get the size when the set.ignorecl option is set. This should maintain the size value as -1, unknown, in this situation. Closes #9772
* cfilter: re-add `conn` as parameter to cfilter setup methodsStefan Eissing2022-11-261-4/+5
| | | | | | | | | | | - `Curl_ssl_get_config()` now returns the first config if no SSL proxy filter is active - socket filter starts connection only on first invocation of its connect method Fixes #9982 Closes #9983
* netware: remove leftover tracesDaniel Gustafsson2022-11-231-5/+0
| | | | | | | | | Commit 3b16575ae938dec2a29454631a12aa52b6ab9c67 removed support for building on Novell Netware, but a few leftover traces remained. This removes the last bits. Closes: #9966 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
* vtls: localization of state data in filtersStefan Eissing2022-11-221-22/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - almost all backend calls pass the Curl_cfilter intance instead of connectdata+sockindex - ssl_connect_data is remove from struct connectdata and made internal to vtls - ssl_connect_data is allocated in the added filter, kept at cf->ctx - added function to let a ssl filter access its ssl_primary_config and ssl_config_data this selects the propert subfields in conn and data, for filters added as plain or proxy - adjusted all backends to use the changed api - adjusted all backends to access config data via the exposed functions, no longer using conn or data directly cfilter renames for clear purpose: - methods `Curl_conn_*(data, conn, sockindex)` work on the complete filter chain at `sockindex` and connection `conn`. - methods `Curl_cf_*(cf, ...)` work on a specific Curl_cfilter instance. - methods `Curl_conn_cf()` work on/with filter instances at a connection. - rebased and resolved some naming conflicts - hostname validation (und session lookup) on SECONDARY use the same name as on FIRST (again). new debug macros and removing connectdata from function signatures where not needed. adapting schannel for new Curl_read_plain paramter. Closes #9919
* cfiler: filter types have flags indicating what they doStefan Eissing2022-11-221-3/+7
| | | | | | | | | | | | - Adding Curl_conn_is_ip_connected() to check if network connectivity has been reached - having ftp wait for network connectivity before proceeding with transfers. Fixes test failures 1631 and 1632 with hyper. Closes #9952
* ftp: fix "AUTH TLS" on primary conn and for SSL in PASV second connStefan Eissing2022-11-191-1/+9
| | | | | | | Follow-up to dafdb20a26d0c89 Reported-by: Anthony Hu Closes #9948
* lib: parse numbers with fixed known base 10Daniel Stenberg2022-11-171-2/+2
| | | | | | | ... instead of using 0 argument that allows decimal, hex or octal when the number is documented and assumed to use base 10. Closes #9933
* lib: remove bad set.opt_no_body assignmentsDaniel Stenberg2022-11-111-3/+3
| | | | | | | | | | This struct field MUST remain what the application set it to, so that handle reuse and handle duplication work. Instead, the request state bit 'no_body' is introduced for code flows that need to change this in run-time. Closes #9888
* lib: connection filters (cfilter) addition to curl:Stefan Eissing2022-11-111-122/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - general construct/destroy in connectdata - default implementations of callback functions - connect: cfilters for connect and accept - socks: cfilter for socks proxying - http_proxy: cfilter for http proxy tunneling - vtls: cfilters for primary and proxy ssl - change in general handling of data/conn - Curl_cfilter_setup() sets up filter chain based on data settings, if none are installed by the protocol handler setup - Curl_cfilter_connect() boot straps filters into `connected` status, used by handlers and multi to reach further stages - Curl_cfilter_is_connected() to check if a conn is connected, e.g. all filters have done their work - Curl_cfilter_get_select_socks() gets the sockets and READ/WRITE indicators for multi select to work - Curl_cfilter_data_pending() asks filters if the have incoming data pending for recv - Curl_cfilter_recv()/Curl_cfilter_send are the general callbacks installed in conn->recv/conn->send for io handling - Curl_cfilter_attach_data()/Curl_cfilter_detach_data() inform filters and addition/removal of a `data` from their connection - adding vtl functions to prevent use of Curl_ssl globals directly in other parts of the code. Reviewed-by: Daniel Stenberg Closes #9855
* lib: fix some type mismatches and remove unneeded typecastsRose2022-11-081-6/+7
| | | | | | | | | Many of these castings are unneeded if we change the variables to work better with each other. Ref: https://github.com/curl/curl/pull/9823 Closes https://github.com/curl/curl/pull/9835
* style: use space after comment start and before comment endDaniel Stenberg2022-10-301-1/+1
| | | | | | | | | | /* like this */ /*not this*/ checksrc is updated accordingly Closes #9828
* misc: typo and grammar fixesAyesh Karunaratne2022-10-271-1/+1
| | | | | | | | | | - Replace `Github` with `GitHub`. - Replace `windows` with `Windows` - Replace `advice` with `advise` where a verb is used. - A few fixes on removing repeated words. - Replace `a HTTP` with `an HTTP` Closes #9802
* misc: remove duplicated include filesDaniel Stenberg2022-10-261-1/+0
| | | | Closes #9796
* ftp: remove redundant ifDaniel Stenberg2022-10-181-5/+3
| | | | | | Reported-by: Trail of Bits Closes #9753
* ftp: ignore a 550 response to MDTMMichael Heimpold2022-09-071-3/+5
| | | | | | | | | | | | | | | The 550 is overused as a return code for multiple error case, e.g. file not found and/or insufficient permissions to access the file. So we cannot fail hard in this case. Adjust test 511 since we now fail later. Add new test 3027 which check that when MDTM failed, but the file could actually be retrieved, that in this case no filetime is provided. Reported-by: Michael Heimpold Fixes #9357 Closes #9387
* ftp: use a correct expire ID for timer expiryDaniel Stenberg2022-07-201-1/+2
| | | | | | | | This was an accurate error pointed out by the icc warning: enumerated type mixed with another type Ref: #9179 Closes #9184
* ftp: restore protocol state after http proxy CONNECTTom Eccles2022-06-231-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | connect_init() (lib/http_proxy.c) swaps out the protocol state while working on the proxy connection, this is then restored by Curl_connect_done() after the connection completes. ftp_do_more() extracted the protocol state pointer to a local variable at the start of the function then calls Curl_proxy_connect(). If the proxy connection completes, Curl_proxy_connect() will call Curl_connect_done() (via Curl_proxyCONNECT()), which restores data->req.p to point to the ftp protocol state instead of the http proxy protocol state, but the local variable in ftp_do_more still pointed to the old value. Ultimately this meant that the state worked on by ftp_do_more() was the http proxy state not the ftp state initialised by ftp_connect(), but subsequent calls to any ftp_ function would use the original state. For my use-case, the visible consequence was that ftp->downloadsize was never set and so downloaded data was never returned to the application. This commit updates the ftp protocol state pointer in ftp_do_more() after Curl_proxy_connect() returns, ensuring that the correct state pointer is used. Fixes #8737 Closes #9043
* copyright: make repository REUSE compliantmax.mehl2022-06-131-0/+2
| | | | | | | | | | | Add licensing and copyright information for all files in this repository. This either happens in the file itself as a comment header or in the file `.reuse/dep5`. This commit also adds a Github workflow to check pull requests and adapts copyright.pl to the changes. Closes #8869
* ftp: when failing to do a secure GSSAPI login, fail hardDaniel Stenberg2022-06-061-4/+5
| | | | | | | | ... instead of switching to cleartext. For the sake of security. Reported-by: Harry Sintonen Bug: https://hackerone.com/reports/1590102 Closes #8963
* lib: make more protocol specific struct fields #ifdefedDaniel Stenberg2022-06-011-3/+4
| | | | | | | ... so that they don't take up space if the protocols are disabled in the build. Closes #8944
* lib: remove exclamation marksDaniel Stenberg2022-04-161-5/+5
| | | | | | ... from infof() and failf() calls. Make them less attention seeking. Closes #8713
* ftp: fix error message for partial file uploadJay Satiro2022-04-011-1/+1
| | | | | | | | | | | | - Show the count of bytes written on partial file upload. Prior to this change the error message mistakenly showed the count of bytes read, not written. Bug: https://github.com/curl/curl/discussions/8637 Reported-by: Taras Kushnir Closes https://github.com/curl/curl/pull/8649
* ftp: provide error message for control bytes in pathDaniel Stenberg2022-02-171-1/+3
| | | | Closes #8460
* misc: remove unused data when IPv6 is not supportedMAntoniak2022-02-131-1/+4
| | | | Closes #8430
* lib: remove support for CURL_DOES_CONVERSIONSDaniel Stenberg2022-02-041-4/+3
| | | | | | TPF was the only user and support for that was dropped. Closes #8378
* ftp: disable warning 4706 in MSVCDaniel Stenberg2022-01-031-1/+6
| | | | | | | | | Follow-up to 21248e052d Disabling "assignment within conditional expression" for MSVC needs to be done before the function starts, for it to take effect. Closes #8218
* checksrc: detect more kinds of NULL comparisons we avoidDaniel Stenberg2021-12-271-3/+3
| | | | | Co-authored-by: Jay Satiro Closes #8180
* ftp: make the MKD retry to retry once per directoryRoger Young2021-11-081-5/+6
| | | | | | Reported-by: Roger Young Fixes #7967 Closes #7976
* ftp,imap,pop3,smtp: reject STARTTLS server response pipeliningPatrick Monnerat2021-09-131-0/+3
| | | | | | | | | | | | | If a server pipelines future responses within the STARTTLS response, the former are preserved in the pingpong cache across TLS negotiation and used as responses to the encrypted commands. This fix detects pipelined STARTTLS responses and rejects them with an error. CVE-2021-22947 Bug: https://curl.se/docs/CVE-2021-22947.html