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

5892 Commits

Author SHA1 Message Date
Rene Bernhardt
4851dafcf1 HTTP auth: fix proxy Negotiate bug
If a proxy offers several Authentication schemes where NTLM and
Negotiate are offered by the proxy and you tell libcurl not to use the
Negotiate scheme then the request never returns when the proxy answers
with its HTTP 407 reply.

It is reproducible by the following steps:

- Use a proxy that offers NTLM and Negotiate ( CURLOPT_PROXY and
CURLOPT_PROXYPORT )

- Tell libcurl NOT to use Negotiate CURL_EASY_SETOPT(CURLOPT_PROXYAUTH,
CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_NTLM )

- Start the request

The call to CURL_EASY_PERFORM never returns. If you switch on debug
logging you can see that libcurl issues a new request As soon as it
received the 407 reply. Instead it should return and set the response
code to 407.

Bug: http://curl.haxx.se/mail/lib-2011-10/0323.html
2011-11-06 17:19:37 +01:00
Yang Tse
73029dca5a ssluse.c: fix calling of OpenSSL's ERR_remove_state(0)
Move calling of ERR_remove_state(0) a.k.a ERR_remove_thread_state(NULL)
from Curl_ossl_close_all() to Curl_ossl_cleanup().

In this way ERR_remove_state(0) is now only called in libcurl by
curl_global_cleanup(). Previously it would get called by functions
curl_easy_cleanup(), curl_multi_cleanup and potentially each time a
connection was removed from a connection cache leading to premature
destruction of OpenSSL's thread local state hash.

Multi-threaded apps using OpenSSL enabled libcurl should still call
function ERR_remove_state(0) or ERR_remove_thread_state(NULL) at the
very end end of threads that do not call curl_global_cleanup().
2011-11-04 13:08:37 +01:00
Yang Tse
6fa6567b92 url.c and file.c: fix OOM triggered segfault 2011-11-03 21:56:51 +01:00
Daniel Stenberg
93e57d0628 rename ftp_ssl: the struct field is used for many protocols
Now called 'use_ssl' instead, which better matches the current CURLOPT
name and since the option is used for all pingpong protocols (at least)
it makes sense to not use 'ftp' in the name.
2011-11-03 09:54:12 +01:00
Daniel Stenberg
a873b95c21 gtls_connect_step1: remove use of deprecated functions
Use gnutls_priority_set_direct() instead of gnutls_protocol_set_priority().

Remove the gnutls_certificate_type_set_priority() use since x509 is the
default certificate type anyway.

Reported by: Vincent Torri
2011-11-02 22:44:22 +01:00
Yang Tse
6bdeca967d url.c and transfer.c: nullify connection pointer when free()'ed 2011-11-02 22:34:41 +01:00
Yang Tse
f7dfe2b87a multi.c: OOM handling fix 2011-11-01 14:38:21 +01:00
Yang Tse
49e3b2e03a setup.h: fix compiler warning 2011-10-31 22:42:43 +01:00
Yang Tse
f5bb370186 gtls.c: gnutls_transport_set_global_errno() deprecated in version 2.12.3 2011-10-29 14:58:50 +02:00
Yang Tse
ddeab48245 multi.c: OOM handling fix
Fix curl_multi_cleanup() segfault when using weird cleanup sequence.
2011-10-27 17:08:02 +02:00
Daniel Stenberg
b0d42da26b multi: start ftp state machine when switching to DO_MORE
This extends the fix from commit d7934b8bd4

When the multi state is changed within the multi_runsingle from DOING to
DO_MORE, we didn't immediately start the FTP state machine again. That
then left the FTP state in FTP_STOP. When curl_multi_fdset() was
subsequently called, the ftp_domore_getsock() function would return the
wrong fd info.

Reported by: Gokhan Sengun
2011-10-27 12:46:29 +02:00
Yang Tse
e8d8843a02 ftp.c: some OOM handling fixes 2011-10-24 20:45:13 +02:00
Daniel Stenberg
d7934b8bd4 curl_multi_fdset: correct fdset with FTP PORT use
After a PORT has been issued, and the multi handle would switch to the
CURLM_STATE_DO_MORE state (which is unique for FTP), libcurl would
return the wrong fdset to wait for when curl_multi_fdset() is
called. The code would blindly assume that it was waiting for a connect
of the second connection, while that isn't true immediately after the
PORT command.

