1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00
Commit Graph

822 Commits

Author SHA1 Message Date
Kamil Dudka
0c8e5f7e6a ftp: prevent server from hanging on closed data connection
Some FTP servers (e.g. Pure-ftpd) end up hanging if we close the data
connection before transferring all the requested data.  If we send ABOR
in that case, it prevents the server from hanging.

Bug: https://bugzilla.redhat.com/643656
Reported by: Pasi Karkkainen, Patrick Monnerat
2010-10-29 12:01:19 +02:00
Dan Fandrich
59f07ddf28 Lightened the stack in wc_statemach to permit deeper recursion
Also, added a few hints to help compilers to perform tail call
recursion optimization.
2010-10-20 18:27:56 -07:00
Julien Chaffraix
4b69f641a6 krb5-gssapi: Delete the GSS-API context.
This fixes a memory leak related to the GSS-API code.

Added a krb5_init and krb5_end functions. Also removed a work-around
the lack of proper initialization of the GSS-API context.
2010-10-02 10:00:42 -07:00
Julien Chaffraix
e3811ed7c3 security.c: Remove Curl_sec_fflush_fd.
The current implementation would make us send wrong data on a closed
socket. We don't buffer our data so the method can be safely removed.
2010-09-28 22:05:24 -07:00
Julien Chaffraix
fc9f369829 security.c: Fix Curl_sec_login after rewrite.
Curl_sec_login was returning the opposite result that the code in ftp.c
was expecting. Simplified the return code (using a CURLcode) so to see
more clearly what is going on.
2010-09-28 22:05:24 -07:00
Daniel Stenberg
8a00c94b0f FTP: fix bad check of Curl_timeleft() return code
When it returns 0 it means no timeout. Only a negative value means that
we're out of time.
2010-09-18 23:08:32 +02:00
Daniel Stenberg
dc2157a087 parse_remote_port: fix ;type= URL suffix over HTTP proxy
Test 563 is enabled now and verifies that the combo FTP type=A URL,
CURLOPT_PORT set and proxy work fine. As a bonus I managed to remove the
somewhat odd FTP check in parse_remote_port() and instead converted it
to a better and more generic 'slash_removed' struct field. Checking the
->protocol field isn't right since when an FTP:// URL is sent over a
HTTP proxy, the protocol is HTTP but the URL was handled by the FTP code
and thus slash_removed is set TRUE for this case.
2010-08-10 00:56:45 +02:00
Jan Van Boghout
4a1384a8b4 ftp: response timeout bug in "quote" sending
The FTP implementation was missing a timestamp reset point, making the
waiting for responses after sending a post-transfer "QUOTE" command not
working as supposedly. This bug was introduced in 7.20.0
2010-07-18 00:44:25 +02:00
Pavel Raiskup
0a04078916 ftp-wildcard: avoid tight loop when used without any pattern
It was broken for URLs like "ftp://example.com/".
2010-06-24 10:18:17 +02:00
Dan Fandrich
bd6a695545 Fixed an OOM memory leak in the FTP wildcard code 2010-06-17 10:56:25 -07:00
Yang Tse
6a0d3233ff add Curl_ prefix to conform with cURL naming standards 2010-06-09 15:45:46 +02:00
Yang Tse
b4fa27ae4b fix compiler warning: enumerated type mixed with another type 2010-05-31 17:11:51 +02:00
Yang Tse
40f8aaedb7 fix compiler warning: external declaration in primary source file 2010-05-31 16:24:01 +02:00
Kamil Dudka
233ec511db lib: eliminate 'statement not reached' warnings 2010-05-28 09:45:17 +02:00
Pavel Raiskup
0825cd80a6 FTP: WILDCARDMATCH/CHUNKING/FNMATCH added 2010-05-12 23:17:51 +02:00
Daniel Stenberg
d6be52d80e FTP PORT: Value stored to 'rc' is never read 2010-04-16 23:45:05 +02:00
Daniel Stenberg
c0111460b0 Curl_setup_transfer: no longer returns anything
This function could only return CURLE_OK and by changing it to
a void instead, we can simplify code all over.
2010-04-16 23:43:04 +02:00
Daniel Stenberg
93981bb9b5 PASV response: Value stored to 'rc' is never read 2010-04-16 23:28:20 +02:00
Daniel Stenberg
b025ac16a6 ftp_range: remove unnecessary check for NULL pointer 2010-04-16 23:20:07 +02:00
Daniel Stenberg
516dfd1705 FTP PASV: Value stored to 'rc' is never read 2010-04-16 23:02:15 +02:00
Daniel Stenberg
743bd81e64 ftp_range: Value stored to 'totalsize' is never read
Simplified the code by removing a local variable completely.
2010-04-16 23:00:21 +02:00
Daniel Stenberg
02892e4fd8 FTP quote commands prefixed with '*' now can fail without aborting
Prefixing the FTP quote commands with an asterisk really only
worked for the postquote actions. This is now fixed and test case
227 has been extended to verify.
2010-04-09 16:54:52 +02:00
Daniel Stenberg
2309b4e330 remove the CVSish $Id$ lines 2010-03-24 11:02:54 +01:00
Yang Tse
749fd2f9e9 another shot at the ftp_init() icc 9.1 optimizer issue 2010-03-18 17:37:00 +00:00
Daniel Stenberg
13ac29382f - Made the pingpong timeout code properly deal with the response timeout AND
the global timeout if set. Also, as was reported in the bug report #2956437
  by Ryan Chan, the time stamp to use as basis for the per command timeout was
  not set properly in the DONE phase for FTP (and not for SMTP) so I fixed
  that just now. This was a regression compared to 7.19.7 due to the
  conversion of FTP code over to the generic pingpong concepts.

  http://curl.haxx.se/bug/view.cgi?id=2956437
2010-03-02 13:26:23 +00:00
Yang Tse
5695c4db86 fix compiler warning 2010-02-24 00:03:06 +00:00
Yang Tse
bc7615ae2d - attempt to workaround icc 9.1 optimizer issue 2010-02-05 09:32:11 +00:00
Yang Tse
7aef172a34 fix printf-style format strings 2010-02-04 19:44:31 +00:00
Yang Tse
d1717e7c90 Fix compiler warning: conditional expression is constant 2010-02-02 16:25:07 +00:00
Daniel Stenberg
17a2c32ca9 Julien Chaffraix pointed out a comment mistake, and I re-indented the code
slightly while editing
2010-02-02 08:48:58 +00:00
Yang Tse
4ee4e66c4f fix errno usage for WIN32 builds 2010-01-29 16:38:43 +00:00
Yang Tse
340ab2f87f make Curl_handler_*_proxy definition static 2010-01-25 23:41:02 +00:00
Daniel Stenberg
33ce0ec1f1 wrap long lines and do some indent policing 2010-01-22 23:21:39 +00:00
Daniel Stenberg
a5ca3f1754 - David McCreedy brought a fix and a new test case (129) to make libcurl work
again when downloading files over FTP using ASCII and it turns out that the
  final size of the file is not the same as the initial size the server
  reported. This is very common since servers don't take the newline
  conversions into account.
2010-01-19 21:39:10 +00:00
Daniel Stenberg
a62f32d3c2 update copyright year since we are in 2010 now 2010-01-01 14:52:50 +00:00
Daniel Stenberg
605bbfc4c0 - Ingmar Runge enhanced libcurl's FTP engine to support the PRET command. This
command is a special "hack" used by the drftpd server, but even though it is
  a custom extension I've deemed it fine to add to libcurl since this server
  seems to survive and people keep using it and want libcurl to support
  it. The new libcurl option is named CURLOPT_FTP_USE_PRET, and it is also
  usable from the curl tool with --ftp-pret. Using this option on a server
  that doesn't support this command will make libcurl fail.
2010-01-01 14:44:44 +00:00
Yang Tse
3184a91ec8 VMS specific preprocessor symbol checking adjustments 2009-12-30 17:59:56 +00:00
Yang Tse
b0f548fb56 Fix compiler warnings 2009-12-14 14:02:43 +00:00
Daniel Stenberg
ec3bb8f727 introducing IMAP, POP3 and SMTP support (still lots of polish left to do) 2009-12-12 21:54:01 +00:00
Daniel Stenberg
c7d2e4c1e1 - Extended and fixed the change I did on Dec 11 for the the progress
meter/callback during FTP command/response sequences. It turned out it was
   really lame before and now the progress meter SHOULD get called at least
   once per second.
2009-11-26 19:07:54 +00:00
Yang Tse
5129442ee7 Explicit initialization of all FTP struct members in ftp_init() 2009-11-19 17:21:56 +00:00
Yang Tse
59939313f8 Make usage of calloc()'s arguments consistent with rest of code base 2009-11-18 10:33:54 +00:00
Daniel Stenberg
107c4d878a - Christian Schmitz noticed that the progress meter/callback was not properly
used during the FTP connection phase (after the actual TCP connect), while
  it of course should be. I also made the speed check get called correctly so
  that really slow servers will trigger that properly too.