Also, the function multi.c:domore_getsock() was highly FTP-centric and
therefore ugly to keep in protocol-agnostic code. I solved this problem
by introducing a new function pointer in the Curl_handler struct called
domore_getsock() which is only called during the DOMORE state for
protocols that set that pointer.

The new ftp.c:ftp_domore_getsock() function now returns fdset info about
the control connection's command/response handling while such a state is
in use, and goes over to waiting for a writable second connection first
once the commands are done.

The original problem could be seen by running test 525 and checking the
time stamps in the FTP server log. I can verify that this fix at least
fixes this problem.

Bug: http://curl.haxx.se/mail/lib-2011-10/0250.html
Reported by: Gokhan Sengun
2011-10-21 23:36:54 +02:00
Yang Tse
95d23d1ceb file.c: OOM handling fix
file_disconnect() free's resources for multi API
2011-10-21 16:52:17 +02:00
Yang Tse
a4758c3276 multi.c: fix segfault 2011-10-21 16:52:16 +02:00
Dan Fandrich
90fcad63cb Fixed compilation when HTTP or cookies are disabled 2011-10-20 17:54:18 -07:00
Daniel Stenberg
ff0a295cdb Curl_http_input_auth: handle multiple auths in WWW-Authenticate
The fix is pretty much the one Nick Zitzmann provided, just edited to do
the right indent levels and with test case 1204 added to verify the fix.

Bug: http://curl.haxx.se/mail/lib-2011-10/0190.html
Reported by: Nick Zitzmann
2011-10-20 13:12:02 +02:00
Daniel Stenberg
4fa0166173 Curl_smtp_escape_eob: first byte is index 0...
Fix a bug with with commit 2621dd42a4 that happened due to my last
second pre-commit cleanup of the change without proper testing
afterwards!
2011-10-20 13:12:02 +02:00
Tim Harder
8036da870c gtls: only call gnutls_transport_set_lowat with <gnutls-2.12.0
The default lowat level for gnutls-2.12* is set to zero to avoid
unnecessary system calls and the gnutls_transport_set_lowat function has
been totally removed in >=gnutls-3 which causes build failures.

Therefore, the function shouldn't be used except for versions that
require it, <gnutls-2.12.0.
2011-10-20 00:28:29 +02:00
Daniel Stenberg
2621dd42a4 Curl_smtp_escape_eob: fix EOB escaping
As the EOB string can come byte by byte over a series of writes we must
match byte-wise.

Bug: http://curl.haxx.se/mail/lib-2011-10/0172.html
2011-10-20 00:13:09 +02:00
Daniel Stenberg
ecbb08cea3 singleipconnect: unstick the ipv6-connection boolean
Previously the bit was set before the connection was found working so if
it would first fail to an ipv6 address and then connect fine to a IPv4
address the variable would still be TRUE.

Reported by: Thomas L. Shinnick
Bug: http://curl.haxx.se/bug/view.cgi?id=3421912
2011-10-17 23:12:58 +02:00
Kamil Dudka
491c5a497c nss: avoid a SIGSEGV with immature version of NSS
Bug: https://bugzilla.redhat.com/733685
2011-10-17 12:13:44 +02:00
Kamil Dudka
06e6755e87 nss: big cleanup in nss_load_cert() and cert_stuff() 2011-10-17 12:13:42 +02:00
Kamil Dudka
052a08ff59 nss: refactor fmt_nickname() -> dup_nickname()
Do not use artificial nicknames for certificates from files.
2011-10-17 12:11:40 +02:00
Kamil Dudka
f6980bbf24 nss: select client certificates by DER
... instead of nicknames, which are not unique.
2011-10-17 12:11:38 +02:00
Daniel Stenberg
840eff44f2 formdata: ack read callback abort
When doing a multipart formpost with a read callback, and that callback
returns CURL_READFUNC_ABORT, that return code must be properly
propagated back and handled accordingly. Previously it would be handled
as a zero byte read which would cause a hang!

Added test case 587 to verify. It uses the lib554.c source code with a
small ifdef.

Reported by: Anton Bychkov
Bug: http://curl.haxx.se/mail/lib-2011-10/0097.html
2011-10-16 01:09:56 +02:00
Daniel Stenberg
1a416cd27a singleipconnect: don't clobber errno
Save the errno value immediately after a connect() failure so that it
won't get reset to something else before we read it.

Bug: http://curl.haxx.se/mail/lib-2011-10/0066.html
Reported by: Frank Van Uffelen and Fabian Hiernaux
2011-10-15 23:44:28 +02:00
Yang Tse
8af94de50a file.c: fix compiler warning 2011-10-14 18:23:16 +02:00
Yang Tse
1bab38780b url.c: fix endless loop upon transport connection timeout
Jerry Wu detected and provided detailed info about this issue.
2011-10-14 17:34:42 +02:00
Yang Tse
ea12c72d12 curl_gethostname.c: fix signed/unsigned comparison and avoid a double copy
both introduced in 42be24af
2011-10-13 23:00:24 +02:00
Yang Tse
47e4537ac6 curl_ntlm_msgs.c: fix variable shadowing declaration introduced in 185ed340 2011-10-13 22:59:36 +02:00
Marcin Adamski
03adff1eba tftp.c: TFTP timeout and unexpected block adjustments
Set ACK timeout to 5 seconds.

If we are waiting for block X and receive block Y that is the expected one, we
should send ACK and increase X (which is already implemented). Otherwise drop
the packet and don't increase retry counter.
2011-10-13 19:45:36 +02:00
Yang Tse
34770b8ab0 multi.c: OOM handling fixes
Prevent modification of easy handle being added with curl_multi_add_handle()
unless this function actually suceeds.

Run Curl_posttransfer() to allow restoring of SIGPIPE handler when
Curl_connect() fails early in multi_runsingle().
2011-10-13 18:04:56 +02:00
Yang Tse
880cf0bedc url.c: make line shorter than 80 chars 2011-10-13 01:52:56 +02:00
Yang Tse
bff78cc18e OOM handling/cleanup slight adjustments 2011-10-12 21:32:10 +02:00
Yang Tse
584dc8b8af OOM handling/cleanup slight adjustments 2011-10-11 19:41:30 +02:00
Yang Tse
71c9453393 telnet.c: fix compiler warning 2011-10-08 01:27:03 +02:00
Yang Tse
17f48fe879 libcurl: some OOM handling fixes 2011-10-07 20:50:57 +02:00
Yang Tse
b82bd05354 multi.c: OOM handling fixes making torture tests 560 580 581 pass 2011-10-06 20:30:34 +02:00
Daniel Stenberg
ca2c326361 curl_share_cleanup: avoid compiler warning
Move the variable declaration to within the #ifdef
2011-10-04 16:34:45 +02:00
Daniel Stenberg
5c809178c2 struct Curl_share: provide sslsession unconditionally
It makes much nicer and less convuluted code everywhere if this struct
member is always present even when libcurl is built without SSL support.

This reverts parts of commit 15e3e45170
2011-10-04 16:33:07 +02:00
Daniel Stenberg
fa77f54a03 ftp: improved the failed PORT host name resolved error message 2011-10-04 16:24:50 +02:00
Daniel Stenberg
bc007d8ef5 codepolicing 2011-10-03 23:28:17 +02:00
Daniel Stenberg
d0dbd1e98e sspi build fix
define away Curl_ntlm_sspi_cleanup() when no windows SSPI build
2011-10-03 23:28:17 +02:00
Steve Holme
4d327d20c6 smtp: Added support for NTLM authentication
Modified smtp_endofresp() to detect NTLM from the server specified list
of supported authentication mechanisms.

Modified smtp_authenticate() to start the sending of the NTLM data.

Added smtp_auth_ntlm_type1_message() which creates a NTLM type-1
message. This function is used by authenticate() to start the sending
of data and by smtp_state_auth_ntlm_resp() when the AUTH command
doesn't contain the type-1 message as part of the initial response.
This lack of initial response can happen if an OOM error occurs or the
type-1 message is longer than 504 characters. As the main AUTH command
is limited to 512 character the data has to be transmitted in two
parts; one containing the AUTH NTLM and the second containing the
type-1 message.