2009-11-11 09:01:43 +00:00
Yang Tse
0c90cb7b83 fix compiler warning: enumerated type mixed with another type 2009-09-17 16:11:54 +00:00
Daniel Stenberg
4e9d3c26ed - When using the multi interface with FTP and you asked for NOBODY, you did no
QUOTE commands and the request used the same path as the connection had
  already changed to, it would decide that no commands would be necessary for
  the "DO" action and that was not handled properly but libcurl would instead
  hang.
2009-08-31 20:49:30 +00:00
Patrick Monnerat
b0b2824b58 - Introduced a SYST-based test to properly set-up name format when dealing with the OS/400 FTP server.
- Fixed an ftp_readresp() bug preventing detection of failing control socket  and causing FTP client to loop forever.
2009-08-24 12:57:25 +00:00
Daniel Stenberg
171eef68c3 - Benbuck Nason posted the bug report #2835196
(http://curl.haxx.se/bug/view.cgi?id=2835196), fixing a few compiler
  warnings when mixing ints and bools.
2009-08-11 20:43:12 +00:00
Dan Fandrich
0dec3e5e6a Fixed a memory leak in the FTP code and an off-by-one heap buffer overflow. 2009-08-11 02:30:53 +00:00
Daniel Stenberg
0684128209 - All the quote options (CURLOPT_QUOTE, CURLOPT_POSTQUOTE and
CURLOPT_PREQUOTE) now accept a preceeding asterisk before the command to
  send when using FTP, as a sign that libcurl shall simply ignore the response
  from the server instead of treating it as an error. Not treating a 400+ FTP
  response code as an error means that failed commands will not abort the
  chain of commands, nor will they cause the connection to get disconnected.
2009-07-27 18:36:56 +00:00
Gunter Knauf
d7f33b7e4e added a cast to silent compiler warning with 64bit systems. 2009-07-16 17:39:14 +00:00
Daniel Stenberg
d709cb2ae3 - Eric Wong introduced curlx_nonblock() that the curl tool now (re-)uses for
setting a file descriptor non-blocking. Used by the functionality Eric
  himself brough on June 15th.
2009-07-09 21:47:24 +00:00
Gunter Knauf
2aaff16a87 added INET_ADDRSTRLEN define in case system headers dont provide. 2009-07-04 11:27:42 +00:00
Gunter Knauf
6236198d43 removed NIFLAGS which is no longer used; added NI_MAXHOST since its missing with some platforms. 2009-07-04 11:06:00 +00:00
Gunter Knauf
83fb285d40 Markus Koetter provided a patch to avoid getnameinfo() usage which broke a couple of both IPv4 and IPv6 autobuilds. 2009-07-04 01:04:23 +00:00
Daniel Stenberg
175fc5096d Tor Arntsen pointed out a missing #ifdef for IPv6, and I changed another one
to use the "standard" ENABLE_IPV6 one. Also, if port number cannot be figured
out to connect to after a name resolve (due to it not being IPv4 or IPv6),
that particular address will now simply be skipped.
2009-06-30 21:30:39 +00:00
Daniel Stenberg
4f551259dd - Markus Koetter made CURLOPT_FTPPORT (and curl's -P/--ftpport) support a port
range if given colon-separated after the host name/address part. Like
  "192.168.0.1:2000-10000"
2009-06-29 20:46:01 +00:00
Yang Tse
2c16681225 Adjusted to take in account that...
With the curl memory tracking feature decoupled from the debug build feature,
CURLDEBUG and DEBUGBUILD preprocessor symbol definitions are used as follows:

CURLDEBUG used for curl debug memory tracking specific code (--enable-curldebug)

DEBUGBUILD used for debug enabled specific code (--enable-debug)
2009-06-10 02:49:42 +00:00
Daniel Stenberg
de7a14003c - Kamil Dudka brought the patch from the Redhat bug entry
https://bugzilla.redhat.com/show_bug.cgi?id=427966 which was libcurl closing
  a bad file descriptor when closing down the FTP data connection.  Caolan
  McNamara seems to be the original author of it.
2009-05-19 20:54:31 +00:00
Daniel Stenberg
80d2df7789 Reverted my change to use Curl_connected_proxy() here. Clearly I wasn't
thinking straight.
2009-05-12 18:56:33 +00:00
Daniel Stenberg
bcdbba05d3 moved variables more locally to get rid of one set of #ifdefs 2009-05-11 12:13:41 +00:00
Daniel Stenberg
51d1f309cd Use Curl_connected_proxy() here instead of duplicating code. Spell out the
badness in the code flow even for the socks case.
2009-05-11 11:49:39 +00:00
Daniel Stenberg
9c788a529b - Made the SO_SNDBUF setting for the data connection socket for ftp uploads as
well. See change 28 Apr 2009.
2009-05-07 20:00:44 +00:00
Yang Tse
9137e717b0 Use build-time configured curl_socklen_t instead of socklen_t 2009-05-02 02:37:32 +00:00
Daniel Stenberg
e01b7c1ede - Bug report #2709004 (http://curl.haxx.se/bug/view.cgi?id=2709004) by Tim
Chen pointed out how curl couldn't upload with resume when reading from a
  pipe.

  This ended up with the introduction of a new return code for the
  CURLOPT_SEEKFUNCTION callback that basically says that the seek failed but
  that libcurl may try to resolve the situation anyway. In our case this means
  libcurl will attempt to instead read that much data from the stream instead
  of seeking and that way curl can now upload with resume when data is read
  from a stream!
2009-04-28 11:19:10 +00:00
Yang Tse
33a3753c3f libcurl's memory.h renamed to curl_memory.h 2009-04-21 11:46:16 +00:00
Daniel Stenberg
b84876ba69 - Leanic Lefever reported a crash and did some detailed research on why and
how it occurs (http://curl.haxx.se/mail/lib-2009-04/0289.html). The
  conclusion was that if an error is detected and Curl_done() is called for
  the connection, ftp_done() could at times return another error code that
  then would take precedence and that new code confused existing logic that
  works for the first error code (CURLE_SEND_ERROR) only.
2009-04-20 21:41:17 +00:00
Yang Tse
4882078469 attempt to workaround icc 9.1 optimizer induced problem 2009-04-19 05:20:04 +00:00
Daniel Stenberg
30f7a2ff20 - Pramod Sharma reported and tracked down a bug when doing FTP over a HTTP
proxy. libcurl would then wrongly close the connection after each
  request. In his case it had the weird side-effect that it killed NTLM auth
  for the proxy causing an inifinite loop!

  I added test case 1098 to verify this fix. The test case does however not
  properly verify that the transfers are done persistently - as I couldn't
  think of a clever way to achieve it right now - but you need to read the
  stderr output after a test run to see that it truly did the right thing.
2009-04-17 12:48:24 +00:00
Daniel Stenberg
a06b36dee0 - Andre Guibert de Bruet fixed a NULL pointer use in an infof() call if a
strdup() call failed.
2009-04-01 12:15:37 +00:00
Dan Fandrich
a9a03b9708 Avoid a compile warning in --disable-proxy case 2009-03-09 04:32:51 +00:00
Daniel Stenberg
af91ff0e06 - Linus Nielsen Feltzing reported and helped me repeat and fix a problem with
FTP with the multi interface: when a transfer fails, like when aborted by a
  write callback, the control connection was wrongly closed and thus not
  re-used properly.

  This change is also an attempt to cleanup the code somewhat in this area, as
  now the FTP code attempts to keep (better) track on pending responses
  necessary to get read in ftp_done().
2009-02-20 08:16:03 +00:00
Patrick Monnerat
6e422c447a FTP downloads (i.e.: RETR) ending with code 550 now return error CURLE_REMOTE_FILE_NOT_FOUND instead of CURLE_FTP_COULDNT_RETR_FILE. 2009-02-18 11:40:16 +00:00
Daniel Stenberg
8f81fd6be5 - CURLOPT_FTP_CREATE_MISSING_DIRS can now be set to 2 in addition to 1 for
plain FTP connections, and it will then allow MKD to fail once and retry the
  CWD afterwards. This is especially useful if you're doing many simultanoes
  connections against the same server and they all have this option enabled,
  as then CWD may first fail but then another connection does MKD before this
  connection and thus MKD fails but trying CWD works! The numbers can
  (should?) now be set with the convenience enums now called
  CURLFTP_CREATE_DIR and CURLFTP_CREATE_DIR_RETRY.

  Tests has proven that if you're making an application that uploads a set of
  files to an ftp server, you will get a noticable gain in speed if you're
  using multiple connections and this option will be then be very useful.
2009-02-17 09:07:25 +00:00
Daniel Stenberg
002cf105c6 - CURLINFO_CONDITION_UNMET was added to allow an application to get to know if
the condition in the previous request was unmet. This is typically a time
  condition set with CURLOPT_TIMECONDITION and was previously not possible to
  reliably figure out. From bug report #2565128
  (http://curl.haxx.se/bug/view.cgi?id=2565128)
2009-02-11 21:47:14 +00:00
Daniel Stenberg
bdd4294e79 - Craig A West brought us: libcurl now defaults to do CONNECT with HTTP
version 1.1 instead of 1.0 like before. This change also introduces the new
  proxy type for libcurl called 'CURLPROXY_HTTP_1_0' that then allows apps to
  switch (back) to CONNECT 1.0 requests. The curl tool also got a --proxy1.0
  option that works exactly like --proxy but sets CURLPROXY_HTTP_1_0.

  I updated all test cases cases that use CONNECT and I tried to do some using
  --proxy1.0 and some updated to do CONNECT 1.1 to get both versions run.
2009-02-02 16:19:23 +00:00
Dan Fandrich
09f4a1c5e5 Fixed --disable-proxy for FTP and SOCKS. Thanks to Daniel Egger for reporting
the problem.
2009-01-30 19:29:25 +00:00
Dan Fandrich
5591550167 Fixed a couple more locale-dependent toupper conversions, mainly for
clarity.  This does fix one problem that causes ;type=i FTP URLs
to fail in the Turkish locale when CURLOPT_PROXY_TRANSFER_MODE is
used (test case 561)

Added tests 561 and 1092 through 1094 to test various combinations
of ;type= and ;mode= URLs that could potentially fail in the Turkish
locale.
2009-01-21 04:42:47 +00:00
Daniel Stenberg
6f86826516 fix typo in comment that made it confusing 2009-01-19 19:09:39 +00:00
Daniel Stenberg
07416b61e3 - Using the libssh2 0.19 function libssh2_session_block_directions(), libcurl
now has an improved ability to do right when the multi interface (both
  "regular" and multi_socket) is used for SCP and SFTP transfers. This should
  result in (much) less busy-loop situations and thus less CPU usage with no
  speed loss.
2008-12-19 21:14:52 +00:00
Gisle Vanem
418683f537 Added the use of Watt-32 tcp/ip stack for Win32 targets. 2008-12-16 08:25:55 +00:00
Daniel Stenberg
4b62cd3616 - Ken Hirsch simplified how libcurl does FTPS: now it doesn't assume any
particular state for the control connection like it did before for implicit
  FTPS (libcurl assumed such control connections to be encrypted while some
  FTPS servers such as FileZilla assumes such connections to be clear
  mode). Use the CURLOPT_USE_SSL option to set your desired level.
2008-12-09 15:02:37 +00:00
Daniel Stenberg
18371aaff9 - Fred Machado posted about a weird FTP problem on the curl-users list and when
researching it, it turned out he got a 550 response back from a SIZE command
  and then I fell over the text in RFC3659 that says:

   The presence of the 550 error response to a SIZE command MUST NOT be taken
   by the client as an indication that the file cannot be transferred in the
   current MODE and TYPE.

  In other words: the change I did on September 30th 2008 and that has been
  included in the last two releases were a regression and a bad idea. We MUST
  NOT take a 550 response from SIZE as a hint that the file doesn't exist.
2008-12-08 20:20:51 +00:00
Yang Tse
a0ef686c54 Merged existing IPv4 and IPv6 Curl_ip2addr functions into a single one
which now also takes a protocol address family argument.
2008-11-06 17:19:56 +00:00
Yang Tse
625c107c25 remove bogus whitespace 2008-10-30 18:12:08 +00:00
Yang Tse
ad3c1c37bb These two variables are now Curl_addrinfo pointers 2008-10-30 16:39:09 +00:00
Yang Tse
10035c898b fix compiler warning 2008-10-24 16:59:35 +00:00
Dan Fandrich
bab5183820 Created Curl_raw_nequal() which does a C-locale string case comparison.
Changed checkprefix() to use it and those instances of strnequal() that
compare host names or other protocol strings that are defined to be
independent of case in the C locale.  This should fix a few more
Turkish locale problems.
2008-10-23 01:20:57 +00:00
Dan Fandrich
7fc4e8af0a Changed some arrays of char* to arrays of char[] to reduce data size and
run-time relocations.
2008-10-22 05:46:29 +00:00
Yang Tse
d0a48627b2 fix compiler warning 2008-10-10 02:14:46 +00:00
Dan Fandrich
fad3288d20 Fixed the --interface option to work with IPv6 connections on glibc
systems supporting getifaddrs(). Also fixed a problem where an IPv6
address could be chosen instead of an IPv4 one for --interface when it
involved a name lookup.
2008-10-09 19:23:50 +00:00
Dan Fandrich
95456b8e78 Added const to some pointer variables 2008-10-08 01:17:51 +00:00
Daniel Stenberg
038542ea3e - The libcurl FTP code now returns CURLE_REMOTE_FILE_NOT_FOUND error when SIZE
gets a 550 response back for the cases where a download (or NOBODY) is
  wanted. It still allows a 550 as response if the SIZE is used as part of an
  upload process (like if resuming an upload is requested and the file isn't
  there before the upload). I also modified the FTP test server and a few test
  cases accordingly to match this modified behavior.
2008-09-30 09:51:58 +00:00
Daniel Stenberg
f3ab5d5500 - Daniel Egger provided a patch that allows you to disable proxy support in
libcurl to somewhat reduce the size of the binary. Run configure
  --disable-proxy.
2008-09-29 21:46:04 +00:00
Yang Tse
4e909ee8b1 ntoa() and inet_ntoa_r() no longer used 2008-09-24 12:22:16 +00:00
Yang Tse
59e378f48f remove unnecessary typecasting of malloc() 2008-09-06 05:29:05 +00:00
Yang Tse
a622fd90b4 remove unnecessary typecasting of calloc() 2008-09-06 04:47:14 +00:00
Dan Fandrich
29ec219b82 Fixed an out of memory problem that caused torture test failures in tests
706 and 707.
2008-09-02 23:12:00 +00:00
Yang Tse
ad638da2c2 Library internal only C preprocessor macros FORMAT_OFF_T and FORMAT_OFF_TU
remain in use as internal curl_off_t print formatting strings for the internal
*printf functions which still cannot handle print formatting string directives
such as "I64d", "I64u", and others available on MSVC, MinGW, Intel's ICC, and
other DOS/Windows compilers.

This reverts previous commit part which did:

FORMAT_OFF_T  -> CURL_FORMAT_CURL_OFF_T
FORMAT_OFF_TU -> CURL_FORMAT_CURL_OFF_TU
2008-08-16 01:33:59 +00:00
Yang Tse
66fb9ca5f6 For congruency sake with the naming of other CURL_XXXXXX_CURL_OFF_T macros,
the names of the curl_off_t formatting string directives now become
CURL_FORMAT_CURL_OFF_T and CURL_FORMAT_CURL_OFF_TU.

CURL_FMT_OFF_T  -> CURL_FORMAT_CURL_OFF_T
CURL_FMT_OFF_TU -> CURL_FORMAT_CURL_OFF_TU

Remove the use of an internal name for the curl_off_t formatting string directives
and use the common one available from the inside and outside of the library.

FORMAT_OFF_T  -> CURL_FORMAT_CURL_OFF_T
FORMAT_OFF_TU -> CURL_FORMAT_CURL_OFF_TU
2008-08-15 02:58:15 +00:00
Dan Fandrich
f1fe04245a Fixed a boundary condition error in ftp_readresp() whereby a non-terminal
line of a multiline FTP response whose last byte landed exactly at the end
of the BUFSIZE-length buffer would be treated as the terminal response
line.  The following response code read in would then actually be the
end of the previous response line, and all responses from then on would
correspond to the wrong command. Test case 1062 verifies this.

Stop closing a never-opened ftp socket.
2008-08-11 23:16:08 +00:00
Daniel Stenberg
0e5da5b8bc - Scott Barrett provided a test case for a segfault in the FTP code and the
fix for it. It occured when you did a FTP transfer using
  CURLFTPMETHOD_SINGLECWD and then did another one on the same easy handle but
  switched to CURLFTPMETHOD_NOCWD. Due to the "dir depth" variable not being
  cleared properly.  Scott's test case is now known as test 539 and it
  verifies the fix.
2008-07-07 20:37:07 +00:00
Daniel Stenberg
e481d679b2 - Liam Healy filed the debian bug report #480044
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=480044) identifying a
  segfault when using krb5 ftp, but the krb4 code had the same problem.
2008-05-07 21:02:21 +00:00
Daniel Stenberg
7a6cff4b3a - Norbert Frese filed bug report #1951588: "Problem with curlftpfs and
libcurl" (http://curl.haxx.se/bug/view.cgi?id=1951588) which seems to be an
  identical report to what Denis Golovan reported in
  http://curl.haxx.se/mail/lib-2008-02/0108.html The FTP code didn't reset the
  user/password pointers properly even though there might've been a new
  struct/cconnection getting used.
2008-04-28 21:29:17 +00:00
Dan Fandrich
1960eebc2d Added support for running on Symbian OS. 2008-04-22 22:53:53 +00:00
Dan Fandrich
09777a4fc2 Some trivial changes 2008-04-17 00:45:33 +00:00
Daniel Stenberg
7607d5145b - Based on the Debian bug report #474224 that complained about the FTP error
message when libcurl doesn't get a 220 back immediately on connect, I now
  changed it to be more specific on what the problem is. Also worth noticing:
  while the bug report contains an example where the response is:

    421 There are too many connected users, please try again later

  we cannot assume that the error message will always be this readable nor
  that it fits within a particular boundary etc.
2008-04-05 21:02:38 +00:00
Daniel Stenberg
1b701c746f - Refactored a lot of timeout code into a few functions in an attempt to make
them all use the same (hopefully correct) logic to make it less error-prone
  and easier to introduce library-wide where it should be used.
2008-02-07 22:25:04 +00:00
Daniel Stenberg
b620e62f0f - Dmitry Kurochkin moved several struct fields from the connectdata struct to
the SingleRequest one to make pipelining better. It is a bit tricky to keep
  them in the right place, to keep things related to the actual request or to
  the actual connection in the right place.
2008-01-31 12:04:33 +00:00
Daniel Stenberg
ed6466d176 Calls to Curl_failf() are not supposed to provide a trailing newline as the
function itself adds that. Fixed on 50 or something strings!
2008-01-15 23:19:02 +00:00
Yang Tse
3564aec388 fix compiler warning 2008-01-11 17:35:10 +00:00
Daniel Stenberg
18faa50940 Georg Lippitsch brought CURLOPT_SEEKFUNCTION and CURLOPT_SEEKDATA to allow
libcurl to seek in a given input stream. This is particularly important when
doing upload resumes when there's already a huge part of the file present
remotely. Before, and still if this callback isn't used, libcurl will read
and through away the entire file up to the point to where the resuming
begins (which of course can be a slow opereration depending on file size,
I/O bandwidth and more). This new function will also be preferred to get
used instead of the CURLOPT_IOCTLFUNCTION for seeking back in a stream when
doing multi-stage HTTP auth with POST/PUT.
2008-01-10 10:30:19 +00:00
Daniel Stenberg
f111c9edae more SOCKS5_HOSTNAME adjustments from Richard Atterer 2008-01-06 21:41:38 +00:00
Daniel Stenberg
7138296633 make sure we deal with SOCKS5_HOSTNAME as a proxy type as well 2008-01-06 12:56:34 +00:00
Gisle Vanem
083d3190e5 'false' and 'true' are not built-ins on most compilers.
Use TRUE/FALSE from setup_once.h.
2008-01-03 15:18:27 +00:00
Daniel Stenberg
a46b40b7fd Richard Atterer brought a patch that added support for SOCKS4a proxies, which
is an inofficial PROXY4 variant that sends the hostname to the proxy instead
of the resolved address (which is already supported by SOCKS5).  --socks4a is
the curl command line option for it and CURLOPT_PROXYTYPE can now be set to
CURLPROXY_SOCKS4A as well.
2008-01-02 21:40:11 +00:00
Daniel Stenberg
662bee7193 All static functions that were previously name Curl_* something no longer
use that prefix as we use that prefix only for library-wide internal global
symbols.
2007-12-08 22:50:55 +00:00
Daniel Stenberg
f75ba55b51 Fixed the resumed FTP upload loop to not require that the read callback
returns a full buffer on each invoke.
2007-11-29 22:14:33 +00:00
Daniel Stenberg
13648f8ccd struct HandleData is now called struct SingleRequest, and is only for data that
is inited at the start of the DO action. I removed the Curl_transfer_keeper
struct completely, and I had to move out a few struct members (that had to
be set before DO or used after DONE) to the UrlState struct. The SingleRequest
struct is accessed with SessionHandle->req.

One of the biggest reasons for doing this was the bunch of duplicate struct
members in HandleData and Curl_transfer_keeper since it was really messy to
keep track of two variables with the same name and basically the same purpose!
2007-11-24 23:16:55 +00:00
Daniel Stenberg
cbd1a77ec2 if () => if()
while () => while()
and some other minor re-indentings
2007-11-07 09:21:35 +00:00
Daniel Stenberg
ad6e28073c removed space after if and while before the parenthesis for better source code
consistency
2007-11-05 09:45:09 +00:00
Daniel Stenberg
2ec8f77f21 avoid setting up a transfer when the state machine failed previously 2007-11-02 23:34:00 +00:00
Daniel Stenberg
d34fe06fb0 minor re-indent 2007-11-01 21:43:56 +00:00
Dan Fandrich
d3ee83747c Fixed a valgrind uninitialized variable error. 2007-10-26 19:26:41 +00:00
Daniel Stenberg
8997d258f7 Curl_ftp_disconnect() no longer relies on anything in the reqdata struct. That
was even mentioned to be bad in a comment! Should make test 2000 and 2001 work
fine.

Also, freedirs() now take a ftp_conn struct pointer which saves some extra
unnecessary variable assignments.
2007-10-24 21:14:11 +00:00
Daniel Stenberg
5b358603bd Michal Marek forwarded the bug report
https://bugzilla.novell.com/show_bug.cgi?id=332917 about a HTTP redirect to
FTP that caused memory havoc. His work together with my efforts created two
fixes:

#1 - FTP::file was moved to struct ftp_conn, because is has to be dealt with
     at connection cleanup, at which time the struct HandleData could be
     used by another connection.
     Also, the unused char *urlpath member is removed from struct FTP.

#2 - provide a Curl_reset_reqproto() function that frees
     data->reqdata.proto.* on connection setup if needed (that is if the
     SessionHandle was used by a different connection).
2007-10-22 15:05:35 +00:00
Yang Tse
92433e596b We use this ZERO_NULL to avoid picky compiler warnings,
when assigning a NULL pointer to a function pointer var.
2007-10-17 16:58:32 +00:00
Dan Fandrich
61ffcd7815 Made a few more functions static with the protocol handler table in place. 2007-10-13 00:47:53 +00:00
Dan Fandrich
7831c1ae44 Fixed a few compile errors and warnings. 2007-10-12 18:49:14 +00:00
Patrick Monnerat
07b6e7363d Added per-protocol callback static tables, replacing callback ptr storage
in the connectdata structure by a single handler table ptr.
2007-10-12 13:36:37 +00:00
Yang Tse
08b9f73219 Fix memory leak under low memory conditions. 2007-10-02 19:19:47 +00:00
Yang Tse
048bfeaaef Fix compiler warning 2007-10-02 15:26:30 +00:00
Dan Fandrich
0bd2d54814 Renamed a few variables to avoid shadowing global declarations. 2007-09-27 02:45:58 +00:00
Dan Fandrich
16b95fc773 Enabled a few more gcc warnings with --enable-debug. Renamed a few
variables to avoid shadowing global declarations.
2007-09-27 01:45:22 +00:00
Daniel Stenberg
a6315359d7 Max Katsev reported that when doing a libcurl FTP request with
CURLOPT_NOBODY enabled but not CURLOPT_HEADER, libcurl wouldn't do TYPE
before it does SIZE which makes it less useful. I walked over the code and
made it do this properly, and added test case 542 to verify it.
2007-09-26 12:00:01 +00:00
Daniel Stenberg
775f86cb5a Immanuel Gregoire fixed KNOWN_BUGS #44: --ftp-method nocwd did not handle
URLs ending with a slash properly (it should list the contents of that
directory). Test case 351 brought back and also test 1010 was added.
2007-09-24 21:47:35 +00:00
Daniel Stenberg
1ce732e9d6 - I noticed while writing test 541 that the FTP code wrongly did a CWD on the
second transfer as it didn't store and remember the "" path from the
  previous transfer so it would instead CWD to the entry path as stored. This
  worked, but did a superfluous command. Thus, test case 541 now also verifies
  this fix.
2007-09-11 22:21:39 +00:00
Daniel Stenberg
73e91ce20c Curl_GetFTPResponse() now checks and properly deals with the fact that the
underlying ftp_readresp() function has a separate "cache" where there might
in fact be leftover data...
2007-09-05 21:41:07 +00:00
Dan Fandrich
3fa60164af Renamed the CURLE_FTP_SSL_FAILED error code to CURLE_USE_SSL_FAILED.
Renamed the curl_ftpssl enum to curl_usessl and its enumerated constants,
creating macros for backward compatibility.
2007-08-31 19:36:32 +00:00
Dan Fandrich
9f44a95522 Renamed several libcurl error codes and options to make them more general
and allow reuse by multiple protocols. Several unused error codes were
removed.  In all cases, macros were added to preserve source (and binary)
compatibility with the old names.  These macros are subject to removal at
a future date, but probably not before 2009.  An application can be
tested to see if it is using any obsolete code by compiling it with the
CURL_NO_OLDIES macro defined.

Documented some newer error codes in libcurl-error(3)
2007-08-30 20:34:57 +00:00
Daniel Stenberg
da4a776758 Made Curl_GetFTPResponse() use lots less code and instead use the proper
low-level ftp_readresp() function. Hopefully adressing bug #1779054.
2007-08-30 14:06:00 +00:00
Dan Fandrich
8cf0814a14 Fixed some minor type mismatches and missing consts mainly found by splint. 2007-08-27 06:31:28 +00:00
Daniel Stenberg
7cba40b218 Bug report #1779054 (http://curl.haxx.se/bug/view.cgi?id=1779054) pointed
out that libcurl didn't deal with large responses from server commands, when
the single response was consisting of multiple lines but of a total size of
16KB or more. Dan Fandrich improved the ftp test script and provided test
case 1006 to repeat the problem, and I fixed the code to make sure this new
test case runs fine.
2007-08-24 14:00:42 +00:00
Daniel Stenberg
381e372939 Bug report #1779054 (http://curl.haxx.se/bug/view.cgi?id=1779054) pointed
out that libcurl didn't deal with very long (>16K) FTP server response lines
properly. Starting now, libcurl will chop them off (thus the client app will
not get the full line) but survive and deal with them fine otherwise. Test
case 1003 was added to verify this.
2007-08-22 14:18:06 +00:00
Daniel Stenberg
b132e865b9 Based on a patch by Christian Vogt, the FTP code now sets the upcoming
download transfer size much earlier to be possible to get read with
CURLINFO_CONTENT_LENGTH_DOWNLOAD as soon as possible.
2007-08-20 21:54:00 +00:00
Daniel Stenberg
1aa82decea - Robson Braga Araujo filed bug report #1776232
(http://curl.haxx.se/bug/view.cgi?id=1776232) about libcurl calling
  Curl_client_write(), passing on a const string that the caller may not
  modify and yet it does (on some platforms).
2007-08-17 22:31:51 +00:00
Daniel Stenberg
3217809294 Robson Braga Araujo filed bug report #1776235
(http://curl.haxx.se/bug/view.cgi?id=1776235) about ftp requests with NOBODY
on a directory would do a "SIZE (null)" request. This is now fixed and test
case 1000 was added to verify.
2007-08-17 22:22:43 +00:00
Daniel Stenberg
50c10aa5bf Patrick Monnerat and I modified libcurl so that now it *copies* all strings
passed to it with curl_easy_setopt()! Previously it has always just refered
to the data, forcing the user to keep the data around until libcurl is done
with it. That is now history and libcurl will instead clone the given
strings and keep private copies.
2007-08-01 21:20:01 +00:00
Daniel Stenberg
f1fa7b8ba4 Bug report #1759542 (http://curl.haxx.se/bug/view.cgi?id=1759542). A bad use
of a socket after it has been closed, when the FTP-SSL data connection is taken
down.
2007-07-29 12:54:05 +00:00
Dan Fandrich
5ecd56d964 Implemented only the parts of Patrick Monnerat's OS/400 patch that renamed
some few internal identifiers to avoid conflicts, which could be useful on
other platforms.
2007-07-23 18:51:22 +00:00
Dan Fandrich
b465750041 Make the pointers of a few static const arrays const, too, for safety. 2007-07-21 02:08:17 +00:00
Daniel Stenberg
e3377e637a Ralf S. Engelschall filed bug report #1757328
(http://curl.haxx.se/bug/view.cgi?id=1757328) and submitted a patch. It turns
out we broke login to FTP servers that don't require (nor understand) PASS
after the USER command
2007-07-20 09:35:58 +00:00
Dan Fandrich
4a2f0fb2be Made some const arrays static to avoid unnecessary stack usage. 2007-07-20 00:41:12 +00:00
Daniel Stenberg
1d728aae2a Jofell Gallardo posted a libcurl log using FTP that exposed a bug which made
a control connection that was deemed "dead" to yet be re-used in a following
request. We must make sure the connection gets closed on this situation.
2007-07-17 20:59:53 +00:00
Daniel Stenberg
cf5378b366 Daniel Cater made libcurl build with CURL_NO_OLDIES defined (which doesn't
define the symbols for backwards source compatibility)
2007-07-13 20:04:53 +00:00
Daniel Stenberg
54967d2a3a Thomas J. Moore provided a patch that introduces Kerberos5 support in
libcurl. This also makes the options change name to --krb (from --krb4) and
CURLOPT_KRBLEVEL (from CURLOPT_KRB4LEVEL) but the old names are still
2007-07-01 22:01:18 +00:00
Daniel Stenberg
667fd9a60b Song Ma helped me verify and extend a fix for doing FTP over a SOCKS4/5 proxy 2007-07-01 21:28:14 +00:00
Daniel Stenberg
af4edf10f5 As reported by "Tro" in http://curl.haxx.se/mail/lib-2007-06/0161.html and
http://curl.haxx.se/mail/lib-2007-06/0238.html, libcurl didn't properly do
no-body requests on FTP files on re-used connections properly, or at least
it didn't provide the info back in the header callback properly in the
subsequent requests.
2007-06-24 19:32:33 +00:00
Daniel Stenberg
fc3c5dae87 and fix another flaw in the singlecwd case when we get ftp://site.com/, also
from the #1739100 bug report
2007-06-19 12:33:28 +00:00
Daniel Stenberg
fe85ae15f3 make the ftp-method multicwd case possible to LIST the root directory of a
server!
2007-06-18 21:04:45 +00:00
Dan Fandrich
6e835ef3aa Fixed an out of memory handling issue. 2007-04-25 20:54:02 +00:00
Yang Tse
3616912d22 Avoid an unnecessary call to gettimeofday() when
using custom timeout values.
2007-04-22 18:17:46 +00:00
Dan Fandrich
70cce4cddd Work around an out of memory situation in Curl_ftp_done instead of
returning an error code, to allow connections to be torn down
cleanly since this function can be called AFTER an OOM situation
has already been reached.
2007-04-12 01:26:02 +00:00
Dan Fandrich
47f044265e Fixed some out of memory handling issues. 2007-04-11 00:25:41 +00:00
Daniel Stenberg
5daa6b9367 Ravi Pratap provided fixes for HTTP pipelining 2007-04-10 20:46:40 +00:00
Daniel Stenberg
3af08472ad Removed check for ftpcode being NULL, as later it is derefenced unconditionally
anyway and we can just as well rely on it being valid.
CID 12, coverity.com scan
2007-03-31 10:39:54 +00:00
Daniel Stenberg
74e54c5a49 Pointer "cur_pos" dereferenced before NULL check, found by coverity.com scan.
Removed the NULL check since the pointer must be valid already.
2007-03-30 20:52:42 +00:00
Dan Fandrich
ffb11ad5c6 Don't tear down the ftp connection if the maximum filesize was exceeded
and added tests 290 and 291 to check.
2007-03-30 01:13:47 +00:00
Yang Tse
d58c7a8bdd Update message 2007-03-27 18:16:35 +00:00
Yang Tse
fba4cd0e62 Internal function Curl_select() renamed to Curl_socket_ready() 2007-03-26 23:23:46 +00:00
Yang Tse
f08ac86834 fix compiler warning 2007-03-25 02:30:58 +00:00
Yang Tse
d6eca89229 fix compiler warning 2007-03-25 01:59:52 +00:00
Gisle Vanem
c514a2a89a Removed inclusion of <sys/types.h> and <sys/stat.h> in .c-files
since they're already included through "setup.h".
2007-02-26 04:24:26 +00:00
Linus Nielsen Feltzing
2f5e99ca02 New FTP CCC functionality - adds passive and active mode to accomodate for different server behaviour 2007-02-20 22:02:11 +00:00
Daniel Stenberg
d2bdad5945 and fix warnings due to lack of protos 2007-02-19 11:55:49 +00:00
Daniel Stenberg
17e8d60c01 - Robson Braga Araujo made passive FTP transfers work with SOCKS (both 4 and
5).
2007-02-19 11:53:54 +00:00
Yang Tse
a1d5983991 use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling 2007-02-16 18:19:35 +00:00
Daniel Stenberg
aa4435c23b - Duncan Mac-Vicar Prett and Michal Marek reported problems with resetting
CURLOPT_RANGE back to no range on an easy handle when using FTP.
2007-02-16 15:37:05 +00:00
Yang Tse
e213555c98 compiler warning fix 2007-02-06 18:06:37 +00:00
Daniel Stenberg
91386937ff - Michael Wallner provided a patch that adds support for CURLOPT_TIMEOUT_MS
and CURLOPT_CONNECTTIMEOUT_MS that, as their names should hint, do the
  timeouts with millisecond resolution instead. The only restriction to that
  is the alarm() (sometimes) used to abort name resolves as that uses full
  seconds. I fixed the FTP response timeout part of the patch.

  Internally we now count and keep the timeouts in milliseconds but it also
  means we multiply set timeouts with 1000. The effect of this is that no
  timeout can be set to more than 2^31 milliseconds (on 32 bit systems), which
  equals 24.86 days.  We probably couldn't before either since the code did
  *1000 on the timeout values on several places already.
2007-02-05 22:51:32 +00:00
Yang Tse
d2dd3d7e16 compiler warning fix 2007-02-01 15:36:56 +00:00
Yang Tse
54db98c220 compiler warning fix 2007-02-01 01:42:13 +00:00
Dan Fandrich
5f9cbc4209 Only shut down SSL if the CCC command succeeded. 2007-01-24 19:09:12 +00:00
Daniel Stenberg
385e612fa5 - Armel Asselin improved libcurl to behave a lot better when an easy handle
doing an FTP transfer is removed from a multi handle before completion. The
  fix also fixed the "alive counter" to be correct on "premature removal" for
  all protocols.
2007-01-16 22:22:10 +00:00
Linus Nielsen Feltzing
d465199411 Correct error code for CCC/SSL shutdown failure 2007-01-08 11:24:11 +00:00
Daniel Stenberg
4750e6f3c5 - Linus Nielsen Feltzing introduced the --ftp-ssl-ccc command line option to
curl that uses the new CURLOPT_FTP_SSL_CCC option in libcurl. If enabled, it
  will make libcurl shutdown SSL/TLS after the authentication is done on a
  FTP-SSL operation.
2007-01-05 23:11:14 +00:00
Daniel Stenberg
bedc61ac45 - Robert Foreman provided a prime example snippet showing how libcurl would
get confused and not acknowledge the 'no_proxy' variable properly once it
  had used the proxy and you re-used the same easy handle. I made sure the
  proxy name is properly stored in the connect struct rather than the
  sessionhandle/easy struct.
2006-12-22 15:04:59 +00:00
Daniel Stenberg
1beb7de7e0 removed unused variables 2006-12-21 10:18:15 +00:00
Daniel Stenberg
89ab5f4380 Robson Braga Araujo reported bug #1618359
(http://curl.haxx.se/bug/view.cgi?id=1618359) and subsequently provided a
patch for it: when downloading 2 zero byte files in a row, curl 7.16.0
enters an infinite loop, while curl 7.16.1-20061218 does one additional
unnecessary request.

Fix: During the "Major overhaul introducing http pipelining support and
shared connection cache within the multi handle." change, headerbytecount
was moved to live in the Curl_transfer_keeper structure. But that structure
is reset in the Transfer method, losing the information that we had about
the header size. This patch moves it back to the connectdata struct.
2006-12-21 10:15:38 +00:00
Daniel Stenberg
88c8d72a21 Alexey Simak found out that when doing FTP with the multi interface and
something went wrong like it got a bad response code back from the server,
libcurl would leak memory. Added test case 538 to verify the fix.

I also noted that the connection would get cached in that case, which
doesn't make sense since it cannot be re-use when the authentication has
failed. I fixed that issue too at the same time, and also that the path
would be "remembered" in vain for cases where the connection was about to
get closed.
2006-12-11 09:32:58 +00:00
Daniel Stenberg
3c4f622479 Alexey Simak filed bug report #1600447
(http://curl.haxx.se/bug/view.cgi?id=1600447) in which he noted that active
FTP connections don't work with the multi interface. The problem is here that
the multi interface state machine has a state during which it can wait for the
data connection to connect, but the active connection is not done in the same
step in the sequence as the passive one is so it doesn't quite work for
active. The active FTP code still use a blocking function to allow the remote
server to connect.

The fix (work-around is a better word) for this problem is to set the
boolean prematurely that the data connection is completed, so that the "wait
for connect" phase ends at once.
2006-12-05 13:49:29 +00:00
Daniel Stenberg
44d84ac164 Avoid typecasting a signed char to an int when using is*() functions, as that
could very well cause a negate number get passed in and thus cause reading
outside of the array usually used for this purpose.

We avoid this by using the uppercase macro versions introduced just now that
does some extra crazy typecasts to avoid byte codes > 127 to cause negative
int values.
2006-10-17 21:32:56 +00:00
Yang Tse
ec956b0334 Explicit typecast for Curl_debug() size argument 2006-10-17 10:04:13 +00:00
Yang Tse
e150150d9f Remove redundant __CYGWIN__ symbol check 2006-10-11 16:01:16 +00:00
Daniel Stenberg
e2b48366d3 removed more dead code that is unused since the removal of the third party
transfer support
2006-10-02 13:00:54 +00:00
Daniel Stenberg
5e0d9aea32 Support for FTP third party transfers is now dropped 2006-09-30 20:31:11 +00:00
Daniel Stenberg
ab798fe5ba (FTP) a failed upload does not invalidate the control connection 2006-09-21 20:52:58 +00:00
Daniel Stenberg
c001ed53fa Armel Asselin - When the easy handle is removed from the multi while libcurl
is still trying to resolve the host name, it seems that the ftp struct is not
yet initialized, but the removal action calls Curl_done() which calls
Curl_ftp_done. So we simply return success from there if no ftp pointer is
set.
2006-09-16 20:57:59 +00:00
Yang Tse
733a184ce0 Compiler warning fix 2006-09-12 23:51:01 +00:00
Yang Tse
c30e908034 Compiler warning fix 2006-09-10 23:37:42 +00:00
Yang Tse
bb87b65f08 Compiler warning fix 2006-09-09 13:24:42 +00:00
Daniel Stenberg
ed72d4e104 tab => space 2006-09-09 11:45:05 +00:00
Daniel Stenberg
8ec1bfe897 Peter Sylvester cleaned up and fixed the getsockname() uses in ftp.c. Some
of them can be completetly removed though...
2006-09-08 22:17:39 +00:00
Yang Tse
dc7c915553 Compilation fix 2006-09-08 05:18:07 +00:00
Daniel Stenberg
b7eeb6e67f Major overhaul introducing http pipelining support and shared connection
cache within the multi handle.
2006-09-07 21:49:20 +00:00
Gisle Vanem
4f4277d9c7 Simplified #ifdef on WIN32; the statement
" !defined(__GNUC__) || defined(__MINGW32__)" implies
CygWin.
2006-09-03 13:52:07 +00:00
Gisle Vanem
4031eb1d91 Avoid Metaware's High-C warning "'=' encountered where '==' may have been intended." 2006-08-29 21:11:55 +00:00
Daniel Stenberg
d792937686 Peter Sylvester pointed out a flaw in the AllowServerConnect() in the FTP
code when doing pure ipv6 EPRT connections.
2006-08-22 21:21:01 +00:00
Daniel Stenberg
cfdcae4bc7 Based on a patch by Armel Asselin, the FTP code no longer re-issues the TYPE
command on subsequent requests on a re-used connection unless it has to.
2006-08-19 21:18:36 +00:00
Daniel Stenberg
74a6921bc4 Armel Asselin fixed a crash in the FTP code when using SINGLECWD mode and
files in the root directory.
2006-08-18 23:17:33 +00:00
Daniel Stenberg
1eedad27a2 Armel Asselin made the CURLOPT_PREQUOTE option work fine even when
CURLOPT_NOBODY is set true. PREQUOTE is then run roughly at the same place
in the command sequence as it would have run if there would've been a
transfer.
2006-08-08 22:56:46 +00:00
Daniel Stenberg
2527b53019 Dan Nelson added the CURLOPT_FTP_ALTERNATIVE_TO_USER libcurl option and curl
tool option named --ftp-alternative-to-user. It provides a mean to send a
particular command if the normal USER/PASS approach fails.
2006-07-25 22:45:21 +00:00
Gisle Vanem
73ebb0edde Avoid warning 'port' might be used uninitialized in this function. 2006-07-20 15:54:01 +00:00
Daniel Stenberg
e85e30546c Roland Blom filed bug report #1481217
(http://curl.haxx.se/bug/view.cgi?id=1481217), with follow-ups by Michele Bini
and David Byron. libcurl previously wrongly used GetLastError() on windows to
get error details after socket-related function calls, when it really should
use WSAGetLastError() instead.

When changing to this, the former function Curl_ourerrno() is now instead
called Curl_sockerrno() as it is necessary to only use it to get errno from
socket-related functions as otherwise it won't work as intended on Windows.
2006-05-04 22:39:47 +00:00
Daniel Stenberg
95152aec68 David McCreedy brought line end conversions when doing FTP ASCII
transfers. They are done on non-windows systems and translate CRLF to LF.
2006-04-26 07:40:37 +00:00
Daniel Stenberg
e532b196cc Robson Braga Araujo provided a patch that makes libcurl less eager to close
the control connection when using FTP, for example when you remove an easy
handle from a multi stack.
2006-04-18 23:14:30 +00:00
Daniel Stenberg
686d90745b First curl_multi_socket() commit. Should primarily be considered as an internal
code rearrange to fit the future better.
2006-04-10 15:00:53 +00:00
Daniel Stenberg
5a4b43848a First commit of David McCreedy's EBCDIC and TPF changes. 2006-04-07 21:50:47 +00:00
Daniel Stenberg
598ffeea89 David McCreedy added CURLINFO_FTP_ENTRY_PATH to export the FTP entry path 2006-03-21 22:30:03 +00:00
Daniel Stenberg
6421d69bff David McCreedy fixed libcurl to no longer ignore AUTH failures and now it
reacts properly according to the CURLOPT_FTP_SSL setting.
2006-03-20 22:51:08 +00:00
Daniel Stenberg
7206181385 David McCreedy found a missing return code assignment 2006-03-13 23:33:46 +00:00
Daniel Stenberg
f70f11fc70 Peter Heuchert's correction for the clear control connection case 2006-03-08 15:46:21 +00:00
Daniel Stenberg
b8c8e7349f Peter Heuchert made sure the CURLFTPSSL_CONTROL setting for CURLOPT_FTP_SSL
is used properly.
2006-03-07 22:28:08 +00:00
Daniel Stenberg
7d68101f83 Prevent uploading to a URL that has no file name part. 2006-03-03 13:09:30 +00:00
Daniel Stenberg
87bcb6f377 Karl M added the CURLOPT_CONNECT_ONLY and CURLINFO_LASTSOCKET options that
an app can use to let libcurl only connect to a remote host and then extract
the socket from libcurl. libcurl will then not attempt to do any transfer at
all after the connect is done.
2006-02-11 22:35:16 +00:00
Daniel Stenberg
67bf4f28ff Michal Marek provided a patch for FTP that makes libcurl continue to try PASV
even after EPSV returned a positive response code, if libcurl failed to
connect to the port number the EPSV response said. Obviously some people are
going through protocol-sensitive firewalls (or similar) that don't understand
EPSV and then they don't allow the second connection unless PASV was
used. This also called for a minor fix of test case 238.
2006-01-24 14:40:43 +00:00
Daniel Stenberg
fcfd6d9504 Duane Cathey was one of our friends who reported that curl -P [IP]
(CURLOPT_FTPPORT) didn't work for ipv6-enabed curls if the IP wasn't a
"native" IP while it works fine for ipv6-disabled builds!

In the process of fixing this, I removed the support for LPRT since I can't
think of many reasons to keep doing it and asking on the mailing list didn't
reveal anyone else that could either. The code that sends EPRT and PORT is
now also a lot simpler than before (IMHO).
2006-01-19 23:52:03 +00:00
Daniel Stenberg
c31451cf13 Jon Turner pointed out that doing -P [hostname] with curl (built ipv4-only)
didn't work.
2006-01-19 22:02:46 +00:00
Daniel Stenberg
d9bd5de0b1 Fixed FTP_SKIP_PASV_IP and FTP_USE_EPSV to "do right" when used on FTP thru
HTTP proxy.
2006-01-12 22:18:38 +00:00
Daniel Stenberg
31c7aa0ba4 Michael Jahn fixed ftp over CONNECT 2006-01-12 12:40:04 +00:00
Daniel Stenberg
4431338691 When using a bad path over FTP, as in when libcurl couldn't CWD into all
given subdirs, libcurl would still "remember" the full path as if it is the
current directory libcurl is in so that the next curl_easy_perform() would
get really confused if it tried the same path again - as it would not issue
any CWD commands at all, assuming it is already in the "proper" dir.

Starting now, a failed CWD command sets a flag that prevents the path to be
"remembered" after returning.
2006-01-10 23:03:22 +00:00
Yang Tse
b15f3bb969 Undo last changes 2005-12-11 23:37:58 +00:00
Yang Tse
e3f523ab2a Avoid generation of additional warnings 2005-12-11 18:29:18 +00:00
Yang Tse
36485e56ed Fix compiler warning and compatibility issue with the type of the parameter used in getnameinfo() to receive the length of the sockaddr struct. 2005-12-11 12:03:01 +00:00
Daniel Stenberg
272231fb09 Another Yang Tse warning cleanup raid! 2005-12-05 14:10:48 +00:00
Daniel Stenberg
0fd282b078 new experimental "ftp method" code 2005-11-28 23:06:00 +00:00
Daniel Stenberg
d52ed3fff2 Jan Kunder's debian bug report
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=338680 identified a weird
error message for when you try to upload a file and the requested directory
doesn't exist on the target server.
2005-11-14 00:18:12 +00:00
Daniel Stenberg
a5da1219bb Reversed the logic for sockaddr_storage and made our own Curl_sockaddr_storage
struct instead to use.
2005-11-12 22:10:42 +00:00
Daniel Stenberg
37a6a0bb3e Moved the sockaddr_storage definition to lib/sockaddr.h and only include that
in files that actually need the struct.
2005-11-11 22:04:11 +00:00
Daniel Stenberg
29676f473d David Lang: if there is no sockaddr_storage, make up our own and use that 2005-11-10 22:24:49 +00:00
Daniel Stenberg
3beb2f6b5d CURL_TIMECOND_IFMODSINCE actually requires that the remote document has been
modded since the given time, so we should compare <= and not just <.
2005-10-05 06:09:20 +00:00
Daniel Stenberg
a2902de67c TJ Saunders of the proftpd project identified and pointed out problems with
the modified FTPS negotiation change of August 19 2005. Thus, we revert the
change back to pre-7.14.1 status.
2005-09-27 08:46:54 +00:00
Daniel Stenberg
e7093b3ca8 keep 'socktype' in the connectdata struct and make sure we use that for all
protocol sockets even if the resolved address may say otherwise
2005-09-16 21:30:08 +00:00
Daniel Stenberg
0b8ccd0ae7 oops, return error if an error did occur! 2005-09-14 15:04:01 +00:00
Daniel Stenberg
7e845e7cfd Added FTP_SKIP_PASV_IP and --ftp-skip-pasv-ip 2005-09-04 05:16:06 +00:00
Daniel Stenberg
710ee3b0e0 Norbert Novotny had problems with FTPS and he helped me work out a patch
that made curl run fine in his end. The key was to make sure we do the
SSL/TLS negotiation immediately after the TCP connect is done and not after
a few other commands have been sent like we did previously. I don't consider
this change necessary to obey the standards, I think this server is pickier
than what the specs allow it to be, but I can't see how this modified
libcurl code can add any problems to those who are interpreting the
standards more liberally.
2005-08-19 14:41:09 +00:00
Dan Fandrich
6e87cf5b30 Fixed some typos in output messages. 2005-07-21 22:18:35 +00:00
Daniel Stenberg
20005a83d2 Andrew Bushnell provided enough info for me to tell that we badly needed to
fix the CONNECT authentication code with multi-pass auth methods (such as
NTLM) as it didn't previously properly ignore response-bodies - in fact it
stopped reading after all response headers had been received. This could
lead to libcurl sending the next request and reading the body from the first
request as response to the second request. (I also renamed the function,
which wasn't strictly necessary but...)

The best fix would to once and for all make the CONNECT code use the
ordinary request sending/receiving code, treating it as any ordinary request
instead of the special-purpose function we have now. It should make it
better for multi-interface too. And possibly lead to less code...

Added test case 265 for this. It doesn't work as a _really_ good test case
since the test proxy is too stupid, but the test case helps when running the
debugger to verify.
2005-07-03 22:25:15 +00:00
Daniel Stenberg
e7012a515c Now allow TYPE responses to be any 2xx code, and log if it isn't 200. 2005-05-24 09:39:56 +00:00
Daniel Stenberg
ede9fb4fcc check if getsockname() returns failure before using the address it provides 2005-05-17 09:18:17 +00:00
Daniel Stenberg
723aef71e8 reduced typecasts, from two to one 2005-05-17 09:15:21 +00:00
Gisle Vanem
ecdcb0ef67 Some patches for (a stricter/smarter) gcc 4.0 and
warnings like:
  'x' may be used uninitialized in this function.
2005-05-14 06:00:40 +00:00
Daniel Stenberg
708ed6fded silence compiler warnings 2005-05-08 22:45:01 +00:00
Daniel Stenberg
5c30fa50d6 fix warnings about unused variables for non-debug builds 2005-05-07 20:41:16 +00:00
Daniel Stenberg
fc33c424d9 fix 2005-05-07 20:28:39 +00:00
Daniel Stenberg
9c5f79c56a DEBUGF() is a new conveniant macro to add infof() calls (or similar) for
debug builds only. Made the ftp code use it on several places.
2005-05-07 13:57:07 +00:00
Daniel Stenberg
44985e8884 improved failf() error messages 2005-05-02 22:53:55 +00:00
Daniel Stenberg
a31ddd363b Now configure checks for struct sockaddr_storage and the ftp code tries
to survive without it if not found. AIX 4.3 targetted adjustment.
2005-05-02 11:56:15 +00:00
Daniel Stenberg
6b1220b61d Cory Nelson's work on nuking compiler warnings when building on x64 with
VS2005.
2005-04-26 13:08:49 +00:00
Daniel Stenberg
6e61939382 GnuTLS support added. There's now a "generic" SSL layer that we use all over
internally, with code provided by sslgen.c. All SSL-layer-specific code is
then written in ssluse.c (for OpenSSL) and gtls.c (for GnuTLS).

As far as possible, internals should not need to know what SSL layer that is
in use. Building with GnuTLS currently makes two test cases fail.

TODO.gnutls contains a few known outstanding issues for the GnuTLS support.

GnuTLS support is enabled with configure --with-gnutls
2005-04-07 15:27:13 +00:00
Daniel Stenberg
758d9fe852 too late hacking error 2005-04-05 21:14:59 +00:00
Daniel Stenberg
ee44eec3e1 Christophe Legry's fix to grok time-conditoned uploads 2005-04-05 20:59:12 +00:00
Daniel Stenberg
371ef80dc3 When doing FTP-SSL, advance to the next state properly when the response to
AUTH has been received successfully.
2005-03-29 11:43:02 +00:00
Daniel Stenberg
84b4e9ff7c Fixed the FTP response reader function to properly deal with responses split
up in several chunks when read.
2005-03-29 11:35:25 +00:00
Dan Fandrich
efaf688650 Fixed ftp support with uClibc due to differing inet_ntoa_r() behaviour. 2005-03-15 21:00:46 +00:00
Daniel Stenberg
3916d1e6cb silence compiler warnings for mingw win32 builds --enable-debug 2005-03-14 15:43:23 +00:00
Daniel Stenberg
62970da675 Removed security.h since it shadows an include file mingw needs when building
for SSPI support. The contents of the file has been moved into the krb4.h file.
2005-03-14 00:00:45 +00:00
Daniel Stenberg
702664e959 Dominick Meglio reported that using CURLOPT_FILETIME when transferring a FTP
file got a Last-Modified: header written to the data stream, corrupting the
actual data. This was because some conditions from the previous FTP code was
not properly brought into the new FTP code. I fixed and I added test case 520
to verify. (This bug was introduced in 7.13.1)
2005-03-08 08:09:14 +00:00
Daniel Stenberg
aa47ac4c06 Added test case 235 that makes a resumed upload of a file that isn't present
on the remote side. This then converts the operation to an ordinary STOR
upload. This was requested/pointed out by Ignacio Vazquez-Abrams.

It also proved (and I fixed) a bug in the newly rewritten ftp code (and
present in the 7.13.1 release) when trying to resume an upload and the servers
returns an error to the SIZE command. libcurl then loops and sends SIZE
commands infinitely.
2005-03-04 23:52:06 +00:00
Daniel Stenberg
b98faaa8c0 Fixed bad krb4 code. It always tried to use krb4 if built enabled. 2005-02-11 22:50:57 +00:00
Daniel Stenberg
e7cefd684b Removed all uses of strftime() since it uses the localised version of the
week day names and month names and servers don't like that.
2005-02-11 00:03:49 +00:00
Daniel Stenberg
17d61e4f29 typecast assign to ftpport from int to prevent warnings 2005-02-10 07:45:26 +00:00
Gisle Vanem
f5394cccb1 Use CURL_SOCKET_BAD. 2005-02-09 14:01:15 +00:00
Gisle Vanem
64dd9c7656 Handle CURLE_LOGIN_DENIED in strerror.c.
For ftp only?
2005-02-09 13:59:40 +00:00
Daniel Stenberg
16ae0c6466 FD_SET can be big macro, use braces 2005-02-09 13:47:35 +00:00
Daniel Stenberg
6a2e21ec8c FTP code turned into state machine. Not completely yet, but a good start.
The tag 'before_ftp_statemachine' was set just before this commit in case
of future need.
2005-02-09 13:06:40 +00:00
Gisle Vanem
82b93e4945 Don't free too much in freedirs() if realloc() fails. 2005-02-08 12:32:28 +00:00
Daniel Stenberg
29350b363b Eric Vergnaud found a use of an uninitialized variable 2005-02-04 23:43:44 +00:00
Daniel Stenberg
c4ff5eb0ca conn->ip_addr MUST NOT be used on re-used connections 2005-01-29 13:07:16 +00:00
Daniel Stenberg
064bc3ecbc Stephen More pointed out that CURLOPT_FTPPORT and the -P option didn't work
when built ipv6-enabled. I've now made a fix for it. Writing test cases for
custom port strings turned too tricky so unfortunately there's none.
2005-01-28 08:26:36 +00:00
Daniel Stenberg
177dbc7be0 Ian Ford asked about support for the FTP command ACCT, and I discovered it is
present in RFC959... so now (lib)curl supports it as well. --ftp-account and
CURLOPT_FTP_ACCOUNT set the account string. (The server may ask for an account
string after PASS have been sent away. The client responds with "ACCT [account
string]".) Added test case 228 and 229 to verify the functionality. Updated
the test FTP server to support ACCT somewhat.
2005-01-25 22:13:12 +00:00
Daniel Stenberg
7e42cb61f7 FTP third transfer support overhaul. See CHANGES for details. 2005-01-21 09:32:32 +00:00
Daniel Stenberg
3050ae57c0 Stephan Bergmann made libcurl return CURLE_URL_MALFORMAT if an FTP URL
contains %0a or %0d in the user, password or CWD parts. (A future fix would
include doing it for %00 as well - see KNOWN_BUGS for details.) Test case 225
and 226 were added to verify this
2005-01-19 21:56:02 +00:00
Daniel Stenberg
e3d342df96 avoid an extra malloc 2004-12-17 10:09:32 +00:00
Daniel Stenberg
ccf65be0a4 fixed minor memory leak when running out of memory 2004-12-17 09:00:19 +00:00
Daniel Stenberg
7dfef13224 oops, add missing return keyword 2004-12-17 08:58:48 +00:00
Daniel Stenberg
6e1e9caa32 Based on Gisle Vanem's patch: make sure the directory re-use works even when
a URL-encoded path is used.
2004-12-16 22:20:33 +00:00
Daniel Stenberg
8d4ac69175 reduced the number of sub-blocks 2004-12-16 18:18:23 +00:00
Dan Fandrich
a28b32aa45 Make some arrays of pointers const, too. 2004-12-15 02:32:04 +00:00
Daniel Stenberg
fec571f5b0 modified to use the current error code name, not the obsolete one 2004-12-11 22:18:11 +00:00
Daniel Stenberg
c78ee11c41 CURLFTPSSL_ALL should make sure that the transfer fails if the data connection
isn't set to encrypted properly
2004-12-07 10:00:20 +00:00
Daniel Stenberg
35944744f8 Richard Atterer fixed libcurl's way of dealing with the EPSV
response. Previously, libcurl would re-resolve the host name with the new
port number and attempt to connect to that, while it should use the IP from
the control channel. This bug made it hard to EPSV from an FTP server with
multiple IP addresses!
2004-12-05 23:33:33 +00:00
Daniel Stenberg
0966ddafaa As reported in Mandrake's bug tracker bug 12285
(http://qa.mandrakesoft.com/show_bug.cgi?id=12285), when connecting to an
IPv6 host with FTP, --disable-epsv (or --disable-eprt) effectively disables
the ability to transfer a file. Now, when connected to an FTP server with
IPv6, these FTP commands can't be disabled even if asked to with the
available libcurl options.
2004-11-29 21:25:07 +00:00
Daniel Stenberg
a4752673bb typecast the coversion from long to int 2004-11-27 09:27:48 +00:00
Daniel Stenberg
2459e1e268 removed no longer used variable 2004-11-26 08:52:18 +00:00
Daniel Stenberg
bf51f05a50 FTP improvements:
If EPSV, EPRT or LPRT is tried and doesn't work, it will not be retried on
the same server again even if a following request is made using a persistent
connection.

If a second request is made to a server, requesting a file from the same
directory as the previous request operated on, libcurl will no longer make
that long series of CWD commands just to end up on the same spot. Note that
this is only for *exactly* the same dir. There is still room for improvements
to optimize the CWD-sending when the dirs are only slightly different.

Added test 210, 211 and 212 to verify these changes. Had to improve the
test script too and added a new primitive to the test file format.
2004-11-25 22:21:49 +00:00
Daniel Stenberg
1a05a90f1c David Phillips' FD_SETSIZE fix 2004-11-19 08:52:33 +00:00
Daniel Stenberg
24d47a6e07 Paul Nolan fix to make libcurl build nicely on Windows CE 2004-11-02 10:12:22 +00:00
Daniel Stenberg
2730842559 Dan Fandrich's better ifdef for include fix 2004-10-21 08:22:07 +00:00
Daniel Stenberg
21d5aead47 Alexander Krasnostavsky made the CURLOPT_FTP_CREATE_MISSING_DIRS option work
fine even for third party transfers.
2004-10-16 14:06:54 +00:00
Daniel Stenberg
39af394a1c removed tabs and trailing whitespace from source 2004-10-06 07:50:18 +00:00