Added smtp_state_auth_ntlm_type2msg_resp() which handles the incoming
type-2 message and sends an outgoing type-3 message. This type-2
message is sent by the server in response to our type-1 message.

Modified smtp_state_auth_resp() to handle the response to: the AUTH
NTLM without the initial response and the type-2 response.

Modified smtp_disconnect() to cleanup the NTLM SSPI stack.
2011-10-03 23:28:17 +02:00
Steve Holme
185ed3409a Curl_ntlm_create_typeX_message: Added the outlen parameter
Added the output message length as a parameter to both
Curl_ntlm_create_type1_message() and Curl_ntlm_create_type3_message()
for use by future functions that require it.

Updated curl_ntlm.c to cater for the extra parameter on these two
functions.
2011-10-03 23:28:17 +02:00
Steve Holme
d54bcebad4 smtp: General tidy up ready for adding NTLM support
Changed the name of variable l, in several functions, which represents
the length of strings being sent to the server, to len which is more
meaningful and consistent with other code in smtp.c and elsewhere.

Reworked smtp_authenticate() to be simpler and easier to follow.
Variables and now initialised in their definitions and if no username
and password are specified the function sets the state to SMTP_STOP and
returns immediately, rather than being part of a huge if statement.
2011-10-03 23:28:17 +02:00
Steve Holme
56ed07f7df smtp_mail: fixed another memory leak
... introduced in 7f304ab84f
2011-10-03 22:55:25 +02:00
Daniel Stenberg
15e3e45170 share: don't use SSL unless enabled
Don't even declare the struct members for disabled features

Introducing the CURLSHE_NOT_BUILT_IN return code for the share interface
when trying to set a sharing option that has been disabled (or not
enabled) in the library.
2011-10-03 22:35:04 +02:00
Daniel Stenberg
9dd85bced5 multi: progress function abort must close connection
When the progress function returns to cancel the request, we must mark
the connection to get closed and it must do to the DONE state.

do_init() must be called as early as possible so that state variables
for new connections are reset early. We could otherwise see that the old
values were still there when a connection was to be disconnected very
early and it would make it behave wrongly.

Bug: http://curl.haxx.se/mail/lib-2011-10/0006.html
Reported by: Vladimir Grishchenko
2011-10-02 19:28:39 +02:00
Daniel Stenberg
3d19e1eedf multi_runsingle: change state on callback abort
Reported by: Marcin Adamski
Bug: http://curl.haxx.se/mail/lib-2011-09/0329.html
2011-09-30 22:59:50 +02:00
Yang Tse
0c903ea189 Fix SSL disabled builds broken with 'SSL session sharing' commit 5793bc37 2011-09-30 21:09:59 +02:00
Daniel Stenberg
affed6725e smtp_mail: fix memory leak
... introduced in 7f304ab84f
2011-09-29 23:45:36 +02:00
Steve Holme
7f304ab84f smtp_mail: Added support to MAIL FROM for the optional SIZE parameter
The size of the email can now be set via CURLOPT_INFILESIZE. This
allows the email to be rejected by the server, if supported, and the
maximum size has been configured on the server.
2011-09-29 23:15:46 +02:00
Alejandro Alvarez
5793bc370c SSL session sharing support added
With locking, plus test, plus documentation
2011-09-28 23:06:34 +02:00
Guenter Knauf
b4fccc1d8e Added SPNEGO to NetWare build. 2011-09-27 16:02:07 +02:00
Yang Tse
d9f686db88 remove short-lived CURL_WRITEFUNC_OUT_OF_MEMORY 2011-09-26 13:05:42 +02:00
Steve Holme
400055bfaa smtp_connect: use defined buffer length for hostname 2011-09-26 00:01:09 +02:00
Steve Holme
5801ddb85c Curl_ntlm_create_type3_message: Tidied up the use of Curl_gethostname.
Removed the code that striped off the domain name when Curl_gethostname
returned the fully qualified domain name as the function has been
updated to return the un-qualified host name.

Replaced the use of HOSTNAME_MAX as the size of the buffer in the call
to Curl_gethostname with sizeof(host) as this is safer should the buffer
size ever be changed.
2011-09-25 23:59:53 +02:00
Steve Holme
38b5744266 HOSTNAME_MAX: Moved to curl_gethostname.h
Moved HOSTNAME_MAX #define into curl_gethostname.h rather than being
locally defined in curl_gethostname.c, curl_ntlm_msgs.c and smtp.c.
2011-09-25 23:58:47 +02:00
Yang Tse
d2a47021c0 Q&D fix header inclusion order 2011-09-25 19:08:12 +02:00
Yang Tse
119f43360b allow write callbacks to indicate OOM to libcurl
Allow (*curl_write_callback) write callbacks to return
CURL_WRITEFUNC_OUT_OF_MEMORY to properly indicate libcurl of OOM conditions
inside the callback itself.
2011-09-25 19:05:46 +02:00
Daniel Stenberg
2d6796aac5 curl_multi_fdset: avoid FD_SET out of bounds
If a socket is larger than FD_SETSIZE, avoid using FD_SET() on the
platforms where this is possible.

Bug: http://curl.haxx.se/bug/view.cgi?id=3413274
Reported by: Tim Starling
2011-09-25 17:34:12 +02:00
Guenter Knauf
230459dd00 NetWare makefile tweaks to select different builds. 2011-09-25 16:29:08 +02:00
Daniel Stenberg
5f0764870f http header: allow Content-Length to be replaced
In some cases Content-Length: couldn't be replaced by an application

Also, indented some code properly
2011-09-24 00:05:58 +02:00
Daniel Stenberg
40c27e299f Curl_pgrsStartNow: keep HEADERS_OUT set
To avoid that the progress meter headers get output between each
transfer, make sure the bits gets kept when (re-)inited.

Reported by: Christopher Stone
2011-09-22 22:41:06 +02:00
Guenter Knauf
3c3aa09c65 Added NetWare examples makefile. 2011-09-22 14:35:49 +02:00
Yang Tse
01c172f5e8 NTLM_WB: fix disabling of NTLM_WB when NTLM is disabled 2011-09-22 00:24:02 +02:00
Gisle Vanem
322f3d5af7 smtp: without a MAIL_FROM, send blank MAIL FROM
I think curl should ignore this case and smtp.c should test for this.
Since RFC-2821 seems to allow a "null reverse-path". Ref.  "MAIL
FROM:<>" in section 3.7, page 25.
2011-09-21 22:24:45 +02:00
Dave Reisner
c1057fc9aa lib/http: add missing whitespace in verbose output
Example:
* upload completely sent off: 35out of 35 bytes

Should be:
* upload completely sent off: 35 out of 35 bytes
2011-09-21 22:19:53 +02:00
Guenter Knauf
e4172d934d Changed suffix rules to pattern rules.
Suffix rules cannot have any prerequisites of their own.
2011-09-21 03:25:19 +02:00
Guenter Knauf
977825a68c Added dependency so that curlbuild.h is created. 2011-09-21 02:13:18 +02:00
Guenter Knauf
a6b69b64ad Some more MinGW build tweaks.
Added envvars to specify OpenSSL include, libpath and lib.
Added rule to create curlbuild.h from curlbuild.h.dist.
2011-09-21 02:06:05 +02:00
Guenter Knauf
a6c168b893 A bunch of MinGW build tweaks.
All paths to dependencies now quoted; synced examples makefile.
2011-09-20 15:05:28 +02:00
Guenter Knauf
dee7a08f64 Changed Windows 64bit OS define to x86_64.
Also added check for __x86_64__ define since MinGW64 seems to define
the _M_X64 macro through a header not available for config-win32.h.
2011-09-20 12:32:04 +02:00
Guenter Knauf
cd3cf55b47 Also skip certs masked as CKT_NSS_TRUST_UNKNOWN.
Fix posted by Tomas Hoger <thoger redhat com>.
2011-09-20 12:05:31 +02:00
Guenter Knauf
98a61d8e2e Added _WIN32_WINNT define for IPv6 builds. 2011-09-20 11:59:49 +02:00
Daniel Stenberg
81b41095ef Curl_follow: handle redirects to "//hostname/path" 2011-09-20 11:16:40 +02:00
Steve Holme
42be24af89 Curl_gethostname: return un-qualified machine name
Fixed Curl_gethostname() so that it always returns the un-qualified
machine name rather than being dependent on the socket provider.

Note: The return of getenv("CURL_GETHOSTNAME") is also parsed in case
the developer / test harness provided a fully qualified domain name as
it's value as well.
2011-09-18 13:24:58 +02:00
Yang Tse
ff9d858722 Make Curl_safefree() macro assign NULL to given pointer when free'd 2011-09-15 17:35:23 +02:00
Yang Tse
0216e517d0 ftp.c: add a couple of failure messages 2011-09-14 11:30:22 +02:00
warp kawada
aff70e2e95 Curl_add_custom_headers: support headers with no data
A custom HTTP header ending in a semicolon instead of a colon
will be treated as a header to be added without any data
portion.
2011-09-13 16:17:21 -07:00
Daniel Stenberg
73b18a9d24 codestyle: minor whitespace fix 2011-09-13 18:46:09 +02:00
Jeff Pohlmeyer
1bac153ea3 polarssl: build with PolarSSL-1.0.0
With this fix, it should work for PolarSSL-1.0.0 (and SVN-1091 trunk)
and retain compatibility with earlier versions. (Tested with 0.14.1)

PolarSSL still doesn't play nicely with curl's CA bundle (we discussed
this before) but I was at least able to retrieve the
https://www.gmail.com/ login page using a modified ca-certificates.crt
file with all 3 versions of PolarSSL.
2011-09-13 18:44:41 +02:00
Yang Tse
4e9a1c5bba ftp.c: fix socket leak torture tests detected 2011-08-30
Also fix inappropriate error handling when sending ftp EPRT or PORT commands.
2011-09-12 15:16:07 +02:00
Daniel Stenberg
94d64f8d4c spell-checked comments 2011-09-11 19:26:17 +02:00
Guenter Knauf
2a9fec16cc Updated makefiles to latest libssh2. 2011-09-11 16:50:30 +02:00
Yang Tse
72c14bd6f0 ftp.c: fix ftp active connects which got broken with commit fdf157abdf 2011-09-10 05:05:27 +02:00
Yang Tse
a7d8894291 ssh.c: revert needless commit 7b7c45879e 2011-09-10 00:52:13 +02:00
Daniel Stenberg
303c90074d tcpnodelay: rename variable
Renamed the variable from 'proto' to 'level' simply because it is not
protocol you set but level and that is the name of the argument used in
man pages and the POSIX documentation of the setsockopt function.
2011-09-09 15:31:11 +02:00
Yang Tse
7b7c45879e libssh2: use calloc as alloc function for libssh2 versions older than 1.3
This workarounds old libssh2 versions not properly initializing
some ssh session variables, which would trigger memory debuggers
warnings on memory being used without having been initialized.
2011-09-08 11:08:00 +02:00
Adriano Meirelles
81ead2c4e7 Curl_speedcheck: don't mistakenly clear Curl_expire()
The current version of speedcheck.c may disable timeout by setting zero
to Curl_expire. Which is fine using the curl_multi_perform, because it
recheck all timeout internals, but when using custom event poller (like
hiperfifo.c) it may keep stalle connection forever.
2011-09-08 08:39:53 +02:00
Daniel Stenberg
2147492050 ftp_state_use_port: minor code indent fix 2011-09-07 22:46:06 +02:00
Daniel Stenberg
58a7c51362 checksrc: detect "}else" uses as well 2011-09-07 22:45:43 +02:00
Yang Tse
5658aa9574 ssh.c: fix memory leaks triggered upon OOM or other failures 2011-09-07 01:26:43 +02:00
Yang Tse
e9e894905c pingpong.c: avoid a memmove call in function Curl_pp_vsendf 2011-09-05 23:45:04 +02:00
Yang Tse
a50210710a fix bool variables checking and assignment 2011-09-05 20:46:09 +02:00
Guenter Knauf
d52f3eb598 Fixed final message output. 2011-09-04 22:05:32 +02:00
Yang Tse
196e0d699f setup_once.h cleanup and sync 2011-09-04 17:10:51 +02:00
Guenter Knauf
809cde5416 Fix to skip untrusted certs. 2011-09-04 17:05:49 +02:00