Compare commits
90 Commits
curl-7_17_
...
cares-1_5_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d994a873a4 | ||
|
|
b6575ce0b0 | ||
|
|
e2b2a84497 | ||
|
|
86956c2261 | ||
|
|
ef6dfdc7fd | ||
|
|
f3b85ef79d | ||
|
|
1d7e42ee9f | ||
|
|
6dfb5b4e1f | ||
|
|
930085751c | ||
|
|
258c4686b2 | ||
|
|
600d0b1303 | ||
|
|
2f928797cf | ||
|
|
f3f06e823c | ||
|
|
58292f49c5 | ||
|
|
5376d1047c | ||
|
|
1746b57161 | ||
|
|
0561bffab3 | ||
|
|
968e943eac | ||
|
|
5be00c95a7 | ||
|
|
c80b9c3778 | ||
|
|
536f98a766 | ||
|
|
c4e5613a7d | ||
|
|
bff962398d | ||
|
|
2b15823dab | ||
|
|
59dcc7e191 | ||
|
|
ea3fe98867 | ||
|
|
4f05613fbb | ||
|
|
22e52ddd6e | ||
|
|
1125d45397 | ||
|
|
44d408204a | ||
|
|
50feea3eef | ||
|
|
ca95f58ac0 | ||
|
|
ed636cbe44 | ||
|
|
738e4f410c | ||
|
|
4e731a0189 | ||
|
|
5cf6a539fe | ||
|
|
17fde12fb8 | ||
|
|
5c8b973d4f | ||
|
|
b22e03b2b2 | ||
|
|
a2926ebe7c | ||
|
|
c508d70258 | ||
|
|
f5971f54ff | ||
|
|
c5b16d4468 | ||
|
|
3c71a1bab7 | ||
|
|
3ec322685b | ||
|
|
9a39839a43 | ||
|
|
e87c996fe0 | ||
|
|
32195c673d | ||
|
|
b99a61c5b0 | ||
|
|
c960cd41e8 | ||
|
|
a29471d0f7 | ||
|
|
ba6f20a244 | ||
|
|
61572a1f97 | ||
|
|
dee3844f13 | ||
|
|
cbd1a77ec2 | ||
|
|
33f7ac06c3 | ||
|
|
70f10f1ac9 | ||
|
|
775b60fa09 | ||
|
|
66e4d391d3 | ||
|
|
caf880be18 | ||
|
|
c8355c27e9 | ||
|
|
c2d7e2ae17 | ||
|
|
98ecad0da6 | ||
|
|
bbc4e05434 | ||
|
|
ad6e28073c | ||
|
|
af29dcbafb | ||
|
|
b9a7f4e502 | ||
|
|
51009a40b4 | ||
|
|
2ec8f77f21 | ||
|
|
7f62028d66 | ||
|
|
d34fe06fb0 | ||
|
|
2f3d520571 | ||
|
|
48dd0c5673 | ||
|
|
8be493296d | ||
|
|
6f33531861 | ||
|
|
16897354bc | ||
|
|
823a0454a6 | ||
|
|
6790c559af | ||
|
|
c56c4a0a47 | ||
|
|
45064c5778 | ||
|
|
7aba59f577 | ||
|
|
59b05ac383 | ||
|
|
9b15f1be26 | ||
|
|
38cd2d781f | ||
|
|
2f285b3f16 | ||
|
|
57d2fb41d0 | ||
|
|
0f77fe55b6 | ||
|
|
68ee002ad0 | ||
|
|
1fc3b18592 | ||
|
|
5a5287ef2a |
111
CHANGES
111
CHANGES
@@ -6,6 +6,117 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
|
||||||
|
Daniel S (21 Nov 2007)
|
||||||
|
- While inspecting the Negotiate code, I noticed how the proxy auth was using
|
||||||
|
the same state struct as the host auth, so both could never be used at the
|
||||||
|
same time! I fixed it (without being able to check) to use two separate
|
||||||
|
structs to allow authentication using Negotiate on host and proxy
|
||||||
|
simultanouesly.
|
||||||
|
|
||||||
|
Daniel S (20 Nov 2007)
|
||||||
|
- Emil Romanus pointed out a bug that made an easy handle get the cookie
|
||||||
|
engine activated when set to use a share (even if the share doesn't share
|
||||||
|
cookies). I fixed it.
|
||||||
|
|
||||||
|
- Fixed a very long-lasting mprintf() bug that occured when we did "%.*s%s",
|
||||||
|
since the second %s would then wrongly used the numerical precision argument
|
||||||
|
instead and crash.
|
||||||
|
|
||||||
|
- Introuced --data-urlencode to the curl tool for easier url encoding of the
|
||||||
|
data sent in a post.
|
||||||
|
|
||||||
|
Daniel S (18 Nov 2007)
|
||||||
|
- Rob Crittenden fixed SSL connections with NSS done with the multi-interface
|
||||||
|
|
||||||
|
Daniel S (17 Nov 2007)
|
||||||
|
- Michal Marek made the test suite remember what test servers that fail to
|
||||||
|
start so that subsequent tries are simply skipped.
|
||||||
|
|
||||||
|
- Andres Garcia made the examples build fine on Windows (mingw + msys) when
|
||||||
|
the lib was built staticly.
|
||||||
|
|
||||||
|
Daniel S (16 Nov 2007)
|
||||||
|
- Ates Goral identified a problem in http.c:add_buffer_send() when a debug
|
||||||
|
callback was used, as it could wrongly pass on a bad size for the outgoing
|
||||||
|
HTTP header. The bad size would be a very large value as it was a wrapped
|
||||||
|
size_t content. This happened when the whole HTTP request failed to get sent
|
||||||
|
in one single send. http://curl.haxx.se/mail/lib-2007-11/0165.html
|
||||||
|
|
||||||
|
Daniel S (15 Nov 2007)
|
||||||
|
- Fixed yet another remaining problem with doing SFTP directory listings on a
|
||||||
|
re-used persistent connection. Mentioned by Immanuel Gregoire on the mailing
|
||||||
|
list.
|
||||||
|
|
||||||
|
- Michal Marek fixed the test suite to better deal with the case when the HTTP
|
||||||
|
ipv6 server can't run.
|
||||||
|
|
||||||
|
Yang Tse (14 Nov 2007)
|
||||||
|
- Fix a variable potential wrapping in add_buffer() when using absolutely
|
||||||
|
huge send buffer sizes.
|
||||||
|
|
||||||
|
Daniel S (13 Nov 2007)
|
||||||
|
- Fixed a remaining problem with doing SFTP directory listings on a re-used
|
||||||
|
persistent connection. Mentioned by Immanuel Gregoire on the mailing list.
|
||||||
|
|
||||||
|
Daniel S (12 Nov 2007)
|
||||||
|
- Bug report #1830637 (http://curl.haxx.se/bug/view.cgi?id=1830637), which was
|
||||||
|
forwarded from the Gentoo bug tracker by Daniel Black and was originally
|
||||||
|
submitted by Robin Johnson, pointed out that libcurl would do bad memory
|
||||||
|
references when it failed and bailed out before the handler thing was
|
||||||
|
setup. My fix is not done like the provided patch does it, but instead I
|
||||||
|
make sure that there's never any chance for a NULL pointer in that struct
|
||||||
|
member.
|
||||||
|
|
||||||
|
Daniel S (8 Nov 2007)
|
||||||
|
- Bug report #1823487 (http://curl.haxx.se/bug/view.cgi?id=1823487) pointed
|
||||||
|
out that SFTP requests didn't use persistent connections. Neither did SCP
|
||||||
|
ones. I gave the SSH code a good beating and now both SCP and SFTP should
|
||||||
|
use persistent connections fine. I also did a bunch of indent changes as
|
||||||
|
well as a bug fix for the "keyboard interactive" auth.
|
||||||
|
|
||||||
|
Dan F (6 Nov 2007)
|
||||||
|
- Improved telnet support by drastically reducing the number of write
|
||||||
|
callbacks needed to pass a buffer to the user. Instead one per byte it
|
||||||
|
is now as little as one per segment.
|
||||||
|
|
||||||
|
Yang Tse (6 Nov 2007)
|
||||||
|
- Bug report #1824894 (http://curl.haxx.se/bug/view.cgi?id=1824894) pointed
|
||||||
|
out a problem in curl.h when building C++ apps with MSVC. To fix it, the
|
||||||
|
inclusion of header files in curl.h is moved outside of the C++ extern "C"
|
||||||
|
linkage block.
|
||||||
|
|
||||||
|
Daniel S (1 Nov 2007)
|
||||||
|
- Toby Peterson patched a memory problem in the command line tool that
|
||||||
|
happened when a user had a home dir as an empty string. curl would then do
|
||||||
|
free() on a wrong area.
|
||||||
|
|
||||||
|
Dan F (1 Nov 2007)
|
||||||
|
- Fixed curl-config --features to not display libz when it wasn't used
|
||||||
|
due to a missing header file.
|
||||||
|
|
||||||
|
Dan F (31 October 2007)
|
||||||
|
- Fixed the output of curl-config --protocols which showed SCP and SFTP
|
||||||
|
always, except when --without-libssh2 was given
|
||||||
|
|
||||||
|
- Added test cases 1013 and 1014 to check that curl-config --protocols and
|
||||||
|
curl-config --features matches the output of curl --version
|
||||||
|
|
||||||
|
Dan F (30 October 2007)
|
||||||
|
- Fixed an OOM problem with file: URLs
|
||||||
|
|
||||||
|
- Moved Curl_file_connect into the protocol handler struct
|
||||||
|
|
||||||
|
Dan F (29 October 2007)
|
||||||
|
- Added test case 546 to check that subsequent FTP transfers work after a
|
||||||
|
failed one using the multi interface
|
||||||
|
|
||||||
|
Daniel S (29 October 2007)
|
||||||
|
- Based on one of those bug reports that are intercepted by a distro's bug
|
||||||
|
tracker (https://bugzilla.redhat.com/show_bug.cgi?id=316191), I now made
|
||||||
|
curl-config --features and --protocols show the correct output when built
|
||||||
|
with NSS.
|
||||||
|
|
||||||
Version 7.17.1 (29 October 2007)
|
Version 7.17.1 (29 October 2007)
|
||||||
|
|
||||||
Dan F (25 October 2007)
|
Dan F (25 October 2007)
|
||||||
|
|||||||
@@ -1,53 +1,31 @@
|
|||||||
Curl and libcurl 7.17.1
|
Curl and libcurl 7.17.2
|
||||||
|
|
||||||
Public curl release number: 102
|
Public curl releases: 103
|
||||||
Releases counted from the very beginning: 128
|
Command line options: 122
|
||||||
Available command line options: 121
|
curl_easy_setopt() options: 147
|
||||||
Available curl_easy_setopt() options: 147
|
Public functions in libcurl: 55
|
||||||
Number of public functions in libcurl: 55
|
Public web site mirrors: 42
|
||||||
Amount of public web site mirrors: 43
|
Known libcurl bindings: 36
|
||||||
Number of known libcurl bindings: 36
|
Contributors: 597
|
||||||
Number of contributors: 588
|
|
||||||
|
|
||||||
This release includes the following changes:
|
This release includes the following changes:
|
||||||
|
|
||||||
o automatically append ";type=<a|i>" when using HTTP proxies for FTP urls
|
o --data-urlencode was added
|
||||||
o improved NSS support
|
|
||||||
o added --proxy-negotiate
|
|
||||||
o added --post301 and CURLOPT_POST301
|
|
||||||
o builds with c-ares 1.5.0
|
|
||||||
o added CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 and --hostpubmd5
|
|
||||||
o renamed CURLE_SSL_PEER_CERTIFICATE to CURLE_PEER_FAILED_VERIFICATION
|
|
||||||
o added CURLOPT_OPENSOCKETFUNCTION and CURLOPT_OPENSOCKETDATA
|
|
||||||
o CULROPT_COOKIELIST supports "FLUSH"
|
|
||||||
o added CURLOPT_COPYPOSTFIELDS
|
|
||||||
o added --static-libs to curl-config
|
|
||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
o curl-config --protocols now properly reports LDAPS, SCP and SFTP
|
o curl-config --features and --protocols show the correct output when built
|
||||||
o ldapv3 support on Windows
|
with NSS, and also when SCP, SFTP and libz are not available
|
||||||
o ldap builds with the MSVC makefiles
|
o free problem in the curl tool for users with empty home dir
|
||||||
o no HOME and no key given caused SSH auth failure
|
o curl.h version 7.17.1 problem when building C++ apps with MSVC
|
||||||
o Negotiate authentication over proxy
|
o SFTP and SCP use persistent connections
|
||||||
o --ftp-method nocwd on directory listings
|
o segfault on bad URL
|
||||||
o FTP, CURLOPT_NOBODY enabled and CURLOPT_HEADER disabled now does TYPE
|
o variable wrapping when using absolutely huge send buffer sizes
|
||||||
before SIZE
|
o variable wrapping when using debug callback and the HTTP request wasn't sent
|
||||||
o re-used handle transfers with SFTP
|
in one go
|
||||||
o curl_easy_escape() problem with byte values >= 128
|
o SSL connections with NSS done with the multi-interface
|
||||||
o handles chunked-encoded CONNECT responses
|
o setting a share no longer activates cookies
|
||||||
o misuse of ares_timeout() result
|
o Negotiate now works on auth and proxy simultanouesly
|
||||||
o --local-port on TFTP transfers
|
|
||||||
o CURLOPT_POSTFIELDS could fail to send binary data
|
|
||||||
o specifying a proxy with a trailing slash didn't work (unless it also
|
|
||||||
contained a port number)
|
|
||||||
o redirect from HTTP to FTP or TFTP memory problems and leaks
|
|
||||||
o re-used connections a bit too much when using non-SSL protocols tunneled
|
|
||||||
over a HTTP proxy
|
|
||||||
o embed the manifest in VC8 builds
|
|
||||||
o use valgrind in the tests even when the lib is built shared with libtool
|
|
||||||
o libcurl built with NSS can now ignore the peer verification even when the
|
|
||||||
ca cert bundle is absent
|
|
||||||
|
|
||||||
This release includes the following known bugs:
|
This release includes the following known bugs:
|
||||||
|
|
||||||
@@ -55,18 +33,18 @@ This release includes the following known bugs:
|
|||||||
|
|
||||||
Other curl-related news:
|
Other curl-related news:
|
||||||
|
|
||||||
o
|
o TclCurl 7.17.1 => http://personal1.iddeo.es/andresgarci/tclcurl/english/
|
||||||
|
o Ruby Curl::Multi 0.1 => http://curl-multi.rubyforge.org/
|
||||||
|
|
||||||
New curl mirrors:
|
New curl mirrors:
|
||||||
|
|
||||||
o http://curl.wetzlmayr.at/ is a new web mirror in Nuremberg, Germany
|
o http://curl.gominet.net/ is new web mirror in Vizcaya, Portugal
|
||||||
|
|
||||||
This release would not have looked like this without help, code, reports and
|
This release would not have looked like this without help, code, reports and
|
||||||
advice from friends like these:
|
advice from friends like these:
|
||||||
|
|
||||||
Dan Fandrich, Michal Marek, G<>nter Knauf, Rob Crittenden, Immanuel Gregoire,
|
Dan Fandrich, Gisle Vanem, Toby Peterson, Yang Tse, Daniel Black,
|
||||||
Mark Davies, Max Katsev, Philip Langdale, Alex Fishman, Johnny Luong,
|
Robin Johnson, Michal Marek, Ates Goral, Andres Garcia, Rob Crittenden,
|
||||||
Alexey Pesternikov, Yang Tse, Kim Rinnewitz, Michael Wallner,
|
Emil Romanus
|
||||||
Patrick Monnerat, Vladimir Lazarenko
|
|
||||||
|
|
||||||
Thanks! (and sorry if I forgot to mention someone)
|
Thanks! (and sorry if I forgot to mention someone)
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
To be addressed before 7.17.1 (planned release: late October 2007)
|
To be addressed before 7.17.2 (planned release: December 2007)
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
106 -
|
107 - resolve the type= thing for FTP URLs over HTTP proxies
|
||||||
|
|
||||||
|
108 -
|
||||||
|
|||||||
@@ -300,7 +300,6 @@ ifeq ($(LIBARCH),CLIB)
|
|||||||
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
||||||
@echo $(DL)#define DL_LDAP_FILE "ldapsdk.nlm"$(DL) >> $@
|
|
||||||
@echo $(DL)#define socklen_t int$(DL) >> $@
|
@echo $(DL)#define socklen_t int$(DL) >> $@
|
||||||
@echo $(DL)#define strncasecmp strnicmp$(DL) >> $@
|
@echo $(DL)#define strncasecmp strnicmp$(DL) >> $@
|
||||||
@echo $(DL)#define strcasecmp stricmp$(DL) >> $@
|
@echo $(DL)#define strcasecmp stricmp$(DL) >> $@
|
||||||
@@ -338,7 +337,6 @@ else
|
|||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
||||||
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
||||||
@echo $(DL)#define DL_LDAP_FILE "lldapsdk.nlm"$(DL) >> $@
|
|
||||||
endif
|
endif
|
||||||
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_ARPA_NAMESER_H 1$(DL) >> $@
|
@echo $(DL)#define HAVE_ARPA_NAMESER_H 1$(DL) >> $@
|
||||||
|
|||||||
@@ -1,9 +1,26 @@
|
|||||||
This is what's new and changed in the c-ares 1.4.1 release:
|
This is what's new and changed in the c-ares 1.5.0 release:
|
||||||
|
|
||||||
o
|
o SONAME bump to a few API and ABI breaking changes:
|
||||||
|
- ares_host_callback()
|
||||||
|
- ares_nameinfo_callback()
|
||||||
|
- ares_parse_a_reply()
|
||||||
|
- ares_parse_aaaa_reply()
|
||||||
|
|
||||||
|
o two valgrind reports were silenced
|
||||||
|
o ares_save_options() fix
|
||||||
|
o do DNS retries even on TCP connections
|
||||||
|
o correctly clear sockets from the fd_set in several functions
|
||||||
|
o always wait on TCP events to detect connect closures
|
||||||
|
o new socket options: ARES_OPT_SOCK_SNDBUF and ARES_OPT_SOCK_RCVBUF
|
||||||
|
o made the query callbacks receive the number of timeouts that happened during
|
||||||
|
the execution of a query
|
||||||
|
o don't skip a server if it's the only one
|
||||||
|
o segfault when generating a DNS "Transaction ID" under low memory conditions
|
||||||
|
o ares_strerror() segfault fix
|
||||||
|
o added copyright texts to a few places that were missing them
|
||||||
|
|
||||||
Thanks go to these friendly people for their efforts and contributions:
|
Thanks go to these friendly people for their efforts and contributions:
|
||||||
|
|
||||||
|
Vlad Dinulescu, Brad House, Steinar H. Gunderson, Yang Tse
|
||||||
|
|
||||||
Have fun!
|
Have fun!
|
||||||
|
|||||||
@@ -40,13 +40,6 @@
|
|||||||
#include "inet_net_pton.h"
|
#include "inet_net_pton.h"
|
||||||
#include "ares_getopt.h"
|
#include "ares_getopt.h"
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
|
||||||
struct in6_addr
|
|
||||||
{
|
|
||||||
unsigned char s6_addr[16];
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
static void callback(void *arg, int status, int timeouts, struct hostent *host);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
|
||||||
|
|||||||
48
ares/ares.h
48
ares/ares.h
@@ -18,6 +18,14 @@
|
|||||||
#ifndef ARES__H
|
#ifndef ARES__H
|
||||||
#define ARES__H
|
#define ARES__H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define WIN32 when build target is Win32 API
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||||
|
#define WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if defined(_AIX) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
|
#if defined(_AIX) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
|
||||||
@@ -35,8 +43,12 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <tcp.h>
|
#include <tcp.h>
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
#include <winsock2.h>
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
|
# include <windows.h>
|
||||||
|
# include <winsock2.h>
|
||||||
|
# include <ws2tcpip.h>
|
||||||
#else
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -232,10 +244,38 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
|
|||||||
int alen, char **s, long *enclen);
|
int alen, char **s, long *enclen);
|
||||||
int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf,
|
int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf,
|
||||||
int alen, unsigned char **s, long *enclen);
|
int alen, unsigned char **s, long *enclen);
|
||||||
|
|
||||||
|
#ifndef s6_addr
|
||||||
|
struct in6_addr {
|
||||||
|
union {
|
||||||
|
unsigned char _S6_u8[16];
|
||||||
|
} _S6_un;
|
||||||
|
};
|
||||||
|
#define s6_addr _S6_un._S6_u8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct addrttl {
|
||||||
|
struct in_addr ipaddr;
|
||||||
|
int ttl;
|
||||||
|
};
|
||||||
|
struct addr6ttl {
|
||||||
|
struct in6_addr ip6addr;
|
||||||
|
int ttl;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Parse the buffer, starting at *abuf and of length alen bytes, previously
|
||||||
|
** obtained from an ares_search call. Put the results in *host, if nonnull.
|
||||||
|
** Also, if addrttls is nonnull, put up to *naddrttls IPv4 addresses along with
|
||||||
|
** their TTLs in that array, and set *naddrttls to the number of addresses
|
||||||
|
** so written.
|
||||||
|
*/
|
||||||
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||||
struct hostent **host);
|
struct hostent **host,
|
||||||
|
struct addrttl *addrttls, int *naddrttls);
|
||||||
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||||
struct hostent **host);
|
struct hostent **host,
|
||||||
|
struct addr6ttl *addrttls, int *naddrttls);
|
||||||
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
||||||
int addrlen, int family, struct hostent **host);
|
int addrlen, int family, struct hostent **host);
|
||||||
int ares_parse_ns_reply(const unsigned char *abuf, int alen,
|
int ares_parse_ns_reply(const unsigned char *abuf, int alen,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ struct host_query {
|
|||||||
int timeouts;
|
int timeouts;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void next_lookup(struct host_query *hquery, int status);
|
static void next_lookup(struct host_query *hquery, int status_code);
|
||||||
static void host_callback(void *arg, int status, int timeouts,
|
static void host_callback(void *arg, int status, int timeouts,
|
||||||
unsigned char *abuf, int alen);
|
unsigned char *abuf, int alen);
|
||||||
static void end_hquery(struct host_query *hquery, int status,
|
static void end_hquery(struct host_query *hquery, int status,
|
||||||
@@ -111,13 +111,14 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
|
|||||||
hquery->timeouts = 0;
|
hquery->timeouts = 0;
|
||||||
|
|
||||||
/* Start performing lookups according to channel->lookups. */
|
/* Start performing lookups according to channel->lookups. */
|
||||||
next_lookup(hquery, ARES_SUCCESS);
|
next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void next_lookup(struct host_query *hquery, int status)
|
static void next_lookup(struct host_query *hquery, int status_code)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
struct hostent *host;
|
struct hostent *host;
|
||||||
|
int status = status_code;
|
||||||
|
|
||||||
for (p = hquery->remaining_lookups; *p; p++)
|
for (p = hquery->remaining_lookups; *p; p++)
|
||||||
{
|
{
|
||||||
@@ -142,6 +143,7 @@ static void next_lookup(struct host_query *hquery, int status)
|
|||||||
end_hquery(hquery, status, host);
|
end_hquery(hquery, status, host);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
status = status_code; /* Use original status code */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,13 +162,13 @@ static void host_callback(void *arg, int status, int timeouts,
|
|||||||
{
|
{
|
||||||
if (hquery->family == AF_INET)
|
if (hquery->family == AF_INET)
|
||||||
{
|
{
|
||||||
status = ares_parse_a_reply(abuf, alen, &host);
|
status = ares_parse_a_reply(abuf, alen, &host, NULL, NULL);
|
||||||
if (host && channel->nsort)
|
if (host && channel->nsort)
|
||||||
sort_addresses(host, channel->sortlist, channel->nsort);
|
sort_addresses(host, channel->sortlist, channel->nsort);
|
||||||
}
|
}
|
||||||
else if (hquery->family == AF_INET6)
|
else if (hquery->family == AF_INET6)
|
||||||
{
|
{
|
||||||
status = ares_parse_aaaa_reply(abuf, alen, &host);
|
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
|
||||||
if (host && channel->nsort)
|
if (host && channel->nsort)
|
||||||
sort6_addresses(host, channel->sortlist, channel->nsort);
|
sort6_addresses(host, channel->sortlist, channel->nsort);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/* Copyright (C) 2005 by Dominick Meglio
|
||||||
|
*
|
||||||
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
||||||
* software and its documentation for any purpose and without
|
* software and its documentation for any purpose and without
|
||||||
* fee is hereby granted, provided that the above copyright
|
* fee is hereby granted, provided that the above copyright
|
||||||
@@ -21,11 +22,13 @@
|
|||||||
#define PF_INET6 AF_INET6
|
#define PF_INET6 AF_INET6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
#ifndef s6_addr
|
||||||
struct in6_addr
|
struct in6_addr {
|
||||||
{
|
union {
|
||||||
unsigned char s6_addr[16];
|
unsigned char _S6_u8[16];
|
||||||
|
} _S6_un;
|
||||||
};
|
};
|
||||||
|
#define s6_addr _S6_un._S6_u8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
||||||
|
|||||||
@@ -22,24 +22,39 @@ ares_parse_a_reply \- Parse a reply to a DNS query of type A into a hostent
|
|||||||
.B #include <ares.h>
|
.B #include <ares.h>
|
||||||
.PP
|
.PP
|
||||||
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
.B int ares_parse_a_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
||||||
.B struct hostent **\fIhost\fP);
|
.B struct hostent **\fIhost\fP,
|
||||||
|
.B struct addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
The
|
The
|
||||||
.B ares_parse_a_reply
|
.B ares_parse_a_reply
|
||||||
function parses the response to a query of type A into a
|
function parses the response to a query of type A into a
|
||||||
.BR "struct hostent" .
|
.BR "struct hostent"
|
||||||
|
and/or an array of
|
||||||
|
.BR "struct addrttls" .
|
||||||
The parameters
|
The parameters
|
||||||
.I abuf
|
.I abuf
|
||||||
and
|
and
|
||||||
.I alen
|
.I alen
|
||||||
give the contents of the response. The result is stored in allocated
|
give the contents of the response. The result is stored in allocated
|
||||||
memory and a pointer to it stored into the variable pointed to by
|
memory and a pointer to it stored into the variable pointed to by
|
||||||
.IR host .
|
.IR host ,
|
||||||
|
if host is nonnull.
|
||||||
It is the caller's responsibility to free the resulting host structure
|
It is the caller's responsibility to free the resulting host structure
|
||||||
using
|
using
|
||||||
.BR ares_free_hostent (3)
|
.BR ares_free_hostent (3)
|
||||||
when it is no longer needed.
|
when it is no longer needed.
|
||||||
|
.PP
|
||||||
|
If
|
||||||
|
.IR addrttls
|
||||||
|
and
|
||||||
|
.IR naddrttls
|
||||||
|
are both nonnull,
|
||||||
|
then up to *naddrttls
|
||||||
|
.BR "struct addrttl"
|
||||||
|
records are stored in the array pointed to by addrttls,
|
||||||
|
and then *naddrttls is set to the number of records so stored.
|
||||||
|
Note that the memory for these records is supplied by the caller.
|
||||||
.SH RETURN VALUES
|
.SH RETURN VALUES
|
||||||
.B ares_parse_a_reply
|
.B ares_parse_a_reply
|
||||||
can return any of the following values:
|
can return any of the following values:
|
||||||
|
|||||||
@@ -32,24 +32,32 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "ares.h"
|
#include "ares.h"
|
||||||
#include "ares_dns.h"
|
#include "ares_dns.h"
|
||||||
#include "ares_private.h"
|
#include "ares_private.h"
|
||||||
|
|
||||||
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
||||||
struct hostent **host)
|
struct hostent **host,
|
||||||
|
struct addrttl *addrttls, int *naddrttls)
|
||||||
{
|
{
|
||||||
unsigned int qdcount, ancount;
|
unsigned int qdcount, ancount;
|
||||||
int status, i, rr_type, rr_class, rr_len, naddrs;
|
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
|
||||||
|
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
|
||||||
int naliases;
|
int naliases;
|
||||||
long len;
|
long len;
|
||||||
const unsigned char *aptr;
|
const unsigned char *aptr;
|
||||||
char *hostname, *rr_name, *rr_data, **aliases;
|
char *hostname, *rr_name, *rr_data, **aliases;
|
||||||
struct in_addr *addrs;
|
struct in_addr *addrs;
|
||||||
struct hostent *hostent;
|
struct hostent *hostent;
|
||||||
|
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
/* Set *host to NULL for all failure cases. */
|
||||||
*host = NULL;
|
if (host)
|
||||||
|
*host = NULL;
|
||||||
|
/* Same with *naddrttls. */
|
||||||
|
if (naddrttls)
|
||||||
|
*naddrttls = 0;
|
||||||
|
|
||||||
/* Give up if abuf doesn't have room for a header. */
|
/* Give up if abuf doesn't have room for a header. */
|
||||||
if (alen < HFIXEDSZ)
|
if (alen < HFIXEDSZ)
|
||||||
@@ -73,20 +81,29 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|||||||
}
|
}
|
||||||
aptr += len + QFIXEDSZ;
|
aptr += len + QFIXEDSZ;
|
||||||
|
|
||||||
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
if (host)
|
||||||
addrs = malloc(ancount * sizeof(struct in_addr));
|
|
||||||
if (!addrs)
|
|
||||||
{
|
{
|
||||||
free(hostname);
|
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
||||||
return ARES_ENOMEM;
|
addrs = malloc(ancount * sizeof(struct in_addr));
|
||||||
|
if (!addrs)
|
||||||
|
{
|
||||||
|
free(hostname);
|
||||||
|
return ARES_ENOMEM;
|
||||||
|
}
|
||||||
|
aliases = malloc((ancount + 1) * sizeof(char *));
|
||||||
|
if (!aliases)
|
||||||
|
{
|
||||||
|
free(hostname);
|
||||||
|
free(addrs);
|
||||||
|
return ARES_ENOMEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
else
|
||||||
if (!aliases)
|
|
||||||
{
|
{
|
||||||
free(hostname);
|
addrs = NULL;
|
||||||
free(addrs);
|
aliases = NULL;
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
naddrs = 0;
|
naddrs = 0;
|
||||||
naliases = 0;
|
naliases = 0;
|
||||||
|
|
||||||
@@ -106,13 +123,33 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|||||||
rr_type = DNS_RR_TYPE(aptr);
|
rr_type = DNS_RR_TYPE(aptr);
|
||||||
rr_class = DNS_RR_CLASS(aptr);
|
rr_class = DNS_RR_CLASS(aptr);
|
||||||
rr_len = DNS_RR_LEN(aptr);
|
rr_len = DNS_RR_LEN(aptr);
|
||||||
|
rr_ttl = DNS_RR_TTL(aptr);
|
||||||
aptr += RRFIXEDSZ;
|
aptr += RRFIXEDSZ;
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_A
|
if (rr_class == C_IN && rr_type == T_A
|
||||||
&& rr_len == sizeof(struct in_addr)
|
&& rr_len == sizeof(struct in_addr)
|
||||||
&& strcasecmp(rr_name, hostname) == 0)
|
&& strcasecmp(rr_name, hostname) == 0)
|
||||||
{
|
{
|
||||||
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
|
if (addrs)
|
||||||
|
{
|
||||||
|
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
||||||
|
{
|
||||||
|
status = ARES_EBADRESP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
|
||||||
|
}
|
||||||
|
if (naddrs < max_addr_ttls)
|
||||||
|
{
|
||||||
|
struct addrttl * const at = &addrttls[naddrs];
|
||||||
|
if (aptr + sizeof(struct in_addr) > abuf + alen)
|
||||||
|
{
|
||||||
|
status = ARES_EBADRESP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
|
||||||
|
at->ttl = rr_ttl;
|
||||||
|
}
|
||||||
naddrs++;
|
naddrs++;
|
||||||
status = ARES_SUCCESS;
|
status = ARES_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -120,7 +157,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|||||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
if (rr_class == C_IN && rr_type == T_CNAME)
|
||||||
{
|
{
|
||||||
/* Record the RR name as an alias. */
|
/* Record the RR name as an alias. */
|
||||||
aliases[naliases] = rr_name;
|
if (aliases)
|
||||||
|
aliases[naliases] = rr_name;
|
||||||
|
else
|
||||||
|
free(rr_name);
|
||||||
naliases++;
|
naliases++;
|
||||||
|
|
||||||
/* Decode the RR data and replace the hostname with it. */
|
/* Decode the RR data and replace the hostname with it. */
|
||||||
@@ -129,6 +169,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|||||||
break;
|
break;
|
||||||
free(hostname);
|
free(hostname);
|
||||||
hostname = rr_data;
|
hostname = rr_data;
|
||||||
|
|
||||||
|
/* Take the min of the TTLs we see in the CNAME chain. */
|
||||||
|
if (cname_ttl > rr_ttl)
|
||||||
|
cname_ttl = rr_ttl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
free(rr_name);
|
free(rr_name);
|
||||||
@@ -145,32 +189,51 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
|
|||||||
status = ARES_ENODATA;
|
status = ARES_ENODATA;
|
||||||
if (status == ARES_SUCCESS)
|
if (status == ARES_SUCCESS)
|
||||||
{
|
{
|
||||||
/* We got our answer. Allocate memory to build the host entry. */
|
/* We got our answer. */
|
||||||
aliases[naliases] = NULL;
|
if (naddrttls)
|
||||||
hostent = malloc(sizeof(struct hostent));
|
|
||||||
if (hostent)
|
|
||||||
{
|
{
|
||||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
|
||||||
if (hostent->h_addr_list)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
/* Fill in the hostent and return successfully. */
|
/* Ensure that each A TTL is no larger than the CNAME TTL. */
|
||||||
hostent->h_name = hostname;
|
if (addrttls[i].ttl > cname_ttl)
|
||||||
hostent->h_aliases = aliases;
|
addrttls[i].ttl = cname_ttl;
|
||||||
hostent->h_addrtype = AF_INET;
|
|
||||||
hostent->h_length = sizeof(struct in_addr);
|
|
||||||
for (i = 0; i < naddrs; i++)
|
|
||||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
|
||||||
hostent->h_addr_list[naddrs] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
}
|
||||||
free(hostent);
|
*naddrttls = n;
|
||||||
}
|
}
|
||||||
status = ARES_ENOMEM;
|
if (aliases)
|
||||||
|
aliases[naliases] = NULL;
|
||||||
|
if (host)
|
||||||
|
{
|
||||||
|
/* Allocate memory to build the host entry. */
|
||||||
|
hostent = malloc(sizeof(struct hostent));
|
||||||
|
if (hostent)
|
||||||
|
{
|
||||||
|
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
||||||
|
if (hostent->h_addr_list)
|
||||||
|
{
|
||||||
|
/* Fill in the hostent and return successfully. */
|
||||||
|
hostent->h_name = hostname;
|
||||||
|
hostent->h_aliases = aliases;
|
||||||
|
hostent->h_addrtype = AF_INET;
|
||||||
|
hostent->h_length = sizeof(struct in_addr);
|
||||||
|
for (i = 0; i < naddrs; i++)
|
||||||
|
hostent->h_addr_list[i] = (char *) &addrs[i];
|
||||||
|
hostent->h_addr_list[naddrs] = NULL;
|
||||||
|
*host = hostent;
|
||||||
|
return ARES_SUCCESS;
|
||||||
|
}
|
||||||
|
free(hostent);
|
||||||
|
}
|
||||||
|
status = ARES_ENOMEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aliases)
|
||||||
|
{
|
||||||
|
for (i = 0; i < naliases; i++)
|
||||||
|
free(aliases[i]);
|
||||||
|
free(aliases);
|
||||||
}
|
}
|
||||||
for (i = 0; i < naliases; i++)
|
|
||||||
free(aliases[i]);
|
|
||||||
free(aliases);
|
|
||||||
free(addrs);
|
free(addrs);
|
||||||
free(hostname);
|
free(hostname);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -22,24 +22,39 @@ ares_parse_aaaa_reply \- Parse a reply to a DNS query of type AAAA into a hosten
|
|||||||
.B #include <ares.h>
|
.B #include <ares.h>
|
||||||
.PP
|
.PP
|
||||||
.B int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
.B int ares_parse_aaaa_reply(const unsigned char *\fIabuf\fP, int \fIalen\fP,
|
||||||
.B struct hostent **\fIhost\fP);
|
.B struct hostent **\fIhost\fP,
|
||||||
|
.B struct addrttl *\fIaddrttls\fB, int *\fInaddrttls\fB);
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
The
|
The
|
||||||
.B ares_parse_aaaa_reply
|
.B ares_parse_aaaa_reply
|
||||||
function parses the response to a query of type AAAA into a
|
function parses the response to a query of type AAAA into a
|
||||||
.BR "struct hostent" .
|
.BR "struct hostent"
|
||||||
|
and/or an array of
|
||||||
|
.BR "struct addrttls" .
|
||||||
The parameters
|
The parameters
|
||||||
.I abuf
|
.I abuf
|
||||||
and
|
and
|
||||||
.I alen
|
.I alen
|
||||||
give the contents of the response. The result is stored in allocated
|
give the contents of the response. The result is stored in allocated
|
||||||
memory and a pointer to it stored into the variable pointed to by
|
memory and a pointer to it stored into the variable pointed to by
|
||||||
.IR host .
|
.IR host ,
|
||||||
|
if host is nonnull.
|
||||||
It is the caller's responsibility to free the resulting host structure
|
It is the caller's responsibility to free the resulting host structure
|
||||||
using
|
using
|
||||||
.BR ares_free_hostent (3)
|
.BR ares_free_hostent (3)
|
||||||
when it is no longer needed.
|
when it is no longer needed.
|
||||||
|
.PP
|
||||||
|
If
|
||||||
|
.IR addrttls
|
||||||
|
and
|
||||||
|
.IR naddrttls
|
||||||
|
are both nonnull,
|
||||||
|
then up to *naddrttls
|
||||||
|
.BR "struct addr6ttl"
|
||||||
|
records are stored in the array pointed to by addrttls,
|
||||||
|
and then *naddrttls is set to the number of records so stored.
|
||||||
|
Note that the memory for these records is supplied by the caller.
|
||||||
.SH RETURN VALUES
|
.SH RETURN VALUES
|
||||||
.B ares_parse_aaaa_reply
|
.B ares_parse_aaaa_reply
|
||||||
can return any of the following values:
|
can return any of the following values:
|
||||||
|
|||||||
@@ -34,25 +34,33 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "ares.h"
|
#include "ares.h"
|
||||||
#include "ares_dns.h"
|
#include "ares_dns.h"
|
||||||
#include "inet_net_pton.h"
|
#include "inet_net_pton.h"
|
||||||
#include "ares_private.h"
|
#include "ares_private.h"
|
||||||
|
|
||||||
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
||||||
struct hostent **host)
|
struct hostent **host, struct addr6ttl *addrttls,
|
||||||
|
int *naddrttls)
|
||||||
{
|
{
|
||||||
unsigned int qdcount, ancount;
|
unsigned int qdcount, ancount;
|
||||||
int status, i, rr_type, rr_class, rr_len, naddrs;
|
int status, i, rr_type, rr_class, rr_len, rr_ttl, naddrs;
|
||||||
|
int cname_ttl = INT_MAX; /* the TTL imposed by the CNAME chain */
|
||||||
int naliases;
|
int naliases;
|
||||||
long len;
|
long len;
|
||||||
const unsigned char *aptr;
|
const unsigned char *aptr;
|
||||||
char *hostname, *rr_name, *rr_data, **aliases;
|
char *hostname, *rr_name, *rr_data, **aliases;
|
||||||
struct in6_addr *addrs;
|
struct in6_addr *addrs;
|
||||||
struct hostent *hostent;
|
struct hostent *hostent;
|
||||||
|
const int max_addr_ttls = (addrttls && naddrttls) ? *naddrttls : 0;
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
/* Set *host to NULL for all failure cases. */
|
||||||
*host = NULL;
|
if (host)
|
||||||
|
*host = NULL;
|
||||||
|
/* Same with *naddrttls. */
|
||||||
|
if (naddrttls)
|
||||||
|
*naddrttls = 0;
|
||||||
|
|
||||||
/* Give up if abuf doesn't have room for a header. */
|
/* Give up if abuf doesn't have room for a header. */
|
||||||
if (alen < HFIXEDSZ)
|
if (alen < HFIXEDSZ)
|
||||||
@@ -77,18 +85,26 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|||||||
aptr += len + QFIXEDSZ;
|
aptr += len + QFIXEDSZ;
|
||||||
|
|
||||||
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
|
||||||
addrs = malloc(ancount * sizeof(struct in6_addr));
|
if (host)
|
||||||
if (!addrs)
|
|
||||||
{
|
{
|
||||||
free(hostname);
|
addrs = malloc(ancount * sizeof(struct in6_addr));
|
||||||
return ARES_ENOMEM;
|
if (!addrs)
|
||||||
|
{
|
||||||
|
free(hostname);
|
||||||
|
return ARES_ENOMEM;
|
||||||
|
}
|
||||||
|
aliases = malloc((ancount + 1) * sizeof(char *));
|
||||||
|
if (!aliases)
|
||||||
|
{
|
||||||
|
free(hostname);
|
||||||
|
free(addrs);
|
||||||
|
return ARES_ENOMEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
aliases = malloc((ancount + 1) * sizeof(char *));
|
else
|
||||||
if (!aliases)
|
|
||||||
{
|
{
|
||||||
free(hostname);
|
addrs = NULL;
|
||||||
free(addrs);
|
aliases = NULL;
|
||||||
return ARES_ENOMEM;
|
|
||||||
}
|
}
|
||||||
naddrs = 0;
|
naddrs = 0;
|
||||||
naliases = 0;
|
naliases = 0;
|
||||||
@@ -109,13 +125,33 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|||||||
rr_type = DNS_RR_TYPE(aptr);
|
rr_type = DNS_RR_TYPE(aptr);
|
||||||
rr_class = DNS_RR_CLASS(aptr);
|
rr_class = DNS_RR_CLASS(aptr);
|
||||||
rr_len = DNS_RR_LEN(aptr);
|
rr_len = DNS_RR_LEN(aptr);
|
||||||
|
rr_ttl = DNS_RR_TTL(aptr);
|
||||||
aptr += RRFIXEDSZ;
|
aptr += RRFIXEDSZ;
|
||||||
|
|
||||||
if (rr_class == C_IN && rr_type == T_AAAA
|
if (rr_class == C_IN && rr_type == T_AAAA
|
||||||
&& rr_len == sizeof(struct in6_addr)
|
&& rr_len == sizeof(struct in6_addr)
|
||||||
&& strcasecmp(rr_name, hostname) == 0)
|
&& strcasecmp(rr_name, hostname) == 0)
|
||||||
{
|
{
|
||||||
memcpy(&addrs[naddrs], aptr, sizeof(struct in6_addr));
|
if (addrs)
|
||||||
|
{
|
||||||
|
if (aptr + sizeof(struct in6_addr) > abuf + alen)
|
||||||
|
{
|
||||||
|
status = ARES_EBADRESP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&addrs[naddrs], aptr, sizeof(struct in6_addr));
|
||||||
|
}
|
||||||
|
if (naddrs < max_addr_ttls)
|
||||||
|
{
|
||||||
|
struct addr6ttl * const at = &addrttls[naddrs];
|
||||||
|
if (aptr + sizeof(struct in6_addr) > abuf + alen)
|
||||||
|
{
|
||||||
|
status = ARES_EBADRESP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(&at->ip6addr, aptr, sizeof(struct in6_addr));
|
||||||
|
at->ttl = rr_ttl;
|
||||||
|
}
|
||||||
naddrs++;
|
naddrs++;
|
||||||
status = ARES_SUCCESS;
|
status = ARES_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -123,7 +159,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|||||||
if (rr_class == C_IN && rr_type == T_CNAME)
|
if (rr_class == C_IN && rr_type == T_CNAME)
|
||||||
{
|
{
|
||||||
/* Record the RR name as an alias. */
|
/* Record the RR name as an alias. */
|
||||||
aliases[naliases] = rr_name;
|
if (aliases)
|
||||||
|
aliases[naliases] = rr_name;
|
||||||
|
else
|
||||||
|
free(rr_name);
|
||||||
naliases++;
|
naliases++;
|
||||||
|
|
||||||
/* Decode the RR data and replace the hostname with it. */
|
/* Decode the RR data and replace the hostname with it. */
|
||||||
@@ -132,6 +171,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|||||||
break;
|
break;
|
||||||
free(hostname);
|
free(hostname);
|
||||||
hostname = rr_data;
|
hostname = rr_data;
|
||||||
|
|
||||||
|
/* Take the min of the TTLs we see in the CNAME chain. */
|
||||||
|
if (cname_ttl > rr_ttl)
|
||||||
|
cname_ttl = rr_ttl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
free(rr_name);
|
free(rr_name);
|
||||||
@@ -148,32 +191,51 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
|
|||||||
status = ARES_ENODATA;
|
status = ARES_ENODATA;
|
||||||
if (status == ARES_SUCCESS)
|
if (status == ARES_SUCCESS)
|
||||||
{
|
{
|
||||||
/* We got our answer. Allocate memory to build the host entry. */
|
/* We got our answer. */
|
||||||
aliases[naliases] = NULL;
|
if (naddrttls)
|
||||||
hostent = malloc(sizeof(struct hostent));
|
|
||||||
if (hostent)
|
|
||||||
{
|
{
|
||||||
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
const int n = naddrs < max_addr_ttls ? naddrs : max_addr_ttls;
|
||||||
if (hostent->h_addr_list)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
/* Fill in the hostent and return successfully. */
|
/* Ensure that each A TTL is no larger than the CNAME TTL. */
|
||||||
hostent->h_name = hostname;
|
if (addrttls[i].ttl > cname_ttl)
|
||||||
hostent->h_aliases = aliases;
|
addrttls[i].ttl = cname_ttl;
|
||||||
hostent->h_addrtype = AF_INET6;
|
|
||||||
hostent->h_length = sizeof(struct in6_addr);
|
|
||||||
for (i = 0; i < naddrs; i++)
|
|
||||||
hostent->h_addr_list[i] = (char *) &addrs[i];
|
|
||||||
hostent->h_addr_list[naddrs] = NULL;
|
|
||||||
*host = hostent;
|
|
||||||
return ARES_SUCCESS;
|
|
||||||
}
|
}
|
||||||
free(hostent);
|
*naddrttls = n;
|
||||||
|
}
|
||||||
|
if (aliases)
|
||||||
|
aliases[naliases] = NULL;
|
||||||
|
if (host)
|
||||||
|
{
|
||||||
|
/* Allocate memory to build the host entry. */
|
||||||
|
hostent = malloc(sizeof(struct hostent));
|
||||||
|
if (hostent)
|
||||||
|
{
|
||||||
|
hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
|
||||||
|
if (hostent->h_addr_list)
|
||||||
|
{
|
||||||
|
/* Fill in the hostent and return successfully. */
|
||||||
|
hostent->h_name = hostname;
|
||||||
|
hostent->h_aliases = aliases;
|
||||||
|
hostent->h_addrtype = AF_INET6;
|
||||||
|
hostent->h_length = sizeof(struct in6_addr);
|
||||||
|
for (i = 0; i < naddrs; i++)
|
||||||
|
hostent->h_addr_list[i] = (char *) &addrs[i];
|
||||||
|
hostent->h_addr_list[naddrs] = NULL;
|
||||||
|
*host = hostent;
|
||||||
|
return ARES_SUCCESS;
|
||||||
|
}
|
||||||
|
free(hostent);
|
||||||
|
}
|
||||||
|
status = ARES_ENOMEM;
|
||||||
}
|
}
|
||||||
status = ARES_ENOMEM;
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < naliases; i++)
|
if (aliases)
|
||||||
free(aliases[i]);
|
{
|
||||||
free(aliases);
|
for (i = 0; i < naliases; i++)
|
||||||
|
free(aliases[i]);
|
||||||
|
free(aliases);
|
||||||
|
}
|
||||||
free(addrs);
|
free(addrs);
|
||||||
free(hostname);
|
free(hostname);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -18,6 +18,14 @@
|
|||||||
* without express or implied warranty.
|
* without express or implied warranty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define WIN32 when build target is Win32 API
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||||
|
#define WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/* Copyright (C) 2005 by Dominick Meglio
|
||||||
|
*
|
||||||
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
||||||
* software and its documentation for any purpose and without
|
* software and its documentation for any purpose and without
|
||||||
* fee is hereby granted, provided that the above copyright
|
* fee is hereby granted, provided that the above copyright
|
||||||
|
|||||||
@@ -159,24 +159,44 @@
|
|||||||
/* Define this if you have struct timeval */
|
/* Define this if you have struct timeval */
|
||||||
#define HAVE_STRUCT_TIMEVAL 1
|
#define HAVE_STRUCT_TIMEVAL 1
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
/* COMPILER SPECIFIC */
|
||||||
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* Define to avoid VS2005 complaining about portable C functions */
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
/* IPV6 COMPATIBILITY */
|
/* IPV6 COMPATIBILITY */
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Define this if you have address family AF_INET6 */
|
/* Define this if you have address family AF_INET6 */
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
#define HAVE_AF_INET6 1
|
#define HAVE_AF_INET6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define this if you have protocol family PF_INET6 */
|
/* Define this if you have protocol family PF_INET6 */
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
#define HAVE_PF_INET6 1
|
#define HAVE_PF_INET6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define this if you have struct in6_addr */
|
/* Define this if you have struct in6_addr */
|
||||||
|
#ifdef HAVE_WS2TCPIP_H
|
||||||
#define HAVE_STRUCT_IN6_ADDR 1
|
#define HAVE_STRUCT_IN6_ADDR 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define this if you have struct sockaddr_in6 */
|
/* Define this if you have struct sockaddr_in6 */
|
||||||
|
#ifdef HAVE_WS2TCPIP_H
|
||||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define this if you have sockaddr_in6 with scopeid */
|
/* Define this if you have sockaddr_in6 with scopeid */
|
||||||
|
#ifdef HAVE_WS2TCPIP_H
|
||||||
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* __ARES_CONFIG_WIN32_H */
|
#endif /* __ARES_CONFIG_WIN32_H */
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/* Copyright (C) 2005 by Daniel Stenberg
|
||||||
|
*
|
||||||
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
||||||
* software and its documentation for any purpose and without
|
* software and its documentation for any purpose and without
|
||||||
* fee is hereby granted, provided that the above copyright
|
* fee is hereby granted, provided that the above copyright
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/*
|
/* Copyright (C) 2005 by Dominick Meglio
|
||||||
|
*
|
||||||
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
||||||
* software and its documentation for any purpose and without
|
* software and its documentation for any purpose and without
|
||||||
* fee is hereby granted, provided that the above copyright
|
* fee is hereby granted, provided that the above copyright
|
||||||
|
|||||||
@@ -7,9 +7,6 @@
|
|||||||
port build */
|
port build */
|
||||||
|
|
||||||
#ifndef NETWARE
|
#ifndef NETWARE
|
||||||
#ifndef __CYGWIN__
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
#include <process.h> /* for the _getpid() proto */
|
#include <process.h> /* for the _getpid() proto */
|
||||||
#endif /* !NETWARE */
|
#endif /* !NETWARE */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|||||||
10
ares/setup.h
10
ares/setup.h
@@ -16,13 +16,11 @@
|
|||||||
* without express or implied warranty.
|
* without express or implied warranty.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(WIN32) && defined(__WIN32__)
|
/*
|
||||||
/* Borland fix */
|
* Define WIN32 when build target is Win32 API
|
||||||
#define WIN32
|
*/
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(WIN32) && defined(_WIN32)
|
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||||
/* VS2005 on x64 fix */
|
|
||||||
#define WIN32
|
#define WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ BSC32=bscmake.exe
|
|||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /machine:I386
|
||||||
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
|
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "adig - Win32 Debug"
|
!ELSEIF "$(CFG)" == "adig - Win32 Debug"
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ BSC32=bscmake.exe
|
|||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
|
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ RSC=rc.exe
|
|||||||
# PROP Use_Debug_Libraries 0
|
# PROP Use_Debug_Libraries 0
|
||||||
# PROP Output_Dir "Release"
|
# PROP Output_Dir "Release"
|
||||||
# PROP Intermediate_Dir "Release"
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||||
@@ -48,8 +49,8 @@ BSC32=bscmake.exe
|
|||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /machine:I386
|
||||||
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
|
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /machine:I386 /libpath:"..\areslib\Release"
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "ahost - Win32 Debug"
|
!ELSEIF "$(CFG)" == "ahost - Win32 Debug"
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ LINK32=link.exe
|
|||||||
# PROP Use_Debug_Libraries 1
|
# PROP Use_Debug_Libraries 1
|
||||||
# PROP Output_Dir "Debug"
|
# PROP Output_Dir "Debug"
|
||||||
# PROP Intermediate_Dir "Debug"
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||||
@@ -71,8 +73,8 @@ BSC32=bscmake.exe
|
|||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 ws2_32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 wsock32.lib areslib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
|
# ADD LINK32 ws2_32.lib advapi32.lib areslib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\areslib\Debug"
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
|||||||
12
configure.ac
12
configure.ac
@@ -174,6 +174,7 @@ case $host in
|
|||||||
esac
|
esac
|
||||||
AC_MSG_RESULT($mimpure)
|
AC_MSG_RESULT($mimpure)
|
||||||
AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
|
AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
|
||||||
|
AM_CONDITIONAL(STATICLIB, false)
|
||||||
|
|
||||||
AC_MSG_CHECKING([if we need BUILDING_LIBCURL])
|
AC_MSG_CHECKING([if we need BUILDING_LIBCURL])
|
||||||
case $host in
|
case $host in
|
||||||
@@ -185,6 +186,7 @@ case $host in
|
|||||||
then
|
then
|
||||||
AC_DEFINE(CURL_STATICLIB, 1, [when not building a shared library])
|
AC_DEFINE(CURL_STATICLIB, 1, [when not building a shared library])
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
AM_CONDITIONAL(STATICLIB, true)
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
@@ -1292,6 +1294,7 @@ else
|
|||||||
if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
|
if test "$HAVE_LIBZ" = "1" && test "$HAVE_ZLIB_H" != "1"
|
||||||
then
|
then
|
||||||
AC_MSG_WARN([configure found only the libz lib, not the header file!])
|
AC_MSG_WARN([configure found only the libz lib, not the header file!])
|
||||||
|
HAVE_LIBZ=""
|
||||||
elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
|
elif test "$HAVE_LIBZ" != "1" && test "$HAVE_ZLIB_H" = "1"
|
||||||
then
|
then
|
||||||
AC_MSG_WARN([configure found only the libz header file, not the lib!])
|
AC_MSG_WARN([configure found only the libz header file, not the lib!])
|
||||||
@@ -1356,8 +1359,9 @@ if test X"$OPT_LIBSSH2" != Xno; then
|
|||||||
AC_CHECK_HEADERS(libssh2.h,
|
AC_CHECK_HEADERS(libssh2.h,
|
||||||
curl_ssh_msg="enabled (libSSH2)"
|
curl_ssh_msg="enabled (libSSH2)"
|
||||||
LIBSSH2_ENABLED=1
|
LIBSSH2_ENABLED=1
|
||||||
AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use]))
|
AC_DEFINE(USE_LIBSSH2, 1, [if libSSH2 is in use])
|
||||||
AC_SUBST(USE_LIBSSH2, [1])
|
AC_SUBST(USE_LIBSSH2, [1])
|
||||||
|
)
|
||||||
|
|
||||||
if test X"$OPT_LIBSSH2" != Xoff &&
|
if test X"$OPT_LIBSSH2" != Xoff &&
|
||||||
test "$LIBSSH2_ENABLED" != "1"; then
|
test "$LIBSSH2_ENABLED" != "1"; then
|
||||||
@@ -1566,13 +1570,17 @@ fi dnl OPENSSL != 1 -a GNUTLS_ENABLED != 1
|
|||||||
if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED" = "x"; then
|
if test "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED" = "x"; then
|
||||||
AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
|
AC_MSG_WARN([SSL disabled, you will not be able to use HTTPS, FTPS, NTLM and more.])
|
||||||
AC_MSG_WARN([Use --with-ssl, --with-gnutls or --with-nss to address this.])
|
AC_MSG_WARN([Use --with-ssl, --with-gnutls or --with-nss to address this.])
|
||||||
|
else
|
||||||
|
# SSL is enabled, genericly
|
||||||
|
AC_SUBST(SSL_ENABLED)
|
||||||
|
SSL_ENABLED="1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
dnl Check for the CA bundle
|
dnl Check for the CA bundle
|
||||||
dnl **********************************************************************
|
dnl **********************************************************************
|
||||||
|
|
||||||
if test X"$USE_NSS$USE_GNUTLS$OPENSSL_ENABLED" != "X"; then
|
if test X"$SSL_ENABLED" != "X"; then
|
||||||
|
|
||||||
AC_MSG_CHECKING([CA cert bundle install path])
|
AC_MSG_CHECKING([CA cert bundle install path])
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ while test $# -gt 0; do
|
|||||||
if test "@USE_SSLEAY@" = "1"; then
|
if test "@USE_SSLEAY@" = "1"; then
|
||||||
echo "SSL"
|
echo "SSL"
|
||||||
NTLM=1 # OpenSSL implies NTLM
|
NTLM=1 # OpenSSL implies NTLM
|
||||||
elif test -n "@USE_GNUTLS@"; then
|
elif test -n "@SSL_ENABLED@"; then
|
||||||
echo "SSL"
|
echo "SSL"
|
||||||
fi
|
fi
|
||||||
if test "@KRB4_ENABLED@" = "1"; then
|
if test "@KRB4_ENABLED@" = "1"; then
|
||||||
@@ -113,13 +113,13 @@ while test $# -gt 0; do
|
|||||||
--protocols)
|
--protocols)
|
||||||
if test "@CURL_DISABLE_HTTP@" != "1"; then
|
if test "@CURL_DISABLE_HTTP@" != "1"; then
|
||||||
echo "HTTP"
|
echo "HTTP"
|
||||||
if test "@USE_SSLEAY@" = "1"; then
|
if test "@SSL_ENABLED@" = "1"; then
|
||||||
echo "HTTPS"
|
echo "HTTPS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if test "@CURL_DISABLE_FTP@" != "1"; then
|
if test "@CURL_DISABLE_FTP@" != "1"; then
|
||||||
echo "FTP"
|
echo "FTP"
|
||||||
if test "@USE_SSLEAY@" = "1"; then
|
if test "@SSL_ENABLED@" = "1"; then
|
||||||
echo "FTPS"
|
echo "FTPS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -143,11 +143,20 @@ Rexx
|
|||||||
Written Mark Hessling
|
Written Mark Hessling
|
||||||
http://rexxcurl.sourceforge.net/
|
http://rexxcurl.sourceforge.net/
|
||||||
|
|
||||||
|
RPG
|
||||||
|
|
||||||
|
Support for ILE/RPG on OS/400 is included in source distribution
|
||||||
|
http://curl.haxx.se/libcurl/
|
||||||
|
See packages/OS400/README.OS400 and packages/OS400/curl.inc.in
|
||||||
|
|
||||||
Ruby
|
Ruby
|
||||||
|
|
||||||
Written by Ross Bamford
|
curb - written by Ross Bamford
|
||||||
http://curb.rubyforge.org/
|
http://curb.rubyforge.org/
|
||||||
|
|
||||||
|
ruby-curl-multi - written by Kristjan Petursson and Keith Rarick
|
||||||
|
http://curl-multi.rubyforge.org/
|
||||||
|
|
||||||
Scheme
|
Scheme
|
||||||
|
|
||||||
Bigloo binding by Kirill Lisovsky
|
Bigloo binding by Kirill Lisovsky
|
||||||
|
|||||||
@@ -102,6 +102,8 @@
|
|||||||
using spaces only (no tabs) and having the opening brace ({) on the same line
|
using spaces only (no tabs) and having the opening brace ({) on the same line
|
||||||
as the if() or while().
|
as the if() or while().
|
||||||
|
|
||||||
|
Also note that we use if() and while() with no space before the parenthesis.
|
||||||
|
|
||||||
2.3 Commenting
|
2.3 Commenting
|
||||||
|
|
||||||
Comment your source code extensively using C comments (/* comment */), DO NOT
|
Comment your source code extensively using C comments (/* comment */), DO NOT
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ Albert Chin-A-Young
|
|||||||
Albert Choy
|
Albert Choy
|
||||||
Ale Vesely
|
Ale Vesely
|
||||||
Aleksandar Milivojevic
|
Aleksandar Milivojevic
|
||||||
|
Alex Fishman
|
||||||
Alex Neblett
|
Alex Neblett
|
||||||
Alex Suykov
|
Alex Suykov
|
||||||
Alex aka WindEagle
|
Alex aka WindEagle
|
||||||
@@ -19,6 +20,7 @@ Alexander Kourakos
|
|||||||
Alexander Krasnostavsky
|
Alexander Krasnostavsky
|
||||||
Alexander Lazic
|
Alexander Lazic
|
||||||
Alexander Zhuravlev
|
Alexander Zhuravlev
|
||||||
|
Alexey Pesternikov
|
||||||
Alexey Simak
|
Alexey Simak
|
||||||
Alexis Carvalho
|
Alexis Carvalho
|
||||||
Allen Pulsifer
|
Allen Pulsifer
|
||||||
@@ -229,6 +231,7 @@ Ignacio Vazquez-Abrams
|
|||||||
Igor Polyakov
|
Igor Polyakov
|
||||||
Ilguiz Latypov
|
Ilguiz Latypov
|
||||||
Ilja van Sprundel
|
Ilja van Sprundel
|
||||||
|
Immanuel Gregoire
|
||||||
Ingmar Runge
|
Ingmar Runge
|
||||||
Ingo Ralf Blum
|
Ingo Ralf Blum
|
||||||
Ingo Wilken
|
Ingo Wilken
|
||||||
@@ -274,6 +277,7 @@ John Janssen
|
|||||||
John Kelly
|
John Kelly
|
||||||
John Lask
|
John Lask
|
||||||
John McGowan
|
John McGowan
|
||||||
|
Johnny Luong
|
||||||
Jon Grubbs
|
Jon Grubbs
|
||||||
Jon Travis
|
Jon Travis
|
||||||
Jon Turner
|
Jon Turner
|
||||||
@@ -308,6 +312,7 @@ Kent Boortz
|
|||||||
Kevin Fisk
|
Kevin Fisk
|
||||||
Kevin Lussier
|
Kevin Lussier
|
||||||
Kevin Roth
|
Kevin Roth
|
||||||
|
Kim Rinnewitz
|
||||||
Kimmo Kinnunen
|
Kimmo Kinnunen
|
||||||
Kjell Ericson
|
Kjell Ericson
|
||||||
Kjetil Jacobsen
|
Kjetil Jacobsen
|
||||||
@@ -348,6 +353,7 @@ Marco G. Salvagno
|
|||||||
Marcus Webster
|
Marcus Webster
|
||||||
Mario Schroeder
|
Mario Schroeder
|
||||||
Mark Butler
|
Mark Butler
|
||||||
|
Mark Davies
|
||||||
Mark Eichin
|
Mark Eichin
|
||||||
Mark Lentczner
|
Mark Lentczner
|
||||||
Markus Koetter
|
Markus Koetter
|
||||||
@@ -368,6 +374,7 @@ Matt Witherspoon
|
|||||||
Matthew Blain
|
Matthew Blain
|
||||||
Matthew Clarke
|
Matthew Clarke
|
||||||
Maurice Barnum
|
Maurice Barnum
|
||||||
|
Max Katsev
|
||||||
Mekonikum
|
Mekonikum
|
||||||
Mettgut Jamalla
|
Mettgut Jamalla
|
||||||
Michael Benedict
|
Michael Benedict
|
||||||
@@ -440,6 +447,7 @@ Peter Wullinger
|
|||||||
Peteris Krumins
|
Peteris Krumins
|
||||||
Phil Karn
|
Phil Karn
|
||||||
Philip Gladstone
|
Philip Gladstone
|
||||||
|
Philip Langdale
|
||||||
Philippe Hameau
|
Philippe Hameau
|
||||||
Philippe Raoult
|
Philippe Raoult
|
||||||
Philippe Vaucher
|
Philippe Vaucher
|
||||||
@@ -575,6 +583,7 @@ Vilmos Nebehaj
|
|||||||
Vincent Bronner
|
Vincent Bronner
|
||||||
Vincent Penquerc'h
|
Vincent Penquerc'h
|
||||||
Vincent Sanders
|
Vincent Sanders
|
||||||
|
Vladimir Lazarenko
|
||||||
Vojtech Janota
|
Vojtech Janota
|
||||||
Vojtech Minarik
|
Vojtech Minarik
|
||||||
Walter J. Mack
|
Walter J. Mack
|
||||||
|
|||||||
16
docs/curl.1
16
docs/curl.1
@@ -21,7 +21,7 @@
|
|||||||
.\" * $Id$
|
.\" * $Id$
|
||||||
.\" **************************************************************************
|
.\" **************************************************************************
|
||||||
.\"
|
.\"
|
||||||
.TH curl 1 "21 Sep 2007" "Curl 7.17.1" "Curl Manual"
|
.TH curl 1 "20 Nov 2007" "Curl 7.17.2" "Curl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl \- transfer a URL
|
curl \- transfer a URL
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -261,6 +261,20 @@ the \fI--data-ascii\fP option, this is for you.
|
|||||||
|
|
||||||
If this option is used several times, the ones following the first will
|
If this option is used several times, the ones following the first will
|
||||||
append data.
|
append data.
|
||||||
|
.IP "--data-urlencode <data>"
|
||||||
|
(HTTP) This posts data, similar to the other --data options with the exception
|
||||||
|
that this will do partial URL encoding. (Added in 7.17.2)
|
||||||
|
|
||||||
|
The <data> part should be using one of the two following syntaxes:
|
||||||
|
.RS
|
||||||
|
.IP "name=content"
|
||||||
|
This will make curl URL encode the content part and pass that on. Note that
|
||||||
|
the name part is expected to be URL encoded already.
|
||||||
|
.IP "name@filename"
|
||||||
|
This will make curl load data from the given file, URL encode that data and
|
||||||
|
pass it on in the POST like \fIname=urlencoded-data\fP. Note that the name
|
||||||
|
is expected to be URL encoded already.
|
||||||
|
.RE
|
||||||
.IP "--digest"
|
.IP "--digest"
|
||||||
(HTTP) Enables HTTP Digest authentication. This is a authentication that
|
(HTTP) Enables HTTP Digest authentication. This is a authentication that
|
||||||
prevents the password from being sent over the wire in clear text. Use this in
|
prevents the password from being sent over the wire in clear text. Use this in
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <curl/multi.h>
|
#include <curl/multi.h>
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char *urls[] = {
|
static const char *urls[] = {
|
||||||
"http://www.microsoft.com",
|
"http://www.microsoft.com",
|
||||||
@@ -138,7 +141,11 @@ int main(void)
|
|||||||
L = 100;
|
L = 100;
|
||||||
|
|
||||||
if (M == -1) {
|
if (M == -1) {
|
||||||
|
#ifdef WIN32
|
||||||
|
Sleep(L);
|
||||||
|
#else
|
||||||
sleep(L / 1000);
|
sleep(L / 1000);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
T.tv_sec = L/1000;
|
T.tv_sec = L/1000;
|
||||||
T.tv_usec = (L%1000)*1000;
|
T.tv_usec = (L%1000)*1000;
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ EXTRA_DIST = README Makefile.example makefile.dj $(COMPLICATED_EXAMPLES)
|
|||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
LIBDIR = $(top_builddir)/lib
|
LIBDIR = $(top_builddir)/lib
|
||||||
CPPFLAGS = -DCURL_NO_OLDIES
|
|
||||||
|
if STATICLIB
|
||||||
|
# we need this define when building with a static lib on Windows
|
||||||
|
STATICCPPFLAGS = -DCURL_STATICLIB
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPFLAGS = -DCURL_NO_OLDIES $(STATICCPPFLAGS)
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
LDADD = $(LIBDIR)/libcurl.la
|
LDADD = $(LIBDIR)/libcurl.la
|
||||||
|
|||||||
@@ -98,5 +98,8 @@ int main(int argc, char **argv)
|
|||||||
if(chunk.memory)
|
if(chunk.memory)
|
||||||
free(chunk.memory);
|
free(chunk.memory);
|
||||||
|
|
||||||
|
/* we're done with libcurl, so clean it up */
|
||||||
|
curl_global_cleanup();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1491,6 +1491,14 @@ this curl handle use the data from the shared handle instead of keeping the
|
|||||||
data to itself. This enables several curl handles to share data. If the curl
|
data to itself. This enables several curl handles to share data. If the curl
|
||||||
handles are used simultaneously, you \fBMUST\fP use the locking methods in the
|
handles are used simultaneously, you \fBMUST\fP use the locking methods in the
|
||||||
share handle. See \fIcurl_share_setopt(3)\fP for details.
|
share handle. See \fIcurl_share_setopt(3)\fP for details.
|
||||||
|
|
||||||
|
If you add a share that is set to share cookies, your easy handle will use
|
||||||
|
that cookie cache and get the cookie engine enabled. If you unshare an object
|
||||||
|
that were using cookies (or change to another object that doesn't share
|
||||||
|
cookies), the easy handle will get its cookie engine disabled.
|
||||||
|
|
||||||
|
Data that the share object is not set to share will be dealt with the usual
|
||||||
|
way, as if no share was used.
|
||||||
.IP CURLOPT_NEW_FILE_PERMS
|
.IP CURLOPT_NEW_FILE_PERMS
|
||||||
Pass a long as a parameter, containing the value of the permissions that will
|
Pass a long as a parameter, containing the value of the permissions that will
|
||||||
be assigned to newly created files on the remote server. The default value is
|
be assigned to newly created files on the remote server. The default value is
|
||||||
|
|||||||
@@ -29,6 +29,14 @@
|
|||||||
|
|
||||||
#include "curlver.h" /* the libcurl version defines */
|
#include "curlver.h" /* the libcurl version defines */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define WIN32 when build target is Win32 API
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||||
|
#define WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
@@ -41,12 +49,42 @@
|
|||||||
# include <time.h>
|
# include <time.h>
|
||||||
#endif /* defined (vms) */
|
#endif /* defined (vms) */
|
||||||
|
|
||||||
typedef void CURL;
|
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
|
||||||
|
!defined(__CYGWIN__) || defined(__MINGW32__)
|
||||||
|
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
|
||||||
|
/* The check above prevents the winsock2 inclusion if winsock.h already was
|
||||||
|
included, since they can't co-exist without problems */
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
|
||||||
|
libc5-based Linux systems. Only include it on system that are known to
|
||||||
|
require it! */
|
||||||
|
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || defined(__minix)
|
||||||
|
#include <sys/select.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32_WCE
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#endif
|
||||||
|
#ifndef __WATCOMC__
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __BEOS__
|
||||||
|
#include <support/SupportDefs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef void CURL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decorate exportable functions for Win32 DLL linking.
|
* Decorate exportable functions for Win32 DLL linking.
|
||||||
* This avoids using a .def file for building libcurl.dll.
|
* This avoids using a .def file for building libcurl.dll.
|
||||||
@@ -139,38 +177,6 @@ extern "C" {
|
|||||||
#undef FILESIZEBITS
|
#undef FILESIZEBITS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(WIN32)
|
|
||||||
/* Chris Lewis mentioned that he doesn't get WIN32 defined, only _WIN32 so we
|
|
||||||
make this adjustment to catch this. */
|
|
||||||
#define WIN32 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__GNUC__) && \
|
|
||||||
!defined(__CYGWIN__) || defined(__MINGW32__)
|
|
||||||
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H))
|
|
||||||
/* The check above prevents the winsock2 inclusion if winsock.h already was
|
|
||||||
included, since they can't co-exist without problems */
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish
|
|
||||||
libc5-based Linux systems. Only include it on system that are known to
|
|
||||||
require it! */
|
|
||||||
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || defined(__minix)
|
|
||||||
#include <sys/select.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#ifndef __WATCOMC__
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef curl_socket_typedef
|
#ifndef curl_socket_typedef
|
||||||
/* socket typedef */
|
/* socket typedef */
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -1241,10 +1247,6 @@ typedef enum {
|
|||||||
CURL_TIMECOND_LAST
|
CURL_TIMECOND_LAST
|
||||||
} curl_TimeCond;
|
} curl_TimeCond;
|
||||||
|
|
||||||
#ifdef __BEOS__
|
|
||||||
#include <support/SupportDefs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* curl_strequal() and curl_strnequal() are subject for removal in a future
|
/* curl_strequal() and curl_strnequal() are subject for removal in a future
|
||||||
libcurl, see lib/README.curlx for details */
|
libcurl, see lib/README.curlx for details */
|
||||||
|
|||||||
@@ -28,13 +28,13 @@
|
|||||||
|
|
||||||
/* This is the version number of the libcurl package from which this header
|
/* This is the version number of the libcurl package from which this header
|
||||||
file origins: */
|
file origins: */
|
||||||
#define LIBCURL_VERSION "7.17.1-CVS"
|
#define LIBCURL_VERSION "7.17.2-CVS"
|
||||||
|
|
||||||
/* The numeric version number is also available "in parts" by using these
|
/* The numeric version number is also available "in parts" by using these
|
||||||
defines: */
|
defines: */
|
||||||
#define LIBCURL_VERSION_MAJOR 7
|
#define LIBCURL_VERSION_MAJOR 7
|
||||||
#define LIBCURL_VERSION_MINOR 17
|
#define LIBCURL_VERSION_MINOR 17
|
||||||
#define LIBCURL_VERSION_PATCH 1
|
#define LIBCURL_VERSION_PATCH 2
|
||||||
|
|
||||||
/* This is the numeric version of the libcurl version number, meant for easier
|
/* This is the numeric version of the libcurl version number, meant for easier
|
||||||
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
and it is always a greater number in a more recent release. It makes
|
and it is always a greater number in a more recent release. It makes
|
||||||
comparisons with greater than and less than work.
|
comparisons with greater than and less than work.
|
||||||
*/
|
*/
|
||||||
#define LIBCURL_VERSION_NUM 0x071101
|
#define LIBCURL_VERSION_NUM 0x071102
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the date and time when the full source package was created. The
|
* This is the date and time when the full source package was created. The
|
||||||
|
|||||||
@@ -12,9 +12,20 @@ CFLAGS = -3r -mf -d3 -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm -bt=
|
|||||||
-d+ -dWIN32 -dCURL_CA_BUNDLE=getenv("CURL_CA_BUNDLE") &
|
-d+ -dWIN32 -dCURL_CA_BUNDLE=getenv("CURL_CA_BUNDLE") &
|
||||||
-dBUILDING_LIBCURL -dWITHOUT_MM_LIB -dHAVE_SPNEGO=1 -dENABLE_IPV6 &
|
-dBUILDING_LIBCURL -dWITHOUT_MM_LIB -dHAVE_SPNEGO=1 -dENABLE_IPV6 &
|
||||||
-dDEBUG_THREADING_GETADDRINFO -dDEBUG=1 -dCURLDEBUG -d_WIN32_WINNT=0x0501 &
|
-dDEBUG_THREADING_GETADDRINFO -dDEBUG=1 -dCURLDEBUG -d_WIN32_WINNT=0x0501 &
|
||||||
-I. -I..\include -dCURL_DISABLE_LDAP
|
-I. -I..\include -dWINBERAPI=__declspec(cdecl) -dWINLDAPAPI=__declspec(cdecl)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Change to suite.
|
||||||
|
#
|
||||||
|
ZLIB_ROOT = ..\..\..\zlib-1.2.3
|
||||||
|
USE_ZLIB = 0
|
||||||
|
|
||||||
|
!ifeq USE_ZLIB 1
|
||||||
|
CFLAGS += -dHAVE_ZLIB_H -dHAVE_LIBZ -I$(ZLIB_ROOT)
|
||||||
|
!endif
|
||||||
|
|
||||||
OBJ_DIR = Watcom_obj
|
OBJ_DIR = Watcom_obj
|
||||||
|
C_ARG = $(OBJ_DIR)\wcc386.arg
|
||||||
LIB_ARG = $(OBJ_DIR)\wlib.arg
|
LIB_ARG = $(OBJ_DIR)\wlib.arg
|
||||||
LINK_ARG = $(OBJ_DIR)\wlink.arg
|
LINK_ARG = $(OBJ_DIR)\wlink.arg
|
||||||
|
|
||||||
@@ -50,7 +61,7 @@ OBJS = $(OBJ_DIR)\base64.obj $(OBJ_DIR)\connect.obj &
|
|||||||
|
|
||||||
RESOURCE = $(OBJ_DIR)\libcurl.res
|
RESOURCE = $(OBJ_DIR)\libcurl.res
|
||||||
|
|
||||||
all: $(OBJ_DIR) $(TARGETS) .SYMBOLIC
|
all: $(OBJ_DIR) $(C_ARG) $(TARGETS) .SYMBOLIC
|
||||||
@echo Welcome to libcurl
|
@echo Welcome to libcurl
|
||||||
|
|
||||||
$(OBJ_DIR):
|
$(OBJ_DIR):
|
||||||
@@ -69,7 +80,7 @@ clean: .SYMBOLIC
|
|||||||
- rm -f $(OBJS) $(RESOURCE)
|
- rm -f $(OBJS) $(RESOURCE)
|
||||||
|
|
||||||
vclean realclean: clean .SYMBOLIC
|
vclean realclean: clean .SYMBOLIC
|
||||||
- rm -f $(TARGETS) $(LIB_ARG) $(LINK_ARG) libcurl_wc.map
|
- rm -f $(TARGETS) $(C_ARG) $(LIB_ARG) $(LINK_ARG) libcurl_wc.map
|
||||||
- rmdir $(OBJ_DIR)
|
- rmdir $(OBJ_DIR)
|
||||||
|
|
||||||
.ERASE
|
.ERASE
|
||||||
@@ -78,8 +89,11 @@ $(RESOURCE): libcurl.rc
|
|||||||
|
|
||||||
.ERASE
|
.ERASE
|
||||||
.c{$(OBJ_DIR)}.obj:
|
.c{$(OBJ_DIR)}.obj:
|
||||||
$(CC) $[@ $(CFLAGS) -fo=$@
|
$(CC) $[@ @$(C_ARG) -fo=$@
|
||||||
@echo .
|
|
||||||
|
$(C_ARG): $(__MAKEFILES__)
|
||||||
|
%create $^@
|
||||||
|
%append $^@ $(CFLAGS)
|
||||||
|
|
||||||
$(LIB_ARG): $(__MAKEFILES__)
|
$(LIB_ARG): $(__MAKEFILES__)
|
||||||
%create $^@
|
%create $^@
|
||||||
@@ -91,7 +105,10 @@ $(LINK_ARG): $(__MAKEFILES__)
|
|||||||
@%append $^@ file { $(OBJS) }
|
@%append $^@ file { $(OBJS) }
|
||||||
@%append $^@ option quiet, map, caseexact, eliminate, implib=libcurl_wc_imp.lib,
|
@%append $^@ option quiet, map, caseexact, eliminate, implib=libcurl_wc_imp.lib,
|
||||||
@%append $^@ res=$(RESOURCE) libpath $(%watcom)\lib386;$(%watcom)\lib386\nt
|
@%append $^@ res=$(RESOURCE) libpath $(%watcom)\lib386;$(%watcom)\lib386\nt
|
||||||
@%append $^@ library clib3r.lib, ws2_32.lib
|
@%append $^@ library clib3r.lib, wldap32.lib, ws2_32.lib
|
||||||
|
!ifeq USE_ZLIB 1
|
||||||
|
@%append $^@ library $(ZLIB_ROOT)\zlib.lib
|
||||||
|
!endif
|
||||||
|
|
||||||
#
|
#
|
||||||
# Dependencies based on "gcc -MM .."
|
# Dependencies based on "gcc -MM .."
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ endif
|
|||||||
|
|
||||||
# Edit the path below to point to the base of your OpenSSL package.
|
# Edit the path below to point to the base of your OpenSSL package.
|
||||||
ifndef OPENSSL_PATH
|
ifndef OPENSSL_PATH
|
||||||
OPENSSL_PATH = ../../openssl-0.9.8e
|
OPENSSL_PATH = ../../openssl-0.9.8g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Edit the path below to point to the base of your LibSSH2 package.
|
# Edit the path below to point to the base of your LibSSH2 package.
|
||||||
ifndef LIBSSH2_PATH
|
ifndef LIBSSH2_PATH
|
||||||
LIBSSH2_PATH = ../../libssh2-0.16
|
LIBSSH2_PATH = ../../libssh2-0.18
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef INSTDIR
|
ifndef INSTDIR
|
||||||
@@ -372,7 +372,6 @@ ifeq ($(LIBARCH),CLIB)
|
|||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
|
||||||
@echo $(DL)#define socklen_t int$(DL) >> $@
|
@echo $(DL)#define socklen_t int$(DL) >> $@
|
||||||
@echo $(DL)#define DL_LDAP_FILE "ldapsdk.nlm"$(DL) >> $@
|
|
||||||
else
|
else
|
||||||
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
|
||||||
@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
|
@echo $(DL)#define HAVE_FTRUNCATE 1$(DL) >> $@
|
||||||
@@ -405,7 +404,6 @@ else
|
|||||||
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
|
||||||
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
|
||||||
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
@echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
|
||||||
@echo $(DL)#define DL_LDAP_FILE "lldapsdk.nlm"$(DL) >> $@
|
|
||||||
ifdef ENABLE_IPV6
|
ifdef ENABLE_IPV6
|
||||||
@echo $(DL)#define ENABLE_IPV6 1$(DL) >> $@
|
@echo $(DL)#define ENABLE_IPV6 1$(DL) >> $@
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ size_t Curl_base64_decode(const char *src, unsigned char **outptr)
|
|||||||
numQuantums = (length + equalsTerm) / 4;
|
numQuantums = (length + equalsTerm) / 4;
|
||||||
|
|
||||||
/* Don't allocate a buffer if the decoded length is 0 */
|
/* Don't allocate a buffer if the decoded length is 0 */
|
||||||
if (numQuantums <= 0)
|
if(numQuantums <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
rawlen = (numQuantums * 3) - equalsTerm;
|
rawlen = (numQuantums * 3) - equalsTerm;
|
||||||
|
|||||||
@@ -347,6 +347,12 @@
|
|||||||
#define HAVE_LONGLONG 1
|
#define HAVE_LONGLONG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Define to avoid VS2005 complaining about portable C functions */
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
/* LDAP SUPPORT */
|
/* LDAP SUPPORT */
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
@@ -370,10 +376,6 @@
|
|||||||
/* ADDITIONAL DEFINITIONS */
|
/* ADDITIONAL DEFINITIONS */
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Defines set for VS2005 to _not_ deprecate a few functions we use. */
|
|
||||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
|
||||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
|
||||||
|
|
||||||
/* Define cpu-machine-OS */
|
/* Define cpu-machine-OS */
|
||||||
#undef OS
|
#undef OS
|
||||||
#if defined(_M_IX86) || defined(__i386__) /* x86 (MSVC or gcc) */
|
#if defined(_M_IX86) || defined(__i386__) /* x86 (MSVC or gcc) */
|
||||||
|
|||||||
@@ -308,6 +308,12 @@
|
|||||||
/* Undef keyword 'const' if it does not work. */
|
/* Undef keyword 'const' if it does not work. */
|
||||||
/* #undef const */
|
/* #undef const */
|
||||||
|
|
||||||
|
/* Define to avoid VS2005 complaining about portable C functions */
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||||
|
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
/* LDAP SUPPORT */
|
/* LDAP SUPPORT */
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
@@ -320,10 +326,6 @@
|
|||||||
/* ADDITIONAL DEFINITIONS */
|
/* ADDITIONAL DEFINITIONS */
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Defines set for VS2005 to _not_ deprecate a few functions we use. */
|
|
||||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
|
||||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
|
||||||
|
|
||||||
/* Define cpu-machine-OS */
|
/* Define cpu-machine-OS */
|
||||||
#undef OS
|
#undef OS
|
||||||
#define OS "i386-pc-win32ce"
|
#define OS "i386-pc-win32ce"
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
|
|||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
flags = fcntl(sockfd, F_GETFL, 0);
|
flags = fcntl(sockfd, F_GETFL, 0);
|
||||||
if (FALSE != nonblock)
|
if(FALSE != nonblock)
|
||||||
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
|
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||||
else
|
else
|
||||||
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
|
return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
|
||||||
@@ -165,7 +165,7 @@ int Curl_nonblock(curl_socket_t sockfd, /* operate on this */
|
|||||||
#define SETBLOCK 6
|
#define SETBLOCK 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (SETBLOCK == 0)
|
#if(SETBLOCK == 0)
|
||||||
#error "no non-blocking method was found/used/set"
|
#error "no non-blocking method was found/used/set"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Select device to bind socket to
|
* Select device to bind socket to
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
if (dev && (strlen(dev)<255) ) {
|
if(dev && (strlen(dev)<255) ) {
|
||||||
struct Curl_dns_entry *h=NULL;
|
struct Curl_dns_entry *h=NULL;
|
||||||
char myhost[256] = "";
|
char myhost[256] = "";
|
||||||
in_addr_t in;
|
in_addr_t in;
|
||||||
@@ -303,11 +303,11 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
* interfaces to go out the external interface.
|
* interfaces to go out the external interface.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (was_iface) {
|
if(was_iface) {
|
||||||
/* Only bind to the interface when specified as interface, not just as a
|
/* Only bind to the interface when specified as interface, not just as a
|
||||||
* hostname or ip address.
|
* hostname or ip address.
|
||||||
*/
|
*/
|
||||||
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
|
if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
|
||||||
dev, strlen(dev)+1) != 0) {
|
dev, strlen(dev)+1) != 0) {
|
||||||
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
|
/* printf("Failed to BINDTODEVICE, socket: %d device: %s error: %s\n",
|
||||||
sockfd, dev, Curl_strerror(SOCKERRNO)); */
|
sockfd, dev, Curl_strerror(SOCKERRNO)); */
|
||||||
@@ -323,12 +323,12 @@ static CURLcode bindlocal(struct connectdata *conn,
|
|||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
in6 = Curl_inet_pton (AF_INET6, myhost, (void *)&ipv6_addr);
|
in6 = Curl_inet_pton (AF_INET6, myhost, (void *)&ipv6_addr);
|
||||||
#endif
|
#endif
|
||||||
if (CURL_INADDR_NONE == in && -1 == in6) {
|
if(CURL_INADDR_NONE == in && -1 == in6) {
|
||||||
failf(data,"couldn't find my own IP address (%s)", myhost);
|
failf(data,"couldn't find my own IP address (%s)", myhost);
|
||||||
return CURLE_INTERFACE_FAILED;
|
return CURLE_INTERFACE_FAILED;
|
||||||
} /* end of inet_addr */
|
} /* end of inet_addr */
|
||||||
|
|
||||||
if ( h ) {
|
if( h ) {
|
||||||
Curl_addrinfo *addr = h->addr;
|
Curl_addrinfo *addr = h->addr;
|
||||||
sock = addr->ai_addr;
|
sock = addr->ai_addr;
|
||||||
socksize = addr->ai_addrlen;
|
socksize = addr->ai_addrlen;
|
||||||
@@ -433,33 +433,33 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
|
if(0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize))
|
||||||
err = SOCKERRNO;
|
err = SOCKERRNO;
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
/* Old WinCE versions don't support SO_ERROR */
|
/* Old WinCE versions don't support SO_ERROR */
|
||||||
if (WSAENOPROTOOPT == err) {
|
if(WSAENOPROTOOPT == err) {
|
||||||
SET_SOCKERRNO(0);
|
SET_SOCKERRNO(0);
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef __minix
|
#ifdef __minix
|
||||||
/* Minix 3.1.x doesn't support getsockopt on UDP sockets */
|
/* Minix 3.1.x doesn't support getsockopt on UDP sockets */
|
||||||
if (EBADIOCTL == err) {
|
if(EBADIOCTL == err) {
|
||||||
SET_SOCKERRNO(0);
|
SET_SOCKERRNO(0);
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((0 == err) || (EISCONN == err))
|
if((0 == err) || (EISCONN == err))
|
||||||
/* we are connected, awesome! */
|
/* we are connected, awesome! */
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
else
|
else
|
||||||
/* This wasn't a successful connect */
|
/* This wasn't a successful connect */
|
||||||
rc = FALSE;
|
rc = FALSE;
|
||||||
if (error)
|
if(error)
|
||||||
*error = err;
|
*error = err;
|
||||||
#else
|
#else
|
||||||
(void)sockfd;
|
(void)sockfd;
|
||||||
if (error)
|
if(error)
|
||||||
*error = SOCKERRNO;
|
*error = SOCKERRNO;
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
@@ -504,7 +504,7 @@ static bool trynextip(struct connectdata *conn,
|
|||||||
/* try the next address */
|
/* try the next address */
|
||||||
ai = conn->ip_addr->ai_next;
|
ai = conn->ip_addr->ai_next;
|
||||||
|
|
||||||
while (ai) {
|
while(ai) {
|
||||||
sockfd = singleipconnect(conn, ai, 0L, connected);
|
sockfd = singleipconnect(conn, ai, 0L, connected);
|
||||||
if(sockfd != CURL_SOCKET_BAD) {
|
if(sockfd != CURL_SOCKET_BAD) {
|
||||||
/* store the new socket descriptor */
|
/* store the new socket descriptor */
|
||||||
@@ -545,7 +545,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
|||||||
|
|
||||||
/* subtract the most strict timeout of the ones */
|
/* subtract the most strict timeout of the ones */
|
||||||
if(data->set.timeout && data->set.connecttimeout) {
|
if(data->set.timeout && data->set.connecttimeout) {
|
||||||
if (data->set.timeout < data->set.connecttimeout)
|
if(data->set.timeout < data->set.connecttimeout)
|
||||||
allow_total = allow = data->set.timeout;
|
allow_total = allow = data->set.timeout;
|
||||||
else
|
else
|
||||||
allow = data->set.connecttimeout;
|
allow = data->set.connecttimeout;
|
||||||
@@ -576,7 +576,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
|||||||
|
|
||||||
if(WAITCONN_CONNECTED == rc) {
|
if(WAITCONN_CONNECTED == rc) {
|
||||||
int error;
|
int error;
|
||||||
if (verifyconnect(sockfd, &error)) {
|
if(verifyconnect(sockfd, &error)) {
|
||||||
/* we are connected, awesome! */
|
/* we are connected, awesome! */
|
||||||
*connected = TRUE;
|
*connected = TRUE;
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
@@ -594,7 +594,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
|||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
/* nope, not connected */
|
/* nope, not connected */
|
||||||
if (WAITCONN_FDSET_ERROR == rc) {
|
if(WAITCONN_FDSET_ERROR == rc) {
|
||||||
(void)verifyconnect(sockfd, &error);
|
(void)verifyconnect(sockfd, &error);
|
||||||
data->state.os_errno = error;
|
data->state.os_errno = error;
|
||||||
infof(data, "%s\n",Curl_strerror(conn,error));
|
infof(data, "%s\n",Curl_strerror(conn,error));
|
||||||
@@ -628,7 +628,7 @@ static void tcpnodelay(struct connectdata *conn,
|
|||||||
|
|
||||||
#ifdef HAVE_GETPROTOBYNAME
|
#ifdef HAVE_GETPROTOBYNAME
|
||||||
struct protoent *pe = getprotobyname("tcp");
|
struct protoent *pe = getprotobyname("tcp");
|
||||||
if (pe)
|
if(pe)
|
||||||
proto = pe->p_proto;
|
proto = pe->p_proto;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -703,7 +703,7 @@ singleipconnect(struct connectdata *conn,
|
|||||||
CURLSOCKTYPE_IPCXN, addr);
|
CURLSOCKTYPE_IPCXN, addr);
|
||||||
else
|
else
|
||||||
sockfd = socket(addr->family, addr->socktype, addr->protocol);
|
sockfd = socket(addr->family, addr->socktype, addr->protocol);
|
||||||
if (sockfd == CURL_SOCKET_BAD)
|
if(sockfd == CURL_SOCKET_BAD)
|
||||||
return CURL_SOCKET_BAD;
|
return CURL_SOCKET_BAD;
|
||||||
|
|
||||||
*connected = FALSE; /* default is not connected */
|
*connected = FALSE; /* default is not connected */
|
||||||
@@ -728,7 +728,7 @@ singleipconnect(struct connectdata *conn,
|
|||||||
error = data->set.fsockopt(data->set.sockopt_client,
|
error = data->set.fsockopt(data->set.sockopt_client,
|
||||||
sockfd,
|
sockfd,
|
||||||
CURLSOCKTYPE_IPCXN);
|
CURLSOCKTYPE_IPCXN);
|
||||||
if (error) {
|
if(error) {
|
||||||
sclose(sockfd); /* close the socket and bail out */
|
sclose(sockfd); /* close the socket and bail out */
|
||||||
return CURL_SOCKET_BAD;
|
return CURL_SOCKET_BAD;
|
||||||
}
|
}
|
||||||
@@ -836,9 +836,9 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
|
|
||||||
/* if a timeout is set, use the most restrictive one */
|
/* if a timeout is set, use the most restrictive one */
|
||||||
|
|
||||||
if (data->set.timeout > 0)
|
if(data->set.timeout > 0)
|
||||||
timeout_set += 1;
|
timeout_set += 1;
|
||||||
if (data->set.connecttimeout > 0)
|
if(data->set.connecttimeout > 0)
|
||||||
timeout_set += 2;
|
timeout_set += 2;
|
||||||
|
|
||||||
switch (timeout_set) {
|
switch (timeout_set) {
|
||||||
@@ -849,7 +849,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
timeout_ms = data->set.connecttimeout;
|
timeout_ms = data->set.connecttimeout;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (data->set.timeout < data->set.connecttimeout)
|
if(data->set.timeout < data->set.connecttimeout)
|
||||||
timeout_ms = data->set.timeout;
|
timeout_ms = data->set.timeout;
|
||||||
else
|
else
|
||||||
timeout_ms = data->set.connecttimeout;
|
timeout_ms = data->set.connecttimeout;
|
||||||
@@ -859,7 +859,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout_set > 0) {
|
if(timeout_set > 0) {
|
||||||
/* if a timeout was already set, substract elapsed time */
|
/* if a timeout was already set, substract elapsed time */
|
||||||
timeout_ms -= Curl_tvdiff(before, data->progress.t_startsingle);
|
timeout_ms -= Curl_tvdiff(before, data->progress.t_startsingle);
|
||||||
if(timeout_ms < 0) {
|
if(timeout_ms < 0) {
|
||||||
@@ -906,7 +906,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
|||||||
before = after;
|
before = after;
|
||||||
} /* end of connect-to-each-address loop */
|
} /* end of connect-to-each-address loop */
|
||||||
|
|
||||||
if (sockfd == CURL_SOCKET_BAD) {
|
if(sockfd == CURL_SOCKET_BAD) {
|
||||||
/* no good connect was made */
|
/* no good connect was made */
|
||||||
*sockconn = CURL_SOCKET_BAD;
|
*sockconn = CURL_SOCKET_BAD;
|
||||||
failf(data, "couldn't connect to host");
|
failf(data, "couldn't connect to host");
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static CURLcode
|
|||||||
process_zlib_error(struct connectdata *conn, z_stream *z)
|
process_zlib_error(struct connectdata *conn, z_stream *z)
|
||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
if (z->msg)
|
if(z->msg)
|
||||||
failf (data, "Error while processing content unencoding: %s",
|
failf (data, "Error while processing content unencoding: %s",
|
||||||
z->msg);
|
z->msg);
|
||||||
else
|
else
|
||||||
@@ -90,7 +90,7 @@ inflate_stream(struct connectdata *conn,
|
|||||||
/* Dynamically allocate a buffer for decompression because it's uncommonly
|
/* Dynamically allocate a buffer for decompression because it's uncommonly
|
||||||
large to hold on the stack */
|
large to hold on the stack */
|
||||||
decomp = (char*)malloc(DSIZ);
|
decomp = (char*)malloc(DSIZ);
|
||||||
if (decomp == NULL) {
|
if(decomp == NULL) {
|
||||||
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,39 +102,39 @@ inflate_stream(struct connectdata *conn,
|
|||||||
z->avail_out = DSIZ;
|
z->avail_out = DSIZ;
|
||||||
|
|
||||||
status = inflate(z, Z_SYNC_FLUSH);
|
status = inflate(z, Z_SYNC_FLUSH);
|
||||||
if (status == Z_OK || status == Z_STREAM_END) {
|
if(status == Z_OK || status == Z_STREAM_END) {
|
||||||
allow_restart = 0;
|
allow_restart = 0;
|
||||||
if(DSIZ - z->avail_out) {
|
if(DSIZ - z->avail_out) {
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,
|
||||||
DSIZ - z->avail_out);
|
DSIZ - z->avail_out);
|
||||||
/* if !CURLE_OK, clean up, return */
|
/* if !CURLE_OK, clean up, return */
|
||||||
if (result) {
|
if(result) {
|
||||||
free(decomp);
|
free(decomp);
|
||||||
return exit_zlib(z, &k->zlib_init, result);
|
return exit_zlib(z, &k->zlib_init, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done? clean up, return */
|
/* Done? clean up, return */
|
||||||
if (status == Z_STREAM_END) {
|
if(status == Z_STREAM_END) {
|
||||||
free(decomp);
|
free(decomp);
|
||||||
if (inflateEnd(z) == Z_OK)
|
if(inflateEnd(z) == Z_OK)
|
||||||
return exit_zlib(z, &k->zlib_init, result);
|
return exit_zlib(z, &k->zlib_init, result);
|
||||||
else
|
else
|
||||||
return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
|
return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done with these bytes, exit */
|
/* Done with these bytes, exit */
|
||||||
if (status == Z_OK && z->avail_in == 0) {
|
if(status == Z_OK && z->avail_in == 0) {
|
||||||
free(decomp);
|
free(decomp);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (allow_restart && status == Z_DATA_ERROR) {
|
else if(allow_restart && status == Z_DATA_ERROR) {
|
||||||
/* some servers seem to not generate zlib headers, so this is an attempt
|
/* some servers seem to not generate zlib headers, so this is an attempt
|
||||||
to fix and continue anyway */
|
to fix and continue anyway */
|
||||||
|
|
||||||
(void) inflateEnd(z); /* don't care about the return code */
|
(void) inflateEnd(z); /* don't care about the return code */
|
||||||
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
|
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
|
||||||
return process_zlib_error(conn, z);
|
return process_zlib_error(conn, z);
|
||||||
}
|
}
|
||||||
z->next_in = orig_in;
|
z->next_in = orig_in;
|
||||||
@@ -158,13 +158,13 @@ Curl_unencode_deflate_write(struct connectdata *conn,
|
|||||||
z_stream *z = &k->z; /* zlib state structure */
|
z_stream *z = &k->z; /* zlib state structure */
|
||||||
|
|
||||||
/* Initialize zlib? */
|
/* Initialize zlib? */
|
||||||
if (k->zlib_init == ZLIB_UNINIT) {
|
if(k->zlib_init == ZLIB_UNINIT) {
|
||||||
z->zalloc = (alloc_func)Z_NULL;
|
z->zalloc = (alloc_func)Z_NULL;
|
||||||
z->zfree = (free_func)Z_NULL;
|
z->zfree = (free_func)Z_NULL;
|
||||||
z->opaque = 0;
|
z->opaque = 0;
|
||||||
z->next_in = NULL;
|
z->next_in = NULL;
|
||||||
z->avail_in = 0;
|
z->avail_in = 0;
|
||||||
if (inflateInit(z) != Z_OK)
|
if(inflateInit(z) != Z_OK)
|
||||||
return process_zlib_error(conn, z);
|
return process_zlib_error(conn, z);
|
||||||
k->zlib_init = ZLIB_INIT;
|
k->zlib_init = ZLIB_INIT;
|
||||||
}
|
}
|
||||||
@@ -189,16 +189,16 @@ static enum {
|
|||||||
const ssize_t totallen = len;
|
const ssize_t totallen = len;
|
||||||
|
|
||||||
/* The shortest header is 10 bytes */
|
/* The shortest header is 10 bytes */
|
||||||
if (len < 10)
|
if(len < 10)
|
||||||
return GZIP_UNDERFLOW;
|
return GZIP_UNDERFLOW;
|
||||||
|
|
||||||
if ((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1))
|
if((data[0] != GZIP_MAGIC_0) || (data[1] != GZIP_MAGIC_1))
|
||||||
return GZIP_BAD;
|
return GZIP_BAD;
|
||||||
|
|
||||||
method = data[2];
|
method = data[2];
|
||||||
flags = data[3];
|
flags = data[3];
|
||||||
|
|
||||||
if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
|
if(method != Z_DEFLATED || (flags & RESERVED) != 0) {
|
||||||
/* Can't handle this compression method or unknown flag */
|
/* Can't handle this compression method or unknown flag */
|
||||||
return GZIP_BAD;
|
return GZIP_BAD;
|
||||||
}
|
}
|
||||||
@@ -207,28 +207,28 @@ static enum {
|
|||||||
len -= 10;
|
len -= 10;
|
||||||
data += 10;
|
data += 10;
|
||||||
|
|
||||||
if (flags & EXTRA_FIELD) {
|
if(flags & EXTRA_FIELD) {
|
||||||
ssize_t extra_len;
|
ssize_t extra_len;
|
||||||
|
|
||||||
if (len < 2)
|
if(len < 2)
|
||||||
return GZIP_UNDERFLOW;
|
return GZIP_UNDERFLOW;
|
||||||
|
|
||||||
extra_len = (data[1] << 8) | data[0];
|
extra_len = (data[1] << 8) | data[0];
|
||||||
|
|
||||||
if (len < (extra_len+2))
|
if(len < (extra_len+2))
|
||||||
return GZIP_UNDERFLOW;
|
return GZIP_UNDERFLOW;
|
||||||
|
|
||||||
len -= (extra_len + 2);
|
len -= (extra_len + 2);
|
||||||
data += (extra_len + 2);
|
data += (extra_len + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & ORIG_NAME) {
|
if(flags & ORIG_NAME) {
|
||||||
/* Skip over NUL-terminated file name */
|
/* Skip over NUL-terminated file name */
|
||||||
while (len && *data) {
|
while(len && *data) {
|
||||||
--len;
|
--len;
|
||||||
++data;
|
++data;
|
||||||
}
|
}
|
||||||
if (!len || *data)
|
if(!len || *data)
|
||||||
return GZIP_UNDERFLOW;
|
return GZIP_UNDERFLOW;
|
||||||
|
|
||||||
/* Skip over the NUL */
|
/* Skip over the NUL */
|
||||||
@@ -236,13 +236,13 @@ static enum {
|
|||||||
++data;
|
++data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & COMMENT) {
|
if(flags & COMMENT) {
|
||||||
/* Skip over NUL-terminated comment */
|
/* Skip over NUL-terminated comment */
|
||||||
while (len && *data) {
|
while(len && *data) {
|
||||||
--len;
|
--len;
|
||||||
++data;
|
++data;
|
||||||
}
|
}
|
||||||
if (!len || *data)
|
if(!len || *data)
|
||||||
return GZIP_UNDERFLOW;
|
return GZIP_UNDERFLOW;
|
||||||
|
|
||||||
/* Skip over the NUL */
|
/* Skip over the NUL */
|
||||||
@@ -250,8 +250,8 @@ static enum {
|
|||||||
++data;
|
++data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & HEAD_CRC) {
|
if(flags & HEAD_CRC) {
|
||||||
if (len < 2)
|
if(len < 2)
|
||||||
return GZIP_UNDERFLOW;
|
return GZIP_UNDERFLOW;
|
||||||
|
|
||||||
len -= 2;
|
len -= 2;
|
||||||
@@ -271,30 +271,30 @@ Curl_unencode_gzip_write(struct connectdata *conn,
|
|||||||
z_stream *z = &k->z; /* zlib state structure */
|
z_stream *z = &k->z; /* zlib state structure */
|
||||||
|
|
||||||
/* Initialize zlib? */
|
/* Initialize zlib? */
|
||||||
if (k->zlib_init == ZLIB_UNINIT) {
|
if(k->zlib_init == ZLIB_UNINIT) {
|
||||||
z->zalloc = (alloc_func)Z_NULL;
|
z->zalloc = (alloc_func)Z_NULL;
|
||||||
z->zfree = (free_func)Z_NULL;
|
z->zfree = (free_func)Z_NULL;
|
||||||
z->opaque = 0;
|
z->opaque = 0;
|
||||||
z->next_in = NULL;
|
z->next_in = NULL;
|
||||||
z->avail_in = 0;
|
z->avail_in = 0;
|
||||||
|
|
||||||
if (strcmp(zlibVersion(), "1.2.0.4") >= 0) {
|
if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
|
||||||
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
|
/* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
|
||||||
if (inflateInit2(z, MAX_WBITS+32) != Z_OK) {
|
if(inflateInit2(z, MAX_WBITS+32) != Z_OK) {
|
||||||
return process_zlib_error(conn, z);
|
return process_zlib_error(conn, z);
|
||||||
}
|
}
|
||||||
k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
|
k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* we must parse the gzip header ourselves */
|
/* we must parse the gzip header ourselves */
|
||||||
if (inflateInit2(z, -MAX_WBITS) != Z_OK) {
|
if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
|
||||||
return process_zlib_error(conn, z);
|
return process_zlib_error(conn, z);
|
||||||
}
|
}
|
||||||
k->zlib_init = ZLIB_INIT; /* Initial call state */
|
k->zlib_init = ZLIB_INIT; /* Initial call state */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k->zlib_init == ZLIB_INIT_GZIP) {
|
if(k->zlib_init == ZLIB_INIT_GZIP) {
|
||||||
/* Let zlib handle the gzip decompression entirely */
|
/* Let zlib handle the gzip decompression entirely */
|
||||||
z->next_in = (Bytef *)k->str;
|
z->next_in = (Bytef *)k->str;
|
||||||
z->avail_in = (uInt)nread;
|
z->avail_in = (uInt)nread;
|
||||||
@@ -342,7 +342,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
z->avail_in = (uInt)nread;
|
z->avail_in = (uInt)nread;
|
||||||
z->next_in = malloc(z->avail_in);
|
z->next_in = malloc(z->avail_in);
|
||||||
if (z->next_in == NULL) {
|
if(z->next_in == NULL) {
|
||||||
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
memcpy(z->next_in, k->str, z->avail_in);
|
memcpy(z->next_in, k->str, z->avail_in);
|
||||||
@@ -366,7 +366,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
|
|||||||
|
|
||||||
z->avail_in += nread;
|
z->avail_in += nread;
|
||||||
z->next_in = realloc(z->next_in, z->avail_in);
|
z->next_in = realloc(z->next_in, z->avail_in);
|
||||||
if (z->next_in == NULL) {
|
if(z->next_in == NULL) {
|
||||||
free(oldblock);
|
free(oldblock);
|
||||||
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (z->avail_in == 0) {
|
if(z->avail_in == 0) {
|
||||||
/* We don't have any data to inflate; wait until next time */
|
/* We don't have any data to inflate; wait until next time */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
14
lib/cookie.c
14
lib/cookie.c
@@ -483,7 +483,7 @@ Curl_cookie_add(struct SessionHandle *data,
|
|||||||
/* It turns out, that sometimes the file format allows the path
|
/* It turns out, that sometimes the file format allows the path
|
||||||
field to remain not filled in, we try to detect this and work
|
field to remain not filled in, we try to detect this and work
|
||||||
around it! Andr<64>s Garc<72>a made us aware of this... */
|
around it! Andr<64>s Garc<72>a made us aware of this... */
|
||||||
if (strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
|
if(strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
|
||||||
/* only if the path doesn't look like a boolean option! */
|
/* only if the path doesn't look like a boolean option! */
|
||||||
co->path = strdup(ptr);
|
co->path = strdup(ptr);
|
||||||
if(!co->path)
|
if(!co->path)
|
||||||
@@ -972,7 +972,7 @@ int Curl_cookie_output(struct CookieInfo *c, const char *dumphere)
|
|||||||
|
|
||||||
while(co) {
|
while(co) {
|
||||||
format_ptr = get_netscape_format(co);
|
format_ptr = get_netscape_format(co);
|
||||||
if (format_ptr == NULL) {
|
if(format_ptr == NULL) {
|
||||||
fprintf(out, "#\n# Fatal libcurl error\n");
|
fprintf(out, "#\n# Fatal libcurl error\n");
|
||||||
fclose(out);
|
fclose(out);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -996,27 +996,27 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
|
|||||||
struct Cookie *c;
|
struct Cookie *c;
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
if ((data->cookies == NULL) ||
|
if((data->cookies == NULL) ||
|
||||||
(data->cookies->numcookies == 0))
|
(data->cookies->numcookies == 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
c = data->cookies->cookies;
|
c = data->cookies->cookies;
|
||||||
|
|
||||||
beg = list;
|
beg = list;
|
||||||
while (c) {
|
while(c) {
|
||||||
/* fill the list with _all_ the cookies we know */
|
/* fill the list with _all_ the cookies we know */
|
||||||
line = get_netscape_format(c);
|
line = get_netscape_format(c);
|
||||||
if (line == NULL) {
|
if(line == NULL) {
|
||||||
curl_slist_free_all(beg);
|
curl_slist_free_all(beg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
list = curl_slist_append(list, line);
|
list = curl_slist_append(list, line);
|
||||||
free(line);
|
free(line);
|
||||||
if (list == NULL) {
|
if(list == NULL) {
|
||||||
curl_slist_free_all(beg);
|
curl_slist_free_all(beg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (beg == NULL) {
|
else if(beg == NULL) {
|
||||||
beg = list;
|
beg = list;
|
||||||
}
|
}
|
||||||
c = c->next;
|
c = c->next;
|
||||||
|
|||||||
34
lib/dict.c
34
lib/dict.c
@@ -129,7 +129,7 @@ static char *unescape_word(struct SessionHandle *data, const char *inp)
|
|||||||
for(ptr = newp;
|
for(ptr = newp;
|
||||||
(byte = *ptr) != 0;
|
(byte = *ptr) != 0;
|
||||||
ptr++) {
|
ptr++) {
|
||||||
if ((byte <= 32) || (byte == 127) ||
|
if((byte <= 32) || (byte == 127) ||
|
||||||
(byte == '\'') || (byte == '\"') || (byte == '\\')) {
|
(byte == '\'') || (byte == '\"') || (byte == '\\')) {
|
||||||
dictp[olen++] = '\\';
|
dictp[olen++] = '\\';
|
||||||
}
|
}
|
||||||
@@ -164,35 +164,35 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
|||||||
/* AUTH is missing */
|
/* AUTH is missing */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
|
if(strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
|
||||||
strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
|
strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
|
||||||
strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
|
strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
|
||||||
|
|
||||||
word = strchr(path, ':');
|
word = strchr(path, ':');
|
||||||
if (word) {
|
if(word) {
|
||||||
word++;
|
word++;
|
||||||
database = strchr(word, ':');
|
database = strchr(word, ':');
|
||||||
if (database) {
|
if(database) {
|
||||||
*database++ = (char)0;
|
*database++ = (char)0;
|
||||||
strategy = strchr(database, ':');
|
strategy = strchr(database, ':');
|
||||||
if (strategy) {
|
if(strategy) {
|
||||||
*strategy++ = (char)0;
|
*strategy++ = (char)0;
|
||||||
nthdef = strchr(strategy, ':');
|
nthdef = strchr(strategy, ':');
|
||||||
if (nthdef) {
|
if(nthdef) {
|
||||||
*nthdef++ = (char)0;
|
*nthdef++ = (char)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((word == NULL) || (*word == (char)0)) {
|
if((word == NULL) || (*word == (char)0)) {
|
||||||
infof(data, "lookup word is missing");
|
infof(data, "lookup word is missing");
|
||||||
word=(char *)"default";
|
word=(char *)"default";
|
||||||
}
|
}
|
||||||
if ((database == NULL) || (*database == (char)0)) {
|
if((database == NULL) || (*database == (char)0)) {
|
||||||
database = (char *)"!";
|
database = (char *)"!";
|
||||||
}
|
}
|
||||||
if ((strategy == NULL) || (*strategy == (char)0)) {
|
if((strategy == NULL) || (*strategy == (char)0)) {
|
||||||
strategy = (char *)".";
|
strategy = (char *)".";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,28 +223,28 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
|||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
|
else if(strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
|
||||||
strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
|
strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
|
||||||
strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
|
strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
|
||||||
|
|
||||||
word = strchr(path, ':');
|
word = strchr(path, ':');
|
||||||
if (word) {
|
if(word) {
|
||||||
word++;
|
word++;
|
||||||
database = strchr(word, ':');
|
database = strchr(word, ':');
|
||||||
if (database) {
|
if(database) {
|
||||||
*database++ = (char)0;
|
*database++ = (char)0;
|
||||||
nthdef = strchr(database, ':');
|
nthdef = strchr(database, ':');
|
||||||
if (nthdef) {
|
if(nthdef) {
|
||||||
*nthdef++ = (char)0;
|
*nthdef++ = (char)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((word == NULL) || (*word == (char)0)) {
|
if((word == NULL) || (*word == (char)0)) {
|
||||||
infof(data, "lookup word is missing");
|
infof(data, "lookup word is missing");
|
||||||
word=(char *)"default";
|
word=(char *)"default";
|
||||||
}
|
}
|
||||||
if ((database == NULL) || (*database == (char)0)) {
|
if((database == NULL) || (*database == (char)0)) {
|
||||||
database = (char *)"!";
|
database = (char *)"!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,12 +276,12 @@ static CURLcode Curl_dict(struct connectdata *conn, bool *done)
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
ppath = strchr(path, '/');
|
ppath = strchr(path, '/');
|
||||||
if (ppath) {
|
if(ppath) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ppath++;
|
ppath++;
|
||||||
for (i = 0; ppath[i]; i++) {
|
for (i = 0; ppath[i]; i++) {
|
||||||
if (ppath[i] == ':')
|
if(ppath[i] == ':')
|
||||||
ppath[i] = ' ';
|
ppath[i] = ' ';
|
||||||
}
|
}
|
||||||
result = Curl_sendf(sockfd, conn,
|
result = Curl_sendf(sockfd, conn,
|
||||||
|
|||||||
58
lib/easy.c
58
lib/easy.c
@@ -127,7 +127,7 @@ static CURLcode win32_init(void)
|
|||||||
|
|
||||||
err = WSAStartup(wVersionRequested, &wsaData);
|
err = WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
||||||
if (err != 0)
|
if(err != 0)
|
||||||
/* Tell the user that we couldn't find a useable */
|
/* Tell the user that we couldn't find a useable */
|
||||||
/* winsock.dll. */
|
/* winsock.dll. */
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
@@ -138,7 +138,7 @@ static CURLcode win32_init(void)
|
|||||||
/* wVersionRequested in wVersion. wHighVersion contains the */
|
/* wVersionRequested in wVersion. wHighVersion contains the */
|
||||||
/* highest supported version. */
|
/* highest supported version. */
|
||||||
|
|
||||||
if ( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
|
if( LOBYTE( wsaData.wVersion ) != LOBYTE(wVersionRequested) ||
|
||||||
HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) {
|
HIBYTE( wsaData.wVersion ) != HIBYTE(wVersionRequested) ) {
|
||||||
/* Tell the user that we couldn't find a useable */
|
/* Tell the user that we couldn't find a useable */
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ static void idna_init (void)
|
|||||||
char buf[60];
|
char buf[60];
|
||||||
UINT cp = GetACP();
|
UINT cp = GetACP();
|
||||||
|
|
||||||
if (!getenv("CHARSET") && cp > 0) {
|
if(!getenv("CHARSET") && cp > 0) {
|
||||||
snprintf(buf, sizeof(buf), "CHARSET=cp%u", cp);
|
snprintf(buf, sizeof(buf), "CHARSET=cp%u", cp);
|
||||||
putenv(buf);
|
putenv(buf);
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc;
|
|||||||
*/
|
*/
|
||||||
CURLcode curl_global_init(long flags)
|
CURLcode curl_global_init(long flags)
|
||||||
{
|
{
|
||||||
if (initialized++)
|
if(initialized++)
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
/* Setup the default memory functions here (again) */
|
/* Setup the default memory functions here (again) */
|
||||||
@@ -222,14 +222,14 @@ CURLcode curl_global_init(long flags)
|
|||||||
Curl_cstrdup = (curl_strdup_callback)system_strdup;
|
Curl_cstrdup = (curl_strdup_callback)system_strdup;
|
||||||
Curl_ccalloc = (curl_calloc_callback)calloc;
|
Curl_ccalloc = (curl_calloc_callback)calloc;
|
||||||
|
|
||||||
if (flags & CURL_GLOBAL_SSL)
|
if(flags & CURL_GLOBAL_SSL)
|
||||||
if (!Curl_ssl_init()) {
|
if(!Curl_ssl_init()) {
|
||||||
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
|
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & CURL_GLOBAL_WIN32)
|
if(flags & CURL_GLOBAL_WIN32)
|
||||||
if (win32_init() != CURLE_OK) {
|
if(win32_init() != CURLE_OK) {
|
||||||
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
|
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
@@ -267,16 +267,16 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
|
|||||||
CURLcode code = CURLE_OK;
|
CURLcode code = CURLE_OK;
|
||||||
|
|
||||||
/* Invalid input, return immediately */
|
/* Invalid input, return immediately */
|
||||||
if (!m || !f || !r || !s || !c)
|
if(!m || !f || !r || !s || !c)
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
|
|
||||||
/* Already initialized, don't do it again */
|
/* Already initialized, don't do it again */
|
||||||
if ( initialized )
|
if( initialized )
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
/* Call the actual init function first */
|
/* Call the actual init function first */
|
||||||
code = curl_global_init(flags);
|
code = curl_global_init(flags);
|
||||||
if (code == CURLE_OK) {
|
if(code == CURLE_OK) {
|
||||||
Curl_cmalloc = m;
|
Curl_cmalloc = m;
|
||||||
Curl_cfree = f;
|
Curl_cfree = f;
|
||||||
Curl_cstrdup = s;
|
Curl_cstrdup = s;
|
||||||
@@ -293,18 +293,18 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
|
|||||||
*/
|
*/
|
||||||
void curl_global_cleanup(void)
|
void curl_global_cleanup(void)
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if(!initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (--initialized)
|
if(--initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Curl_global_host_cache_dtor();
|
Curl_global_host_cache_dtor();
|
||||||
|
|
||||||
if (init_flags & CURL_GLOBAL_SSL)
|
if(init_flags & CURL_GLOBAL_SSL)
|
||||||
Curl_ssl_cleanup();
|
Curl_ssl_cleanup();
|
||||||
|
|
||||||
if (init_flags & CURL_GLOBAL_WIN32)
|
if(init_flags & CURL_GLOBAL_WIN32)
|
||||||
win32_cleanup();
|
win32_cleanup();
|
||||||
|
|
||||||
#ifdef __AMIGA__
|
#ifdef __AMIGA__
|
||||||
@@ -324,7 +324,7 @@ CURL *curl_easy_init(void)
|
|||||||
struct SessionHandle *data;
|
struct SessionHandle *data;
|
||||||
|
|
||||||
/* Make sure we inited the global SSL stuff */
|
/* Make sure we inited the global SSL stuff */
|
||||||
if (!initialized) {
|
if(!initialized) {
|
||||||
res = curl_global_init(CURL_GLOBAL_DEFAULT);
|
res = curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
if(res) {
|
if(res) {
|
||||||
/* something in the global init failed, return nothing */
|
/* something in the global init failed, return nothing */
|
||||||
@@ -465,17 +465,17 @@ CURLcode curl_easy_perform(CURL *curl)
|
|||||||
if(!data)
|
if(!data)
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
|
||||||
if ( ! (data->share && data->share->hostcache) ) {
|
if( ! (data->share && data->share->hostcache) ) {
|
||||||
|
|
||||||
if (Curl_global_host_cache_use(data) &&
|
if(Curl_global_host_cache_use(data) &&
|
||||||
(data->dns.hostcachetype != HCACHE_GLOBAL)) {
|
(data->dns.hostcachetype != HCACHE_GLOBAL)) {
|
||||||
if (data->dns.hostcachetype == HCACHE_PRIVATE)
|
if(data->dns.hostcachetype == HCACHE_PRIVATE)
|
||||||
Curl_hash_destroy(data->dns.hostcache);
|
Curl_hash_destroy(data->dns.hostcache);
|
||||||
data->dns.hostcache = Curl_global_host_cache_get();
|
data->dns.hostcache = Curl_global_host_cache_get();
|
||||||
data->dns.hostcachetype = HCACHE_GLOBAL;
|
data->dns.hostcachetype = HCACHE_GLOBAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data->dns.hostcache) {
|
if(!data->dns.hostcache) {
|
||||||
data->dns.hostcachetype = HCACHE_PRIVATE;
|
data->dns.hostcachetype = HCACHE_PRIVATE;
|
||||||
data->dns.hostcache = Curl_mk_dnscache();
|
data->dns.hostcache = Curl_mk_dnscache();
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ void Curl_easy_addmulti(struct SessionHandle *data,
|
|||||||
void *multi)
|
void *multi)
|
||||||
{
|
{
|
||||||
data->multi = multi;
|
data->multi = multi;
|
||||||
if (multi == NULL)
|
if(multi == NULL)
|
||||||
/* the association is cleared, mark the easy handle as not used by an
|
/* the association is cleared, mark the easy handle as not used by an
|
||||||
interface */
|
interface */
|
||||||
data->state.used_interface = Curl_if_none;
|
data->state.used_interface = Curl_if_none;
|
||||||
@@ -579,7 +579,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
|
|||||||
outcurl->state.headersize=HEADERSIZE;
|
outcurl->state.headersize=HEADERSIZE;
|
||||||
|
|
||||||
/* copy all userdefined values */
|
/* copy all userdefined values */
|
||||||
if (Curl_dupset(outcurl, data) != CURLE_OK)
|
if(Curl_dupset(outcurl, data) != CURLE_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(data->state.used_interface == Curl_if_multi)
|
if(data->state.used_interface == Curl_if_multi)
|
||||||
@@ -600,9 +600,9 @@ CURL *curl_easy_duphandle(CURL *incurl)
|
|||||||
/* If cookies are enabled in the parent handle, we enable them
|
/* If cookies are enabled in the parent handle, we enable them
|
||||||
in the clone as well! */
|
in the clone as well! */
|
||||||
outcurl->cookies = Curl_cookie_init(data,
|
outcurl->cookies = Curl_cookie_init(data,
|
||||||
data->cookies->filename,
|
data->cookies->filename,
|
||||||
outcurl->cookies,
|
outcurl->cookies,
|
||||||
data->set.cookiesession);
|
data->set.cookiesession);
|
||||||
if(!outcurl->cookies) {
|
if(!outcurl->cookies) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -789,7 +789,7 @@ CURLcode Curl_convert_to_network(struct SessionHandle *data,
|
|||||||
in_bytes = out_bytes = length;
|
in_bytes = out_bytes = length;
|
||||||
rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes,
|
rc = iconv(data->outbound_cd, (const char**)&input_ptr, &in_bytes,
|
||||||
&output_ptr, &out_bytes);
|
&output_ptr, &out_bytes);
|
||||||
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
|
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
failf(data,
|
failf(data,
|
||||||
"The Curl_convert_to_network iconv call failed with errno %i: %s",
|
"The Curl_convert_to_network iconv call failed with errno %i: %s",
|
||||||
@@ -849,7 +849,7 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data,
|
|||||||
in_bytes = out_bytes = length;
|
in_bytes = out_bytes = length;
|
||||||
rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
|
rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
|
||||||
&output_ptr, &out_bytes);
|
&output_ptr, &out_bytes);
|
||||||
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
|
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
failf(data,
|
failf(data,
|
||||||
"The Curl_convert_from_network iconv call failed with errno %i: %s",
|
"The Curl_convert_from_network iconv call failed with errno %i: %s",
|
||||||
@@ -910,14 +910,14 @@ CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
|
|||||||
in_bytes = out_bytes = length;
|
in_bytes = out_bytes = length;
|
||||||
rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
|
rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
|
||||||
&output_ptr, &out_bytes);
|
&output_ptr, &out_bytes);
|
||||||
if ((rc == ICONV_ERROR) || (in_bytes != 0)) {
|
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
|
||||||
error = ERRNO;
|
error = ERRNO;
|
||||||
failf(data,
|
failf(data,
|
||||||
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
|
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
|
||||||
error, strerror(error));
|
error, strerror(error));
|
||||||
return CURLE_CONV_FAILED;
|
return CURLE_CONV_FAILED;
|
||||||
}
|
}
|
||||||
if (output_ptr < input_ptr) {
|
if(output_ptr < input_ptr) {
|
||||||
/* null terminate the now shorter output string */
|
/* null terminate the now shorter output string */
|
||||||
*output_ptr = 0x00;
|
*output_ptr = 0x00;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
|
|||||||
|
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
|
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
|
||||||
if (!handle ||
|
if(!handle ||
|
||||||
(Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) {
|
(Curl_convert_to_network(handle, &in, 1) != CURLE_OK)) {
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
free(ns);
|
free(ns);
|
||||||
@@ -163,7 +163,7 @@ char *curl_easy_unescape(CURL *handle, const char *string, int length,
|
|||||||
|
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
|
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */
|
||||||
if (!handle ||
|
if(!handle ||
|
||||||
(Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) {
|
(Curl_convert_from_network(handle, &in, 1) != CURLE_OK)) {
|
||||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||||
free(ns);
|
free(ns);
|
||||||
|
|||||||
32
lib/file.c
32
lib/file.c
@@ -97,6 +97,7 @@
|
|||||||
static CURLcode Curl_file(struct connectdata *, bool *done);
|
static CURLcode Curl_file(struct connectdata *, bool *done);
|
||||||
static CURLcode Curl_file_done(struct connectdata *conn,
|
static CURLcode Curl_file_done(struct connectdata *conn,
|
||||||
CURLcode status, bool premature);
|
CURLcode status, bool premature);
|
||||||
|
static CURLcode Curl_file_connect(struct connectdata *conn, bool *done);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FILE scheme handler.
|
* FILE scheme handler.
|
||||||
@@ -108,7 +109,7 @@ const struct Curl_handler Curl_handler_file = {
|
|||||||
Curl_file, /* do_it */
|
Curl_file, /* do_it */
|
||||||
Curl_file_done, /* done */
|
Curl_file_done, /* done */
|
||||||
ZERO_NULL, /* do_more */
|
ZERO_NULL, /* do_more */
|
||||||
ZERO_NULL, /* connect_it */
|
Curl_file_connect, /* connect_it */
|
||||||
ZERO_NULL, /* connecting */
|
ZERO_NULL, /* connecting */
|
||||||
ZERO_NULL, /* doing */
|
ZERO_NULL, /* doing */
|
||||||
ZERO_NULL, /* proto_getsock */
|
ZERO_NULL, /* proto_getsock */
|
||||||
@@ -123,7 +124,7 @@ const struct Curl_handler Curl_handler_file = {
|
|||||||
* do protocol-specific actions at connect-time. We emulate a
|
* do protocol-specific actions at connect-time. We emulate a
|
||||||
* connect-then-transfer protocol and "connect" to the file here
|
* connect-then-transfer protocol and "connect" to the file here
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_file_connect(struct connectdata *conn)
|
static CURLcode Curl_file_connect(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
char *real_path = curl_easy_unescape(data, data->reqdata.path, 0, NULL);
|
char *real_path = curl_easy_unescape(data, data->reqdata.path, 0, NULL);
|
||||||
@@ -141,7 +142,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
|
|||||||
sessionhandle, deal with it */
|
sessionhandle, deal with it */
|
||||||
Curl_reset_reqproto(conn);
|
Curl_reset_reqproto(conn);
|
||||||
|
|
||||||
if (!data->reqdata.proto.file) {
|
if(!data->reqdata.proto.file) {
|
||||||
file = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1);
|
file = (struct FILEPROTO *)calloc(sizeof(struct FILEPROTO), 1);
|
||||||
if(!file) {
|
if(!file) {
|
||||||
free(real_path);
|
free(real_path);
|
||||||
@@ -176,7 +177,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
|
|||||||
with a drive letter.
|
with a drive letter.
|
||||||
*/
|
*/
|
||||||
actual_path = real_path;
|
actual_path = real_path;
|
||||||
if ((actual_path[0] == '/') &&
|
if((actual_path[0] == '/') &&
|
||||||
actual_path[1] &&
|
actual_path[1] &&
|
||||||
(actual_path[2] == ':' || actual_path[2] == '|'))
|
(actual_path[2] == ':' || actual_path[2] == '|'))
|
||||||
{
|
{
|
||||||
@@ -186,7 +187,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
|
|||||||
|
|
||||||
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
|
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
|
||||||
for (i=0; actual_path[i] != '\0'; ++i)
|
for (i=0; actual_path[i] != '\0'; ++i)
|
||||||
if (actual_path[i] == '/')
|
if(actual_path[i] == '/')
|
||||||
actual_path[i] = '\\';
|
actual_path[i] = '\\';
|
||||||
|
|
||||||
fd = open(actual_path, O_RDONLY | O_BINARY); /* no CR/LF translation! */
|
fd = open(actual_path, O_RDONLY | O_BINARY); /* no CR/LF translation! */
|
||||||
@@ -203,6 +204,7 @@ CURLcode Curl_file_connect(struct connectdata *conn)
|
|||||||
Curl_file_done(conn, CURLE_FILE_COULDNT_READ_FILE, FALSE);
|
Curl_file_done(conn, CURLE_FILE_COULDNT_READ_FILE, FALSE);
|
||||||
return CURLE_FILE_COULDNT_READ_FILE;
|
return CURLE_FILE_COULDNT_READ_FILE;
|
||||||
}
|
}
|
||||||
|
*done = TRUE;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@@ -218,9 +220,6 @@ static CURLcode Curl_file_done(struct connectdata *conn,
|
|||||||
if(file->fd != -1)
|
if(file->fd != -1)
|
||||||
close(file->fd);
|
close(file->fd);
|
||||||
|
|
||||||
free(file);
|
|
||||||
conn->data->reqdata.proto.file= NULL; /* clear it! */
|
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +270,7 @@ static CURLcode file_upload(struct connectdata *conn)
|
|||||||
fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC,
|
fd = open(file->path, O_WRONLY|O_CREAT|O_TRUNC,
|
||||||
conn->data->set.new_file_perms);
|
conn->data->set.new_file_perms);
|
||||||
#endif /* !(WIN32 || MSDOS || __EMX__) */
|
#endif /* !(WIN32 || MSDOS || __EMX__) */
|
||||||
if (fd < 0) {
|
if(fd < 0) {
|
||||||
failf(data, "Can't open %s for writing", file->path);
|
failf(data, "Can't open %s for writing", file->path);
|
||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
@@ -298,13 +297,13 @@ static CURLcode file_upload(struct connectdata *conn)
|
|||||||
data->reqdata.resume_from = (curl_off_t)file_stat.st_size;
|
data->reqdata.resume_from = (curl_off_t)file_stat.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (res == CURLE_OK) {
|
while(res == CURLE_OK) {
|
||||||
int readcount;
|
int readcount;
|
||||||
res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
|
res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
|
||||||
if(res)
|
if(res)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (readcount <= 0) /* fix questionable compare error. curlvms */
|
if(readcount <= 0) /* fix questionable compare error. curlvms */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
nread = (size_t)readcount;
|
nread = (size_t)readcount;
|
||||||
@@ -379,7 +378,6 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
*done = TRUE; /* unconditionally */
|
*done = TRUE; /* unconditionally */
|
||||||
|
|
||||||
Curl_readwrite_init(conn);
|
|
||||||
Curl_initinfo(data);
|
Curl_initinfo(data);
|
||||||
Curl_pgrsStartNow(data);
|
Curl_pgrsStartNow(data);
|
||||||
|
|
||||||
@@ -436,14 +434,14 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->reqdata.resume_from <= expected_size)
|
if(data->reqdata.resume_from <= expected_size)
|
||||||
expected_size -= data->reqdata.resume_from;
|
expected_size -= data->reqdata.resume_from;
|
||||||
else {
|
else {
|
||||||
failf(data, "failed to resume file:// transfer");
|
failf(data, "failed to resume file:// transfer");
|
||||||
return CURLE_BAD_DOWNLOAD_RESUME;
|
return CURLE_BAD_DOWNLOAD_RESUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fstated && (expected_size == 0))
|
if(fstated && (expected_size == 0))
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
/* The following is a shortcut implementation of file reading
|
/* The following is a shortcut implementation of file reading
|
||||||
@@ -461,13 +459,13 @@ static CURLcode Curl_file(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||||
|
|
||||||
while (res == CURLE_OK) {
|
while(res == CURLE_OK) {
|
||||||
nread = read(fd, buf, BUFSIZE-1);
|
nread = read(fd, buf, BUFSIZE-1);
|
||||||
|
|
||||||
if ( nread > 0)
|
if( nread > 0)
|
||||||
buf[nread] = 0;
|
buf[nread] = 0;
|
||||||
|
|
||||||
if (nread <= 0)
|
if(nread <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
bytecount += nread;
|
bytecount += nread;
|
||||||
|
|||||||
@@ -25,7 +25,5 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef CURL_DISABLE_FILE
|
#ifndef CURL_DISABLE_FILE
|
||||||
extern const struct Curl_handler Curl_handler_file;
|
extern const struct Curl_handler Curl_handler_file;
|
||||||
|
|
||||||
CURLcode Curl_file_connect(struct connectdata *);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
202
lib/formdata.c
202
lib/formdata.c
@@ -187,7 +187,7 @@ AddHttpPost(char * name, size_t namelength,
|
|||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (parent_post) {
|
if(parent_post) {
|
||||||
/* now, point our 'more' to the original 'more' */
|
/* now, point our 'more' to the original 'more' */
|
||||||
post->more = parent_post->more;
|
post->more = parent_post->more;
|
||||||
|
|
||||||
@@ -224,16 +224,16 @@ static FormInfo * AddFormInfo(char *value,
|
|||||||
form_info = (FormInfo *)malloc(sizeof(FormInfo));
|
form_info = (FormInfo *)malloc(sizeof(FormInfo));
|
||||||
if(form_info) {
|
if(form_info) {
|
||||||
memset(form_info, 0, sizeof(FormInfo));
|
memset(form_info, 0, sizeof(FormInfo));
|
||||||
if (value)
|
if(value)
|
||||||
form_info->value = value;
|
form_info->value = value;
|
||||||
if (contenttype)
|
if(contenttype)
|
||||||
form_info->contenttype = contenttype;
|
form_info->contenttype = contenttype;
|
||||||
form_info->flags = HTTPPOST_FILENAME;
|
form_info->flags = HTTPPOST_FILENAME;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (parent_form_info) {
|
if(parent_form_info) {
|
||||||
/* now, point our 'more' to the original 'more' */
|
/* now, point our 'more' to the original 'more' */
|
||||||
form_info->more = parent_form_info->more;
|
form_info->more = parent_form_info->more;
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ static char *memdup(const char *src, size_t buffer_length)
|
|||||||
bool add = FALSE;
|
bool add = FALSE;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
if (buffer_length)
|
if(buffer_length)
|
||||||
length = buffer_length;
|
length = buffer_length;
|
||||||
else if(src) {
|
else if(src) {
|
||||||
length = strlen(src);
|
length = strlen(src);
|
||||||
@@ -327,13 +327,13 @@ static char *memdup(const char *src, size_t buffer_length)
|
|||||||
return strdup((char *)"");
|
return strdup((char *)"");
|
||||||
|
|
||||||
buffer = (char*)malloc(length+add);
|
buffer = (char*)malloc(length+add);
|
||||||
if (!buffer)
|
if(!buffer)
|
||||||
return NULL; /* fail */
|
return NULL; /* fail */
|
||||||
|
|
||||||
memcpy(buffer, src, length);
|
memcpy(buffer, src, length);
|
||||||
|
|
||||||
/* if length unknown do null termination */
|
/* if length unknown do null termination */
|
||||||
if (add)
|
if(add)
|
||||||
buffer[length] = '\0';
|
buffer[length] = '\0';
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
@@ -418,16 +418,16 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
/*
|
/*
|
||||||
* Loop through all the options set. Break if we have an error to report.
|
* Loop through all the options set. Break if we have an error to report.
|
||||||
*/
|
*/
|
||||||
while (return_value == CURL_FORMADD_OK) {
|
while(return_value == CURL_FORMADD_OK) {
|
||||||
|
|
||||||
/* first see if we have more parts of the array param */
|
/* first see if we have more parts of the array param */
|
||||||
if ( array_state ) {
|
if( array_state ) {
|
||||||
/* get the upcoming option from the given array */
|
/* get the upcoming option from the given array */
|
||||||
option = forms->option;
|
option = forms->option;
|
||||||
array_value = (char *)forms->value;
|
array_value = (char *)forms->value;
|
||||||
|
|
||||||
forms++; /* advance this to next entry */
|
forms++; /* advance this to next entry */
|
||||||
if (CURLFORM_END == option) {
|
if(CURLFORM_END == option) {
|
||||||
/* end of array state */
|
/* end of array state */
|
||||||
array_state = FALSE;
|
array_state = FALSE;
|
||||||
continue;
|
continue;
|
||||||
@@ -436,7 +436,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
else {
|
else {
|
||||||
/* This is not array-state, get next option */
|
/* This is not array-state, get next option */
|
||||||
option = va_arg(params, CURLformoption);
|
option = va_arg(params, CURLformoption);
|
||||||
if (CURLFORM_END == option)
|
if(CURLFORM_END == option)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +447,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
return_value = CURL_FORMADD_ILLEGAL_ARRAY;
|
return_value = CURL_FORMADD_ILLEGAL_ARRAY;
|
||||||
else {
|
else {
|
||||||
forms = va_arg(params, struct curl_forms *);
|
forms = va_arg(params, struct curl_forms *);
|
||||||
if (forms)
|
if(forms)
|
||||||
array_state = TRUE;
|
array_state = TRUE;
|
||||||
else
|
else
|
||||||
return_value = CURL_FORMADD_NULL;
|
return_value = CURL_FORMADD_NULL;
|
||||||
@@ -465,19 +465,19 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
|
current_form->flags |= HTTPPOST_PTRNAME; /* fall through */
|
||||||
#endif
|
#endif
|
||||||
case CURLFORM_COPYNAME:
|
case CURLFORM_COPYNAME:
|
||||||
if (current_form->name)
|
if(current_form->name)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else {
|
else {
|
||||||
char *name = array_state?
|
char *name = array_state?
|
||||||
array_value:va_arg(params, char *);
|
array_value:va_arg(params, char *);
|
||||||
if (name)
|
if(name)
|
||||||
current_form->name = name; /* store for the moment */
|
current_form->name = name; /* store for the moment */
|
||||||
else
|
else
|
||||||
return_value = CURL_FORMADD_NULL;
|
return_value = CURL_FORMADD_NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CURLFORM_NAMELENGTH:
|
case CURLFORM_NAMELENGTH:
|
||||||
if (current_form->namelength)
|
if(current_form->namelength)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else
|
else
|
||||||
current_form->namelength =
|
current_form->namelength =
|
||||||
@@ -490,19 +490,19 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
case CURLFORM_PTRCONTENTS:
|
case CURLFORM_PTRCONTENTS:
|
||||||
current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */
|
current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */
|
||||||
case CURLFORM_COPYCONTENTS:
|
case CURLFORM_COPYCONTENTS:
|
||||||
if (current_form->value)
|
if(current_form->value)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else {
|
else {
|
||||||
char *value =
|
char *value =
|
||||||
array_state?array_value:va_arg(params, char *);
|
array_state?array_value:va_arg(params, char *);
|
||||||
if (value)
|
if(value)
|
||||||
current_form->value = value; /* store for the moment */
|
current_form->value = value; /* store for the moment */
|
||||||
else
|
else
|
||||||
return_value = CURL_FORMADD_NULL;
|
return_value = CURL_FORMADD_NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CURLFORM_CONTENTSLENGTH:
|
case CURLFORM_CONTENTSLENGTH:
|
||||||
if (current_form->contentslength)
|
if(current_form->contentslength)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else
|
else
|
||||||
current_form->contentslength =
|
current_form->contentslength =
|
||||||
@@ -511,12 +511,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
|
|
||||||
/* Get contents from a given file name */
|
/* Get contents from a given file name */
|
||||||
case CURLFORM_FILECONTENT:
|
case CURLFORM_FILECONTENT:
|
||||||
if (current_form->flags != 0)
|
if(current_form->flags != 0)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else {
|
else {
|
||||||
const char *filename = array_state?
|
const char *filename = array_state?
|
||||||
array_value:va_arg(params, char *);
|
array_value:va_arg(params, char *);
|
||||||
if (filename) {
|
if(filename) {
|
||||||
current_form->value = strdup(filename);
|
current_form->value = strdup(filename);
|
||||||
if(!current_form->value)
|
if(!current_form->value)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
@@ -536,10 +536,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
const char *filename = array_state?array_value:
|
const char *filename = array_state?array_value:
|
||||||
va_arg(params, char *);
|
va_arg(params, char *);
|
||||||
|
|
||||||
if (current_form->value) {
|
if(current_form->value) {
|
||||||
if (current_form->flags & HTTPPOST_FILENAME) {
|
if(current_form->flags & HTTPPOST_FILENAME) {
|
||||||
if (filename) {
|
if(filename) {
|
||||||
if ((current_form = AddFormInfo(strdup(filename),
|
if((current_form = AddFormInfo(strdup(filename),
|
||||||
NULL, current_form)) == NULL)
|
NULL, current_form)) == NULL)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -550,7 +550,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (filename) {
|
if(filename) {
|
||||||
current_form->value = strdup(filename);
|
current_form->value = strdup(filename);
|
||||||
if(!current_form->value)
|
if(!current_form->value)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
@@ -570,10 +570,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
const char *filename = array_state?array_value:
|
const char *filename = array_state?array_value:
|
||||||
va_arg(params, char *);
|
va_arg(params, char *);
|
||||||
|
|
||||||
if (current_form->value) {
|
if(current_form->value) {
|
||||||
if (current_form->flags & HTTPPOST_BUFFER) {
|
if(current_form->flags & HTTPPOST_BUFFER) {
|
||||||
if (filename) {
|
if(filename) {
|
||||||
if ((current_form = AddFormInfo(strdup(filename),
|
if((current_form = AddFormInfo(strdup(filename),
|
||||||
NULL, current_form)) == NULL)
|
NULL, current_form)) == NULL)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -584,7 +584,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (filename) {
|
if(filename) {
|
||||||
current_form->value = strdup(filename);
|
current_form->value = strdup(filename);
|
||||||
if(!current_form->value)
|
if(!current_form->value)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
@@ -598,12 +598,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
|
|
||||||
case CURLFORM_BUFFERPTR:
|
case CURLFORM_BUFFERPTR:
|
||||||
current_form->flags |= HTTPPOST_PTRBUFFER;
|
current_form->flags |= HTTPPOST_PTRBUFFER;
|
||||||
if (current_form->buffer)
|
if(current_form->buffer)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else {
|
else {
|
||||||
char *buffer =
|
char *buffer =
|
||||||
array_state?array_value:va_arg(params, char *);
|
array_state?array_value:va_arg(params, char *);
|
||||||
if (buffer)
|
if(buffer)
|
||||||
current_form->buffer = buffer; /* store for the moment */
|
current_form->buffer = buffer; /* store for the moment */
|
||||||
else
|
else
|
||||||
return_value = CURL_FORMADD_NULL;
|
return_value = CURL_FORMADD_NULL;
|
||||||
@@ -611,7 +611,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLFORM_BUFFERLENGTH:
|
case CURLFORM_BUFFERLENGTH:
|
||||||
if (current_form->bufferlength)
|
if(current_form->bufferlength)
|
||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
else
|
else
|
||||||
current_form->bufferlength =
|
current_form->bufferlength =
|
||||||
@@ -622,10 +622,10 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
{
|
{
|
||||||
const char *contenttype =
|
const char *contenttype =
|
||||||
array_state?array_value:va_arg(params, char *);
|
array_state?array_value:va_arg(params, char *);
|
||||||
if (current_form->contenttype) {
|
if(current_form->contenttype) {
|
||||||
if (current_form->flags & HTTPPOST_FILENAME) {
|
if(current_form->flags & HTTPPOST_FILENAME) {
|
||||||
if (contenttype) {
|
if(contenttype) {
|
||||||
if ((current_form = AddFormInfo(NULL,
|
if((current_form = AddFormInfo(NULL,
|
||||||
strdup(contenttype),
|
strdup(contenttype),
|
||||||
current_form)) == NULL)
|
current_form)) == NULL)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
@@ -637,7 +637,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
return_value = CURL_FORMADD_OPTION_TWICE;
|
return_value = CURL_FORMADD_OPTION_TWICE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (contenttype) {
|
if(contenttype) {
|
||||||
current_form->contenttype = strdup(contenttype);
|
current_form->contenttype = strdup(contenttype);
|
||||||
if(!current_form->contenttype)
|
if(!current_form->contenttype)
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
@@ -692,7 +692,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
for(form = first_form;
|
for(form = first_form;
|
||||||
form != NULL;
|
form != NULL;
|
||||||
form = form->more) {
|
form = form->more) {
|
||||||
if ( ((!form->name || !form->value) && !post) ||
|
if( ((!form->name || !form->value) && !post) ||
|
||||||
( (form->contentslength) &&
|
( (form->contentslength) &&
|
||||||
(form->flags & HTTPPOST_FILENAME) ) ||
|
(form->flags & HTTPPOST_FILENAME) ) ||
|
||||||
( (form->flags & HTTPPOST_FILENAME) &&
|
( (form->flags & HTTPPOST_FILENAME) &&
|
||||||
@@ -709,7 +709,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( ((form->flags & HTTPPOST_FILENAME) ||
|
if( ((form->flags & HTTPPOST_FILENAME) ||
|
||||||
(form->flags & HTTPPOST_BUFFER)) &&
|
(form->flags & HTTPPOST_BUFFER)) &&
|
||||||
!form->contenttype ) {
|
!form->contenttype ) {
|
||||||
/* our contenttype is missing */
|
/* our contenttype is missing */
|
||||||
@@ -721,23 +721,23 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
}
|
}
|
||||||
form->contenttype_alloc = TRUE;
|
form->contenttype_alloc = TRUE;
|
||||||
}
|
}
|
||||||
if ( !(form->flags & HTTPPOST_PTRNAME) &&
|
if( !(form->flags & HTTPPOST_PTRNAME) &&
|
||||||
(form == first_form) ) {
|
(form == first_form) ) {
|
||||||
/* copy name (without strdup; possibly contains null characters) */
|
/* copy name (without strdup; possibly contains null characters) */
|
||||||
form->name = memdup(form->name, form->namelength);
|
form->name = memdup(form->name, form->namelength);
|
||||||
if (!form->name) {
|
if(!form->name) {
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
form->name_alloc = TRUE;
|
form->name_alloc = TRUE;
|
||||||
}
|
}
|
||||||
if ( !(form->flags & HTTPPOST_FILENAME) &&
|
if( !(form->flags & HTTPPOST_FILENAME) &&
|
||||||
!(form->flags & HTTPPOST_READFILE) &&
|
!(form->flags & HTTPPOST_READFILE) &&
|
||||||
!(form->flags & HTTPPOST_PTRCONTENTS) &&
|
!(form->flags & HTTPPOST_PTRCONTENTS) &&
|
||||||
!(form->flags & HTTPPOST_PTRBUFFER) ) {
|
!(form->flags & HTTPPOST_PTRBUFFER) ) {
|
||||||
/* copy value (without strdup; possibly contains null characters) */
|
/* copy value (without strdup; possibly contains null characters) */
|
||||||
form->value = memdup(form->value, form->contentslength);
|
form->value = memdup(form->value, form->contentslength);
|
||||||
if (!form->value) {
|
if(!form->value) {
|
||||||
return_value = CURL_FORMADD_MEMORY;
|
return_value = CURL_FORMADD_MEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -756,7 +756,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form->contenttype)
|
if(form->contenttype)
|
||||||
prevtype = form->contenttype;
|
prevtype = form->contenttype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -780,7 +780,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
|
|
||||||
/* always delete the allocated memory before returning */
|
/* always delete the allocated memory before returning */
|
||||||
form = first_form;
|
form = first_form;
|
||||||
while (form != NULL) {
|
while(form != NULL) {
|
||||||
FormInfo *delete_form;
|
FormInfo *delete_form;
|
||||||
|
|
||||||
delete_form = form;
|
delete_form = form;
|
||||||
@@ -820,7 +820,7 @@ static CURLcode AddFormData(struct FormData **formp,
|
|||||||
{
|
{
|
||||||
struct FormData *newform = (struct FormData *)
|
struct FormData *newform = (struct FormData *)
|
||||||
malloc(sizeof(struct FormData));
|
malloc(sizeof(struct FormData));
|
||||||
if (!newform)
|
if(!newform)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
newform->next = NULL;
|
newform->next = NULL;
|
||||||
|
|
||||||
@@ -829,7 +829,7 @@ static CURLcode AddFormData(struct FormData **formp,
|
|||||||
length = strlen((char *)line);
|
length = strlen((char *)line);
|
||||||
|
|
||||||
newform->line = (char *)malloc(length+1);
|
newform->line = (char *)malloc(length+1);
|
||||||
if (!newform->line) {
|
if(!newform->line) {
|
||||||
free(newform);
|
free(newform);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -845,7 +845,7 @@ static CURLcode AddFormData(struct FormData **formp,
|
|||||||
else
|
else
|
||||||
*formp = newform;
|
*formp = newform;
|
||||||
|
|
||||||
if (size) {
|
if(size) {
|
||||||
if((type == FORM_DATA) || (type == FORM_CONTENT))
|
if((type == FORM_DATA) || (type == FORM_CONTENT))
|
||||||
*size += length;
|
*size += length;
|
||||||
else {
|
else {
|
||||||
@@ -896,7 +896,7 @@ void Curl_formclean(struct FormData **form_ptr)
|
|||||||
free(form->line); /* free the line */
|
free(form->line); /* free the line */
|
||||||
free(form); /* free the struct */
|
free(form); /* free the struct */
|
||||||
|
|
||||||
} while ((form = next) != NULL); /* continue */
|
} while((form = next) != NULL); /* continue */
|
||||||
|
|
||||||
*form_ptr = NULL;
|
*form_ptr = NULL;
|
||||||
}
|
}
|
||||||
@@ -920,13 +920,13 @@ CURLcode Curl_formconvert(struct SessionHandle *data, struct FormData *form)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
next=form->next; /* the following form line */
|
next=form->next; /* the following form line */
|
||||||
if (form->type == FORM_DATA) {
|
if(form->type == FORM_DATA) {
|
||||||
rc = Curl_convert_to_network(data, form->line, form->length);
|
rc = Curl_convert_to_network(data, form->line, form->length);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if (rc != CURLE_OK)
|
if(rc != CURLE_OK)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
} while ((form = next) != NULL); /* continue */
|
} while((form = next) != NULL); /* continue */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
@@ -944,11 +944,11 @@ int curl_formget(struct curl_httppost *form, void *arg,
|
|||||||
struct FormData *data, *ptr;
|
struct FormData *data, *ptr;
|
||||||
|
|
||||||
rc = Curl_getFormData(&data, form, NULL, &size);
|
rc = Curl_getFormData(&data, form, NULL, &size);
|
||||||
if (rc != CURLE_OK)
|
if(rc != CURLE_OK)
|
||||||
return (int)rc;
|
return (int)rc;
|
||||||
|
|
||||||
for (ptr = data; ptr; ptr = ptr->next) {
|
for (ptr = data; ptr; ptr = ptr->next) {
|
||||||
if (ptr->type == FORM_FILE) {
|
if(ptr->type == FORM_FILE) {
|
||||||
char buffer[8192];
|
char buffer[8192];
|
||||||
size_t nread;
|
size_t nread;
|
||||||
struct Form temp;
|
struct Form temp;
|
||||||
@@ -957,16 +957,16 @@ int curl_formget(struct curl_httppost *form, void *arg,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
nread = readfromfile(&temp, buffer, sizeof(buffer));
|
nread = readfromfile(&temp, buffer, sizeof(buffer));
|
||||||
if ((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
|
if((nread == (size_t) -1) || (nread != append(arg, buffer, nread))) {
|
||||||
if (temp.fp) {
|
if(temp.fp) {
|
||||||
fclose(temp.fp);
|
fclose(temp.fp);
|
||||||
}
|
}
|
||||||
Curl_formclean(&data);
|
Curl_formclean(&data);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} while (nread == sizeof(buffer));
|
} while(nread == sizeof(buffer));
|
||||||
} else {
|
} else {
|
||||||
if (ptr->length != append(arg, ptr->line, ptr->length)) {
|
if(ptr->length != append(arg, ptr->line, ptr->length)) {
|
||||||
Curl_formclean(&data);
|
Curl_formclean(&data);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1005,7 +1005,7 @@ void curl_formfree(struct curl_httppost *form)
|
|||||||
free(form->showfilename); /* free the faked file name */
|
free(form->showfilename); /* free the faked file name */
|
||||||
free(form); /* free the struct */
|
free(form); /* free the struct */
|
||||||
|
|
||||||
} while ((form = next) != NULL); /* continue */
|
} while((form = next) != NULL); /* continue */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_BASENAME
|
#ifndef HAVE_BASENAME
|
||||||
@@ -1110,7 +1110,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
"Content-Type: multipart/form-data",
|
"Content-Type: multipart/form-data",
|
||||||
boundary);
|
boundary);
|
||||||
|
|
||||||
if (result) {
|
if(result) {
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1123,13 +1123,13 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
|
|
||||||
if(size) {
|
if(size) {
|
||||||
result = AddFormDataf(&form, &size, "\r\n");
|
result = AddFormDataf(&form, &size, "\r\n");
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* boundary */
|
/* boundary */
|
||||||
result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
|
result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Maybe later this should be disabled when a custom_content_type is
|
/* Maybe later this should be disabled when a custom_content_type is
|
||||||
@@ -1138,16 +1138,16 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
*/
|
*/
|
||||||
result = AddFormDataf(&form, &size,
|
result = AddFormDataf(&form, &size,
|
||||||
"Content-Disposition: form-data; name=\"");
|
"Content-Disposition: form-data; name=\"");
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
|
result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
|
||||||
&size);
|
&size);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
result = AddFormDataf(&form, &size, "\"");
|
result = AddFormDataf(&form, &size, "\"");
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(post->more) {
|
if(post->more) {
|
||||||
@@ -1160,7 +1160,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
"\r\nContent-Type: multipart/mixed,"
|
"\r\nContent-Type: multipart/mixed,"
|
||||||
" boundary=%s\r\n",
|
" boundary=%s\r\n",
|
||||||
fileboundary);
|
fileboundary);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1183,9 +1183,9 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
fileboundary,
|
fileboundary,
|
||||||
(file->showfilename?file->showfilename:
|
(file->showfilename?file->showfilename:
|
||||||
filebasename));
|
filebasename));
|
||||||
if (filebasename)
|
if(filebasename)
|
||||||
free(filebasename);
|
free(filebasename);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if((post->flags & HTTPPOST_FILENAME) ||
|
else if((post->flags & HTTPPOST_FILENAME) ||
|
||||||
@@ -1198,10 +1198,10 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
"; filename=\"%s\"",
|
"; filename=\"%s\"",
|
||||||
(post->showfilename?post->showfilename:
|
(post->showfilename?post->showfilename:
|
||||||
filebasename));
|
filebasename));
|
||||||
if (filebasename)
|
if(filebasename)
|
||||||
free(filebasename);
|
free(filebasename);
|
||||||
|
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1210,7 +1210,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
result = AddFormDataf(&form, &size,
|
result = AddFormDataf(&form, &size,
|
||||||
"\r\nContent-Type: %s",
|
"\r\nContent-Type: %s",
|
||||||
file->contenttype);
|
file->contenttype);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1218,11 +1218,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
while( curList ) {
|
while( curList ) {
|
||||||
/* Process the additional headers specified for this form */
|
/* Process the additional headers specified for this form */
|
||||||
result = AddFormDataf( &form, &size, "\r\n%s", curList->data );
|
result = AddFormDataf( &form, &size, "\r\n%s", curList->data );
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
curList = curList->next;
|
curList = curList->next;
|
||||||
}
|
}
|
||||||
if (result) {
|
if(result) {
|
||||||
Curl_formclean(&firstform);
|
Curl_formclean(&firstform);
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
@@ -1240,13 +1240,13 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
/* this is not a text content, mention our binary encoding */
|
/* this is not a text content, mention our binary encoding */
|
||||||
result = AddFormDataf(&form, &size,
|
result = AddFormDataf(&form, &size,
|
||||||
"\r\nContent-Transfer-Encoding: binary");
|
"\r\nContent-Transfer-Encoding: binary");
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result = AddFormDataf(&form, &size, "\r\n\r\n");
|
result = AddFormDataf(&form, &size, "\r\n\r\n");
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if((post->flags & HTTPPOST_FILENAME) ||
|
if((post->flags & HTTPPOST_FILENAME) ||
|
||||||
@@ -1278,14 +1278,14 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
*/
|
*/
|
||||||
size_t nread;
|
size_t nread;
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
while ((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
|
while((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
|
||||||
result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
|
result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if(result) {
|
||||||
Curl_formclean(&firstform);
|
Curl_formclean(&firstform);
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
@@ -1305,11 +1305,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (post->flags & HTTPPOST_BUFFER) {
|
else if(post->flags & HTTPPOST_BUFFER) {
|
||||||
/* include contents of buffer */
|
/* include contents of buffer */
|
||||||
result = AddFormData(&form, FORM_CONTENT, post->buffer,
|
result = AddFormData(&form, FORM_CONTENT, post->buffer,
|
||||||
post->bufferlength, &size);
|
post->bufferlength, &size);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1317,11 +1317,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
/* include the contents we got */
|
/* include the contents we got */
|
||||||
result = AddFormData(&form, FORM_CONTENT, post->contents,
|
result = AddFormData(&form, FORM_CONTENT, post->contents,
|
||||||
post->contentslength, &size);
|
post->contentslength, &size);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while ((file = file->more) != NULL); /* for each specified file for this field */
|
} while((file = file->more) != NULL); /* for each specified file for this field */
|
||||||
if (result) {
|
if(result) {
|
||||||
Curl_formclean(&firstform);
|
Curl_formclean(&firstform);
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
@@ -1334,12 +1334,12 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
"\r\n--%s--",
|
"\r\n--%s--",
|
||||||
fileboundary);
|
fileboundary);
|
||||||
free(fileboundary);
|
free(fileboundary);
|
||||||
if (result)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ((post = post->next) != NULL); /* for each field */
|
} while((post = post->next) != NULL); /* for each field */
|
||||||
if (result) {
|
if(result) {
|
||||||
Curl_formclean(&firstform);
|
Curl_formclean(&firstform);
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
@@ -1349,7 +1349,7 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
result = AddFormDataf(&form, &size,
|
result = AddFormDataf(&form, &size,
|
||||||
"\r\n--%s--\r\n",
|
"\r\n--%s--\r\n",
|
||||||
boundary);
|
boundary);
|
||||||
if (result) {
|
if(result) {
|
||||||
Curl_formclean(&firstform);
|
Curl_formclean(&firstform);
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
@@ -1488,7 +1488,7 @@ int FormAddTest(const char * errormsg,
|
|||||||
int result;
|
int result;
|
||||||
va_list arg;
|
va_list arg;
|
||||||
va_start(arg, last_post);
|
va_start(arg, last_post);
|
||||||
if ((result = FormAdd(httppost, last_post, arg)))
|
if((result = FormAdd(httppost, last_post, arg)))
|
||||||
fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result,
|
fprintf (stderr, "ERROR doing FormAdd ret: %d action: %s\n", result,
|
||||||
errormsg);
|
errormsg);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
@@ -1539,11 +1539,11 @@ int main(int argc, argv_item_t argv[])
|
|||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
|
|
||||||
if (FormAddTest("simple COPYCONTENTS test", &httppost, &last_post,
|
if(FormAddTest("simple COPYCONTENTS test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name1, CURLFORM_COPYCONTENTS, value1,
|
CURLFORM_COPYNAME, name1, CURLFORM_COPYCONTENTS, value1,
|
||||||
CURLFORM_END))
|
CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
if (FormAddTest("COPYCONTENTS + CONTENTTYPE test", &httppost, &last_post,
|
if(FormAddTest("COPYCONTENTS + CONTENTTYPE test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2,
|
CURLFORM_COPYNAME, name2, CURLFORM_COPYCONTENTS, value2,
|
||||||
CURLFORM_CONTENTTYPE, type2, CURLFORM_END))
|
CURLFORM_CONTENTTYPE, type2, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
@@ -1551,41 +1551,41 @@ int main(int argc, argv_item_t argv[])
|
|||||||
correctly */
|
correctly */
|
||||||
name3[1] = '\0';
|
name3[1] = '\0';
|
||||||
value3[1] = '\0';
|
value3[1] = '\0';
|
||||||
if (FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test",
|
if(FormAddTest("PTRNAME + NAMELENGTH + COPYNAME + CONTENTSLENGTH test",
|
||||||
&httppost, &last_post,
|
&httppost, &last_post,
|
||||||
CURLFORM_PTRNAME, name3, CURLFORM_COPYCONTENTS, value3,
|
CURLFORM_PTRNAME, name3, CURLFORM_COPYCONTENTS, value3,
|
||||||
CURLFORM_CONTENTSLENGTH, value3length,
|
CURLFORM_CONTENTSLENGTH, value3length,
|
||||||
CURLFORM_NAMELENGTH, name3length, CURLFORM_END))
|
CURLFORM_NAMELENGTH, name3length, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
if (FormAddTest("simple PTRCONTENTS test", &httppost, &last_post,
|
if(FormAddTest("simple PTRCONTENTS test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name4, CURLFORM_PTRCONTENTS, value4,
|
CURLFORM_COPYNAME, name4, CURLFORM_PTRCONTENTS, value4,
|
||||||
CURLFORM_END))
|
CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
/* make null character at start to check that contentslength works
|
/* make null character at start to check that contentslength works
|
||||||
correctly */
|
correctly */
|
||||||
value5[1] = '\0';
|
value5[1] = '\0';
|
||||||
if (FormAddTest("PTRCONTENTS + CONTENTSLENGTH test", &httppost, &last_post,
|
if(FormAddTest("PTRCONTENTS + CONTENTSLENGTH test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name5, CURLFORM_PTRCONTENTS, value5,
|
CURLFORM_COPYNAME, name5, CURLFORM_PTRCONTENTS, value5,
|
||||||
CURLFORM_CONTENTSLENGTH, value5length, CURLFORM_END))
|
CURLFORM_CONTENTSLENGTH, value5length, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
/* make null character at start to check that contentslength works
|
/* make null character at start to check that contentslength works
|
||||||
correctly */
|
correctly */
|
||||||
value6[1] = '\0';
|
value6[1] = '\0';
|
||||||
if (FormAddTest("PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE test",
|
if(FormAddTest("PTRCONTENTS + CONTENTSLENGTH + CONTENTTYPE test",
|
||||||
&httppost, &last_post,
|
&httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name6, CURLFORM_PTRCONTENTS, value6,
|
CURLFORM_COPYNAME, name6, CURLFORM_PTRCONTENTS, value6,
|
||||||
CURLFORM_CONTENTSLENGTH, value6length,
|
CURLFORM_CONTENTSLENGTH, value6length,
|
||||||
CURLFORM_CONTENTTYPE, type6, CURLFORM_END))
|
CURLFORM_CONTENTTYPE, type6, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
if (FormAddTest("FILE + CONTENTTYPE test", &httppost, &last_post,
|
if(FormAddTest("FILE + CONTENTTYPE test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name7, CURLFORM_FILE, value7,
|
CURLFORM_COPYNAME, name7, CURLFORM_FILE, value7,
|
||||||
CURLFORM_CONTENTTYPE, type7, CURLFORM_END))
|
CURLFORM_CONTENTTYPE, type7, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
if (FormAddTest("FILE1 + FILE2 test", &httppost, &last_post,
|
if(FormAddTest("FILE1 + FILE2 test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name8, CURLFORM_FILE, value7,
|
CURLFORM_COPYNAME, name8, CURLFORM_FILE, value7,
|
||||||
CURLFORM_FILE, value8, CURLFORM_END))
|
CURLFORM_FILE, value8, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
if (FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post,
|
if(FormAddTest("FILE1 + FILE2 + FILE3 test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7,
|
CURLFORM_COPYNAME, name9, CURLFORM_FILE, value7,
|
||||||
CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END))
|
CURLFORM_FILE, value8, CURLFORM_FILE, value7, CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
@@ -1596,11 +1596,11 @@ int main(int argc, argv_item_t argv[])
|
|||||||
forms[2].option = CURLFORM_FILE;
|
forms[2].option = CURLFORM_FILE;
|
||||||
forms[2].value = value7;
|
forms[2].value = value7;
|
||||||
forms[3].option = CURLFORM_END;
|
forms[3].option = CURLFORM_END;
|
||||||
if (FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post,
|
if(FormAddTest("FILE1 + FILE2 + FILE3 ARRAY test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name10, CURLFORM_ARRAY, forms,
|
CURLFORM_COPYNAME, name10, CURLFORM_ARRAY, forms,
|
||||||
CURLFORM_END))
|
CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
if (FormAddTest("FILECONTENT test", &httppost, &last_post,
|
if(FormAddTest("FILECONTENT test", &httppost, &last_post,
|
||||||
CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7,
|
CURLFORM_COPYNAME, name11, CURLFORM_FILECONTENT, value7,
|
||||||
CURLFORM_END))
|
CURLFORM_END))
|
||||||
++errors;
|
++errors;
|
||||||
@@ -1628,7 +1628,7 @@ int main(int argc, argv_item_t argv[])
|
|||||||
fprintf(stdout, "size: ");
|
fprintf(stdout, "size: ");
|
||||||
fprintf(stdout, CURL_FORMAT_OFF_T, size);
|
fprintf(stdout, CURL_FORMAT_OFF_T, size);
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
if (errors)
|
if(errors)
|
||||||
fprintf(stdout, "\n==> %d Test(s) failed!\n", errors);
|
fprintf(stdout, "\n==> %d Test(s) failed!\n", errors);
|
||||||
else
|
else
|
||||||
fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n");
|
fprintf(stdout, "\nAll Tests seem to have worked (please check output)\n");
|
||||||
|
|||||||
128
lib/ftp.c
128
lib/ftp.c
@@ -111,7 +111,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CURL_DISABLE_VERBOSE_STRINGS
|
#ifdef CURL_DISABLE_VERBOSE_STRINGS
|
||||||
#define ftp_pasv_verbose(a,b,c,d) do { } while (0)
|
#define ftp_pasv_verbose(a,b,c,d) do { } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Local API functions */
|
/* Local API functions */
|
||||||
@@ -152,9 +152,9 @@ static CURLcode Curl_ftps_setup_connection(struct connectdata * conn);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* easy-to-use macro: */
|
/* easy-to-use macro: */
|
||||||
#define FTPSENDF(x,y,z) if ((result = Curl_ftpsendf(x,y,z)) != CURLE_OK) \
|
#define FTPSENDF(x,y,z) if((result = Curl_ftpsendf(x,y,z)) != CURLE_OK) \
|
||||||
return result
|
return result
|
||||||
#define NBFTPSENDF(x,y,z) if ((result = Curl_nbftpsendf(x,y,z)) != CURLE_OK) \
|
#define NBFTPSENDF(x,y,z) if((result = Curl_nbftpsendf(x,y,z)) != CURLE_OK) \
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -307,9 +307,9 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
|||||||
|
|
||||||
/* if a timeout is set, use the most restrictive one */
|
/* if a timeout is set, use the most restrictive one */
|
||||||
|
|
||||||
if (data->set.timeout > 0)
|
if(data->set.timeout > 0)
|
||||||
timeout_set += 1;
|
timeout_set += 1;
|
||||||
if (data->set.connecttimeout > 0)
|
if(data->set.connecttimeout > 0)
|
||||||
timeout_set += 2;
|
timeout_set += 2;
|
||||||
|
|
||||||
switch (timeout_set) {
|
switch (timeout_set) {
|
||||||
@@ -320,7 +320,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
|||||||
timeout_ms = data->set.connecttimeout;
|
timeout_ms = data->set.connecttimeout;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (data->set.timeout < data->set.connecttimeout)
|
if(data->set.timeout < data->set.connecttimeout)
|
||||||
timeout_ms = data->set.timeout;
|
timeout_ms = data->set.timeout;
|
||||||
else
|
else
|
||||||
timeout_ms = data->set.connecttimeout;
|
timeout_ms = data->set.connecttimeout;
|
||||||
@@ -330,7 +330,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout_set > 0) {
|
if(timeout_set > 0) {
|
||||||
/* if a timeout was already set, substract elapsed time */
|
/* if a timeout was already set, substract elapsed time */
|
||||||
timeout_ms -= Curl_tvdiff(Curl_tvnow(), conn->now);
|
timeout_ms -= Curl_tvdiff(Curl_tvnow(), conn->now);
|
||||||
if(timeout_ms < 0) {
|
if(timeout_ms < 0) {
|
||||||
@@ -366,7 +366,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
sclose(sock); /* close the first socket */
|
sclose(sock); /* close the first socket */
|
||||||
|
|
||||||
if (CURL_SOCKET_BAD == s) {
|
if(CURL_SOCKET_BAD == s) {
|
||||||
/* DIE! */
|
/* DIE! */
|
||||||
failf(data, "Error accept()ing server connect");
|
failf(data, "Error accept()ing server connect");
|
||||||
return CURLE_FTP_PORT_FAILED;
|
return CURLE_FTP_PORT_FAILED;
|
||||||
@@ -643,7 +643,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
|
|||||||
size_t nread;
|
size_t nread;
|
||||||
int cache_skip=0;
|
int cache_skip=0;
|
||||||
|
|
||||||
if (ftpcode)
|
if(ftpcode)
|
||||||
*ftpcode = 0; /* 0 for errors */
|
*ftpcode = 0; /* 0 for errors */
|
||||||
|
|
||||||
*nreadp=0;
|
*nreadp=0;
|
||||||
@@ -846,7 +846,7 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
|
|||||||
result = ftp_state_post_cwd(conn);
|
result = ftp_state_post_cwd(conn);
|
||||||
else {
|
else {
|
||||||
ftpc->count2 = 0;
|
ftpc->count2 = 0;
|
||||||
if (conn->bits.reuse && ftpc->entrypath) {
|
if(conn->bits.reuse && ftpc->entrypath) {
|
||||||
/* This is a re-used connection. Since we change directory to where the
|
/* This is a re-used connection. Since we change directory to where the
|
||||||
transfer is taking place, we must first get back to the original dir
|
transfer is taking place, we must first get back to the original dir
|
||||||
where we ended up after login: */
|
where we ended up after login: */
|
||||||
@@ -922,13 +922,13 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
the IP from the control connection */
|
the IP from the control connection */
|
||||||
|
|
||||||
sslen = sizeof(ss);
|
sslen = sizeof(ss);
|
||||||
if (getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
|
if(getsockname(conn->sock[FIRSTSOCKET], (struct sockaddr *)&ss, &sslen)) {
|
||||||
failf(data, "getsockname() failed: %s",
|
failf(data, "getsockname() failed: %s",
|
||||||
Curl_strerror(conn, SOCKERRNO) );
|
Curl_strerror(conn, SOCKERRNO) );
|
||||||
return CURLE_FTP_PORT_FAILED;
|
return CURLE_FTP_PORT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sslen > (socklen_t)sizeof(ss))
|
if(sslen > (socklen_t)sizeof(ss))
|
||||||
sslen = sizeof(ss);
|
sslen = sizeof(ss);
|
||||||
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL,
|
rc = getnameinfo((struct sockaddr *)&ss, sslen, hbuf, sizeof(hbuf), NULL,
|
||||||
0, NIFLAGS);
|
0, NIFLAGS);
|
||||||
@@ -960,11 +960,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
/*
|
/*
|
||||||
* Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
|
* Workaround for AIX5 getaddrinfo() problem (it doesn't set ai_socktype):
|
||||||
*/
|
*/
|
||||||
if (ai->ai_socktype == 0)
|
if(ai->ai_socktype == 0)
|
||||||
ai->ai_socktype = conn->socktype;
|
ai->ai_socktype = conn->socktype;
|
||||||
|
|
||||||
portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
portsock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
||||||
if (portsock == CURL_SOCKET_BAD) {
|
if(portsock == CURL_SOCKET_BAD) {
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -978,11 +978,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
/* step 3, bind to a suitable local address */
|
/* step 3, bind to a suitable local address */
|
||||||
|
|
||||||
/* Try binding the given address. */
|
/* Try binding the given address. */
|
||||||
if (bind(portsock, ai->ai_addr, ai->ai_addrlen)) {
|
if(bind(portsock, ai->ai_addr, ai->ai_addrlen)) {
|
||||||
|
|
||||||
/* It failed. Bind the address used for the control connection instead */
|
/* It failed. Bind the address used for the control connection instead */
|
||||||
sslen = sizeof(ss);
|
sslen = sizeof(ss);
|
||||||
if (getsockname(conn->sock[FIRSTSOCKET],
|
if(getsockname(conn->sock[FIRSTSOCKET],
|
||||||
(struct sockaddr *)sa, &sslen)) {
|
(struct sockaddr *)sa, &sslen)) {
|
||||||
failf(data, "getsockname() failed: %s",
|
failf(data, "getsockname() failed: %s",
|
||||||
Curl_strerror(conn, SOCKERRNO) );
|
Curl_strerror(conn, SOCKERRNO) );
|
||||||
@@ -996,7 +996,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
else
|
else
|
||||||
((struct sockaddr_in6 *)sa)->sin6_port =0;
|
((struct sockaddr_in6 *)sa)->sin6_port =0;
|
||||||
|
|
||||||
if (sslen > (socklen_t)sizeof(ss))
|
if(sslen > (socklen_t)sizeof(ss))
|
||||||
sslen = sizeof(ss);
|
sslen = sizeof(ss);
|
||||||
|
|
||||||
if(bind(portsock, (struct sockaddr *)sa, sslen)) {
|
if(bind(portsock, (struct sockaddr *)sa, sslen)) {
|
||||||
@@ -1018,7 +1018,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
|
|
||||||
/* step 4, listen on the socket */
|
/* step 4, listen on the socket */
|
||||||
|
|
||||||
if (listen(portsock, 1)) {
|
if(listen(portsock, 1)) {
|
||||||
failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO));
|
failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO));
|
||||||
sclose(portsock);
|
sclose(portsock);
|
||||||
return CURLE_FTP_PORT_FAILED;
|
return CURLE_FTP_PORT_FAILED;
|
||||||
@@ -1054,7 +1054,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EPRT == fcmd) {
|
if(EPRT == fcmd) {
|
||||||
/*
|
/*
|
||||||
* Two fine examples from RFC2428;
|
* Two fine examples from RFC2428;
|
||||||
*
|
*
|
||||||
@@ -1070,11 +1070,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
return result;
|
return result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (PORT == fcmd) {
|
else if(PORT == fcmd) {
|
||||||
char *source = myhost;
|
char *source = myhost;
|
||||||
char *dest = tmp;
|
char *dest = tmp;
|
||||||
|
|
||||||
if ((PORT == fcmd) && ai->ai_family != AF_INET)
|
if((PORT == fcmd) && ai->ai_family != AF_INET)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* translate x.x.x.x to x,x,x,x */
|
/* translate x.x.x.x to x,x,x,x */
|
||||||
@@ -1161,19 +1161,19 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
if(!addr) {
|
if(!addr) {
|
||||||
/* pick a suitable default here */
|
/* pick a suitable default here */
|
||||||
|
|
||||||
if (getsockname(conn->sock[FIRSTSOCKET],
|
if(getsockname(conn->sock[FIRSTSOCKET],
|
||||||
(struct sockaddr *)&sa, &sslen)) {
|
(struct sockaddr *)&sa, &sslen)) {
|
||||||
failf(data, "getsockname() failed: %s",
|
failf(data, "getsockname() failed: %s",
|
||||||
Curl_strerror(conn, SOCKERRNO) );
|
Curl_strerror(conn, SOCKERRNO) );
|
||||||
return CURLE_FTP_PORT_FAILED;
|
return CURLE_FTP_PORT_FAILED;
|
||||||
}
|
}
|
||||||
if (sslen > (socklen_t)sizeof(sa))
|
if(sslen > (socklen_t)sizeof(sa))
|
||||||
sslen = sizeof(sa);
|
sslen = sizeof(sa);
|
||||||
|
|
||||||
sa_filled_in = TRUE; /* the sa struct is filled in */
|
sa_filled_in = TRUE; /* the sa struct is filled in */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr || sa_filled_in) {
|
if(addr || sa_filled_in) {
|
||||||
portsock = socket(AF_INET, SOCK_STREAM, 0);
|
portsock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(CURL_SOCKET_BAD != portsock) {
|
if(CURL_SOCKET_BAD != portsock) {
|
||||||
|
|
||||||
@@ -1205,7 +1205,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
porttouse = ntohs(add.sin_port);
|
porttouse = ntohs(add.sin_port);
|
||||||
|
|
||||||
if ( listen(portsock, 1) < 0 ) {
|
if( listen(portsock, 1) < 0 ) {
|
||||||
failf(data, "listen(2) failed on socket");
|
failf(data, "listen(2) failed on socket");
|
||||||
return CURLE_FTP_PORT_FAILED;
|
return CURLE_FTP_PORT_FAILED;
|
||||||
}
|
}
|
||||||
@@ -1484,7 +1484,7 @@ static CURLcode ftp_state_post_mdtm(struct connectdata *conn)
|
|||||||
/* Some servers return different sizes for different modes, and thus we
|
/* Some servers return different sizes for different modes, and thus we
|
||||||
must set the proper type before we check the size */
|
must set the proper type before we check the size */
|
||||||
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_TYPE);
|
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_TYPE);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1659,7 +1659,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
|
|||||||
result = ftp_state_cwd(conn);
|
result = ftp_state_cwd(conn);
|
||||||
break;
|
break;
|
||||||
case FTP_RETR_PREQUOTE:
|
case FTP_RETR_PREQUOTE:
|
||||||
if (ftp->transfer != FTPTRANSFER_BODY)
|
if(ftp->transfer != FTPTRANSFER_BODY)
|
||||||
state(conn, FTP_STOP);
|
state(conn, FTP_STOP);
|
||||||
else {
|
else {
|
||||||
NBFTPSENDF(conn, "SIZE %s", ftpc->file);
|
NBFTPSENDF(conn, "SIZE %s", ftpc->file);
|
||||||
@@ -1724,7 +1724,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
if(ptr) {
|
if(ptr) {
|
||||||
newport = (unsigned short)(num & 0xffff);
|
newport = (unsigned short)(num & 0xffff);
|
||||||
|
|
||||||
if (conn->bits.tunnel_proxy ||
|
if(conn->bits.tunnel_proxy ||
|
||||||
data->set.proxytype == CURLPROXY_SOCKS5 ||
|
data->set.proxytype == CURLPROXY_SOCKS5 ||
|
||||||
data->set.proxytype == CURLPROXY_SOCKS4)
|
data->set.proxytype == CURLPROXY_SOCKS4)
|
||||||
/* proxy tunnel -> use other host info because ip_addr_str is the
|
/* proxy tunnel -> use other host info because ip_addr_str is the
|
||||||
@@ -1759,7 +1759,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
* "227 Entering passive mode. 127,0,0,1,4,51"
|
* "227 Entering passive mode. 127,0,0,1,4,51"
|
||||||
*/
|
*/
|
||||||
while(*str) {
|
while(*str) {
|
||||||
if (6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
|
if(6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
|
||||||
&ip[0], &ip[1], &ip[2], &ip[3],
|
&ip[0], &ip[1], &ip[2], &ip[3],
|
||||||
&port[0], &port[1]))
|
&port[0], &port[1]))
|
||||||
break;
|
break;
|
||||||
@@ -1778,7 +1778,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n",
|
infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n",
|
||||||
ip[0], ip[1], ip[2], ip[3],
|
ip[0], ip[1], ip[2], ip[3],
|
||||||
conn->ip_addr_str);
|
conn->ip_addr_str);
|
||||||
if (conn->bits.tunnel_proxy ||
|
if(conn->bits.tunnel_proxy ||
|
||||||
data->set.proxytype == CURLPROXY_SOCKS5 ||
|
data->set.proxytype == CURLPROXY_SOCKS5 ||
|
||||||
data->set.proxytype == CURLPROXY_SOCKS4)
|
data->set.proxytype == CURLPROXY_SOCKS4)
|
||||||
/* proxy tunnel -> use other host info because ip_addr_str is the
|
/* proxy tunnel -> use other host info because ip_addr_str is the
|
||||||
@@ -1848,7 +1848,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
|
|||||||
|
|
||||||
Curl_resolv_unlock(data, addr); /* we're done using this address */
|
Curl_resolv_unlock(data, addr); /* we're done using this address */
|
||||||
|
|
||||||
if (result && ftpc->count1 == 0 && ftpcode == 229) {
|
if(result && ftpc->count1 == 0 && ftpcode == 229) {
|
||||||
infof(data, "got positive EPSV response, but can't connect. "
|
infof(data, "got positive EPSV response, but can't connect. "
|
||||||
"Disabling EPSV\n");
|
"Disabling EPSV\n");
|
||||||
/* disable it for next transfer */
|
/* disable it for next transfer */
|
||||||
@@ -1936,7 +1936,7 @@ static CURLcode ftp_state_port_resp(struct connectdata *conn,
|
|||||||
if(ftpcode != 200) {
|
if(ftpcode != 200) {
|
||||||
/* the command failed */
|
/* the command failed */
|
||||||
|
|
||||||
if (EPRT == fcmd) {
|
if(EPRT == fcmd) {
|
||||||
infof(data, "disabling EPRT usage\n");
|
infof(data, "disabling EPRT usage\n");
|
||||||
conn->bits.ftp_use_eprt = FALSE;
|
conn->bits.ftp_use_eprt = FALSE;
|
||||||
}
|
}
|
||||||
@@ -2098,7 +2098,7 @@ static CURLcode ftp_state_post_retr_size(struct connectdata *conn,
|
|||||||
struct FTP *ftp = data->reqdata.proto.ftp;
|
struct FTP *ftp = data->reqdata.proto.ftp;
|
||||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||||
|
|
||||||
if (data->set.max_filesize && (filesize > data->set.max_filesize)) {
|
if(data->set.max_filesize && (filesize > data->set.max_filesize)) {
|
||||||
failf(data, "Maximum file size exceeded");
|
failf(data, "Maximum file size exceeded");
|
||||||
return CURLE_FILESIZE_EXCEEDED;
|
return CURLE_FILESIZE_EXCEEDED;
|
||||||
}
|
}
|
||||||
@@ -2220,7 +2220,7 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
|
|||||||
case FTP_REST:
|
case FTP_REST:
|
||||||
default:
|
default:
|
||||||
#ifdef CURL_FTP_HTTPSTYLE_HEAD
|
#ifdef CURL_FTP_HTTPSTYLE_HEAD
|
||||||
if (ftpcode == 350) {
|
if(ftpcode == 350) {
|
||||||
char buffer[24]= { "Accept-ranges: bytes\r\n" };
|
char buffer[24]= { "Accept-ranges: bytes\r\n" };
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buffer, 0);
|
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buffer, 0);
|
||||||
if(result)
|
if(result)
|
||||||
@@ -2231,7 +2231,7 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FTP_RETR_REST:
|
case FTP_RETR_REST:
|
||||||
if (ftpcode != 350) {
|
if(ftpcode != 350) {
|
||||||
failf(conn->data, "Couldn't use REST");
|
failf(conn->data, "Couldn't use REST");
|
||||||
result = CURLE_FTP_COULDNT_USE_REST;
|
result = CURLE_FTP_COULDNT_USE_REST;
|
||||||
}
|
}
|
||||||
@@ -2497,7 +2497,7 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
|
|||||||
530 User ... access denied
|
530 User ... access denied
|
||||||
(the server denies to log the specified user) */
|
(the server denies to log the specified user) */
|
||||||
|
|
||||||
if (conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
|
if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
|
||||||
!conn->data->state.ftp_trying_alternative) {
|
!conn->data->state.ftp_trying_alternative) {
|
||||||
/* Ok, USER failed. Let's try the supplied command. */
|
/* Ok, USER failed. Let's try the supplied command. */
|
||||||
NBFTPSENDF(conn, "%s",
|
NBFTPSENDF(conn, "%s",
|
||||||
@@ -2721,7 +2721,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FTP_CCC:
|
case FTP_CCC:
|
||||||
if (ftpcode < 500) {
|
if(ftpcode < 500) {
|
||||||
/* First shut down the SSL layer (note: this call will block) */
|
/* First shut down the SSL layer (note: this call will block) */
|
||||||
result = Curl_ssl_shutdown(conn, FIRSTSOCKET);
|
result = Curl_ssl_shutdown(conn, FIRSTSOCKET);
|
||||||
|
|
||||||
@@ -2947,8 +2947,8 @@ static CURLcode Curl_ftp_multi_statemach(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
|
rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
|
||||||
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
|
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if(rc == -1) {
|
if(rc == -1) {
|
||||||
failf(data, "select/poll error");
|
failf(data, "select/poll error");
|
||||||
@@ -2980,8 +2980,8 @@ static CURLcode ftp_easy_statemach(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
|
rc = Curl_socket_ready(ftpc->sendleft?CURL_SOCKET_BAD:sock, /* reading */
|
||||||
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
|
ftpc->sendleft?sock:CURL_SOCKET_BAD, /* writing */
|
||||||
(int)timeout_ms);
|
(int)timeout_ms);
|
||||||
|
|
||||||
if(rc == -1) {
|
if(rc == -1) {
|
||||||
failf(data, "select/poll error");
|
failf(data, "select/poll error");
|
||||||
@@ -3024,7 +3024,7 @@ static CURLcode ftp_init(struct connectdata *conn)
|
|||||||
/* no need to duplicate them, this connectdata struct won't change */
|
/* no need to duplicate them, this connectdata struct won't change */
|
||||||
ftp->user = conn->user;
|
ftp->user = conn->user;
|
||||||
ftp->passwd = conn->passwd;
|
ftp->passwd = conn->passwd;
|
||||||
if (isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
|
if(isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
|
||||||
return CURLE_URL_MALFORMAT;
|
return CURLE_URL_MALFORMAT;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
@@ -3066,7 +3066,7 @@ static CURLcode Curl_ftp_connect(struct connectdata *conn,
|
|||||||
ftpc->response_time = 3600000; /* set default response time-out */
|
ftpc->response_time = 3600000; /* set default response time-out */
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if (conn->bits.tunnel_proxy && conn->bits.httpproxy) {
|
if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
|
||||||
/* BLOCKING */
|
/* BLOCKING */
|
||||||
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
||||||
|
|
||||||
@@ -3159,7 +3159,7 @@ static CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status,
|
|||||||
/* the connection stays alive fine even though this happened */
|
/* the connection stays alive fine even though this happened */
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case CURLE_OK: /* doesn't affect the control connection's status */
|
case CURLE_OK: /* doesn't affect the control connection's status */
|
||||||
if (!premature) {
|
if(!premature) {
|
||||||
ftpc->ctl_valid = was_ctl_valid;
|
ftpc->ctl_valid = was_ctl_valid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3330,15 +3330,15 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
|
||||||
item = quote;
|
item = quote;
|
||||||
while (item) {
|
while(item) {
|
||||||
if (item->data) {
|
if(item->data) {
|
||||||
FTPSENDF(conn, "%s", item->data);
|
FTPSENDF(conn, "%s", item->data);
|
||||||
|
|
||||||
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (ftpcode >= 400) {
|
if(ftpcode >= 400) {
|
||||||
failf(conn->data, "QUOT string not accepted: %s", item->data);
|
failf(conn->data, "QUOT string not accepted: %s", item->data);
|
||||||
return CURLE_QUOTE_ERROR;
|
return CURLE_QUOTE_ERROR;
|
||||||
}
|
}
|
||||||
@@ -3377,7 +3377,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
|
|||||||
CURLcode result;
|
CURLcode result;
|
||||||
char want = (char)(ascii?'A':'I');
|
char want = (char)(ascii?'A':'I');
|
||||||
|
|
||||||
if (ftpc->transfertype == want) {
|
if(ftpc->transfertype == want) {
|
||||||
state(conn, newstate);
|
state(conn, newstate);
|
||||||
return ftp_state_type_resp(conn, 200, newstate);
|
return ftp_state_type_resp(conn, 200, newstate);
|
||||||
}
|
}
|
||||||
@@ -3493,7 +3493,7 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
|
|
||||||
if(data->set.upload) {
|
if(data->set.upload) {
|
||||||
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_STOR_TYPE);
|
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_STOR_TYPE);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3511,24 +3511,24 @@ static CURLcode Curl_ftp_nextconnect(struct connectdata *conn)
|
|||||||
/* But only if a body transfer was requested. */
|
/* But only if a body transfer was requested. */
|
||||||
if(ftp->transfer == FTPTRANSFER_BODY) {
|
if(ftp->transfer == FTPTRANSFER_BODY) {
|
||||||
result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
|
result = ftp_nb_type(conn, 1, FTP_LIST_TYPE);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/* otherwise just fall through */
|
/* otherwise just fall through */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_RETR_TYPE);
|
result = ftp_nb_type(conn, data->set.prefer_ascii, FTP_RETR_TYPE);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = ftp_easy_statemach(conn);
|
result = ftp_easy_statemach(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ftp->transfer != FTPTRANSFER_BODY)
|
if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY))
|
||||||
/* no data to transfer. FIX: it feels like a kludge to have this here
|
/* no data to transfer. FIX: it feels like a kludge to have this here
|
||||||
too! */
|
too! */
|
||||||
result=Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
|
result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
|
||||||
|
|
||||||
/* end of transfer */
|
/* end of transfer */
|
||||||
DEBUGF(infof(data, "DO-MORE phase ends with %d\n", result));
|
DEBUGF(infof(data, "DO-MORE phase ends with %d\n", result));
|
||||||
@@ -3612,7 +3612,7 @@ static CURLcode Curl_ftp(struct connectdata *conn, bool *done)
|
|||||||
return retcode;
|
return retcode;
|
||||||
|
|
||||||
retcode = ftp_parse_url_path(conn);
|
retcode = ftp_parse_url_path(conn);
|
||||||
if (retcode)
|
if(retcode)
|
||||||
return retcode;
|
return retcode;
|
||||||
|
|
||||||
retcode = ftp_regular_transfer(conn, done);
|
retcode = ftp_regular_transfer(conn, done);
|
||||||
@@ -3809,7 +3809,7 @@ static CURLcode Curl_ftp_disconnect(struct connectdata *conn)
|
|||||||
|
|
||||||
if(ftpc->entrypath) {
|
if(ftpc->entrypath) {
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
if (data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
|
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
|
||||||
data->state.most_recent_ftp_entrypath = NULL;
|
data->state.most_recent_ftp_entrypath = NULL;
|
||||||
}
|
}
|
||||||
free(ftpc->entrypath);
|
free(ftpc->entrypath);
|
||||||
@@ -3922,25 +3922,25 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* parse the URL path into separate path components */
|
/* parse the URL path into separate path components */
|
||||||
while ((slash_pos = strchr(cur_pos, '/')) != NULL) {
|
while((slash_pos = strchr(cur_pos, '/')) != NULL) {
|
||||||
/* 1 or 0 to indicate absolute directory */
|
/* 1 or 0 to indicate absolute directory */
|
||||||
bool absolute_dir = (bool)((cur_pos - data->reqdata.path > 0) &&
|
bool absolute_dir = (bool)((cur_pos - data->reqdata.path > 0) &&
|
||||||
(ftpc->dirdepth == 0));
|
(ftpc->dirdepth == 0));
|
||||||
|
|
||||||
/* seek out the next path component */
|
/* seek out the next path component */
|
||||||
if (slash_pos-cur_pos) {
|
if(slash_pos-cur_pos) {
|
||||||
/* we skip empty path components, like "x//y" since the FTP command
|
/* we skip empty path components, like "x//y" since the FTP command
|
||||||
CWD requires a parameter and a non-existant parameter a) doesn't
|
CWD requires a parameter and a non-existant parameter a) doesn't
|
||||||
work on many servers and b) has no effect on the others. */
|
work on many servers and b) has no effect on the others. */
|
||||||
int len = (int)(slash_pos - cur_pos + absolute_dir);
|
int len = (int)(slash_pos - cur_pos + absolute_dir);
|
||||||
ftpc->dirs[ftpc->dirdepth] =
|
ftpc->dirs[ftpc->dirdepth] =
|
||||||
curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL);
|
curl_easy_unescape(conn->data, cur_pos - absolute_dir, len, NULL);
|
||||||
if (!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
|
if(!ftpc->dirs[ftpc->dirdepth]) { /* run out of memory ... */
|
||||||
failf(data, "no memory");
|
failf(data, "no memory");
|
||||||
freedirs(ftpc);
|
freedirs(ftpc);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
|
if(isBadFtpString(ftpc->dirs[ftpc->dirdepth])) {
|
||||||
free(ftpc->dirs[ftpc->dirdepth]);
|
free(ftpc->dirs[ftpc->dirdepth]);
|
||||||
freedirs(ftpc);
|
freedirs(ftpc);
|
||||||
return CURLE_URL_MALFORMAT;
|
return CURLE_URL_MALFORMAT;
|
||||||
@@ -3975,7 +3975,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
|||||||
failf(data, "no memory");
|
failf(data, "no memory");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
if (isBadFtpString(ftpc->file)) {
|
if(isBadFtpString(ftpc->file)) {
|
||||||
freedirs(ftpc);
|
freedirs(ftpc);
|
||||||
return CURLE_URL_MALFORMAT;
|
return CURLE_URL_MALFORMAT;
|
||||||
}
|
}
|
||||||
@@ -4117,7 +4117,7 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn)
|
|||||||
/* Unless we have asked to tunnel ftp operations through the proxy, we
|
/* Unless we have asked to tunnel ftp operations through the proxy, we
|
||||||
switch and use HTTP operations only */
|
switch and use HTTP operations only */
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if (conn->handler == &Curl_handler_ftp)
|
if(conn->handler == &Curl_handler_ftp)
|
||||||
conn->handler = &Curl_handler_ftp_proxy;
|
conn->handler = &Curl_handler_ftp_proxy;
|
||||||
else {
|
else {
|
||||||
#ifdef USE_SSL
|
#ifdef USE_SSL
|
||||||
@@ -4140,10 +4140,10 @@ static CURLcode Curl_ftp_setup_connection(struct connectdata * conn)
|
|||||||
* we'll try to get now! */
|
* we'll try to get now! */
|
||||||
type = strstr(data->reqdata.path, ";type=");
|
type = strstr(data->reqdata.path, ";type=");
|
||||||
|
|
||||||
if (!type)
|
if(!type)
|
||||||
type = strstr(conn->host.rawalloc, ";type=");
|
type = strstr(conn->host.rawalloc, ";type=");
|
||||||
|
|
||||||
if (type) {
|
if(type) {
|
||||||
*type = 0; /* it was in the middle of the hostname */
|
*type = 0; /* it was in the middle of the hostname */
|
||||||
command = (char) toupper((int) type[6]);
|
command = (char) toupper((int) type[6]);
|
||||||
|
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ char *GetEnv(const char *variable)
|
|||||||
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
|
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
|
||||||
char *temp = getenv(variable);
|
char *temp = getenv(variable);
|
||||||
env[0] = '\0';
|
env[0] = '\0';
|
||||||
if (temp != NULL)
|
if(temp != NULL)
|
||||||
ExpandEnvironmentStrings(temp, env, sizeof(env));
|
ExpandEnvironmentStrings(temp, env, sizeof(env));
|
||||||
return (env[0] != '\0')?strdup(env):NULL;
|
return (env[0] != '\0')?strdup(env):NULL;
|
||||||
#else
|
#else
|
||||||
char *env = getenv(variable);
|
char *env = getenv(variable);
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
if (env && strcmp("HOME",variable) == 0)
|
if(env && strcmp("HOME",variable) == 0)
|
||||||
env = decc$translate_vms(env);
|
env = decc$translate_vms(env);
|
||||||
#endif
|
#endif
|
||||||
return (env && env[0])?strdup(env):NULL;
|
return (env && env[0])?strdup(env):NULL;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
|
|||||||
info->httpversion=0;
|
info->httpversion=0;
|
||||||
info->filetime=-1; /* -1 is an illegal time and thus means unknown */
|
info->filetime=-1; /* -1 is an illegal time and thus means unknown */
|
||||||
|
|
||||||
if (info->contenttype)
|
if(info->contenttype)
|
||||||
free(info->contenttype);
|
free(info->contenttype);
|
||||||
info->contenttype = NULL;
|
info->contenttype = NULL;
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
|
|||||||
/* determine if ssl */
|
/* determine if ssl */
|
||||||
if(c->ssl[FIRSTSOCKET].use) {
|
if(c->ssl[FIRSTSOCKET].use) {
|
||||||
/* use the SSL context */
|
/* use the SSL context */
|
||||||
if (!Curl_ssl_check_cxn(c))
|
if(!Curl_ssl_check_cxn(c))
|
||||||
*param_longp = -1; /* FIN received */
|
*param_longp = -1; /* FIN received */
|
||||||
}
|
}
|
||||||
/* Minix 3.1 doesn't support any flags on recv; just assume socket is OK */
|
/* Minix 3.1 doesn't support any flags on recv; just assume socket is OK */
|
||||||
|
|||||||
26
lib/gtls.c
26
lib/gtls.c
@@ -97,7 +97,7 @@ int Curl_gtls_init(void)
|
|||||||
static int _Curl_gtls_init(void)
|
static int _Curl_gtls_init(void)
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
if (!gtls_inited) {
|
if(!gtls_inited) {
|
||||||
ret = gnutls_global_init()?0:1;
|
ret = gnutls_global_init()?0:1;
|
||||||
#ifdef GTLSDEBUG
|
#ifdef GTLSDEBUG
|
||||||
gnutls_global_set_log_function(tls_log_func);
|
gnutls_global_set_log_function(tls_log_func);
|
||||||
@@ -110,7 +110,7 @@ static int _Curl_gtls_init(void)
|
|||||||
|
|
||||||
int Curl_gtls_cleanup(void)
|
int Curl_gtls_cleanup(void)
|
||||||
{
|
{
|
||||||
if (gtls_inited)
|
if(gtls_inited)
|
||||||
gnutls_global_deinit();
|
gnutls_global_deinit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ static CURLcode handshake(struct connectdata *conn,
|
|||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
int rc;
|
int rc;
|
||||||
if (!gtls_inited)
|
if(!gtls_inited)
|
||||||
_Curl_gtls_init();
|
_Curl_gtls_init();
|
||||||
do {
|
do {
|
||||||
rc = gnutls_handshake(session);
|
rc = gnutls_handshake(session);
|
||||||
@@ -198,7 +198,7 @@ static CURLcode handshake(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if(rc < 0) {
|
||||||
failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
|
failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,7 @@ Curl_gtls_connect(struct connectdata *conn,
|
|||||||
void *ssl_sessionid;
|
void *ssl_sessionid;
|
||||||
size_t ssl_idsize;
|
size_t ssl_idsize;
|
||||||
|
|
||||||
if (!gtls_inited) _Curl_gtls_init();
|
if(!gtls_inited) _Curl_gtls_init();
|
||||||
/* GnuTLS only supports TLSv1 (and SSLv3?) */
|
/* GnuTLS only supports TLSv1 (and SSLv3?) */
|
||||||
if(data->set.ssl.version == CURL_SSLVERSION_SSLv2) {
|
if(data->set.ssl.version == CURL_SSLVERSION_SSLv2) {
|
||||||
failf(data, "GnuTLS does not support SSLv2");
|
failf(data, "GnuTLS does not support SSLv2");
|
||||||
@@ -269,7 +269,7 @@ Curl_gtls_connect(struct connectdata *conn,
|
|||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
infof(data, "error reading ca cert file %s (%s)\n",
|
infof(data, "error reading ca cert file %s (%s)\n",
|
||||||
data->set.ssl.CAfile, gnutls_strerror(rc));
|
data->set.ssl.CAfile, gnutls_strerror(rc));
|
||||||
if (data->set.ssl.verifypeer)
|
if(data->set.ssl.verifypeer)
|
||||||
return CURLE_SSL_CACERT_BADFILE;
|
return CURLE_SSL_CACERT_BADFILE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -365,14 +365,14 @@ Curl_gtls_connect(struct connectdata *conn,
|
|||||||
gnutls_certificate_set_verify_limits(). */
|
gnutls_certificate_set_verify_limits(). */
|
||||||
|
|
||||||
rc = gnutls_certificate_verify_peers2(session, &verify_status);
|
rc = gnutls_certificate_verify_peers2(session, &verify_status);
|
||||||
if (rc < 0) {
|
if(rc < 0) {
|
||||||
failf(data, "server cert verify failed: %d", rc);
|
failf(data, "server cert verify failed: %d", rc);
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify_status is a bitmask of gnutls_certificate_status bits */
|
/* verify_status is a bitmask of gnutls_certificate_status bits */
|
||||||
if(verify_status & GNUTLS_CERT_INVALID) {
|
if(verify_status & GNUTLS_CERT_INVALID) {
|
||||||
if (data->set.ssl.verifypeer) {
|
if(data->set.ssl.verifypeer) {
|
||||||
failf(data, "server certificate verification failed. CAfile: %s",
|
failf(data, "server certificate verification failed. CAfile: %s",
|
||||||
data->set.ssl.CAfile?data->set.ssl.CAfile:"none");
|
data->set.ssl.CAfile?data->set.ssl.CAfile:"none");
|
||||||
return CURLE_SSL_CACERT;
|
return CURLE_SSL_CACERT;
|
||||||
@@ -409,7 +409,7 @@ Curl_gtls_connect(struct connectdata *conn,
|
|||||||
rc = gnutls_x509_crt_check_hostname(x509_cert, conn->host.name);
|
rc = gnutls_x509_crt_check_hostname(x509_cert, conn->host.name);
|
||||||
|
|
||||||
if(!rc) {
|
if(!rc) {
|
||||||
if (data->set.ssl.verifyhost > 1) {
|
if(data->set.ssl.verifyhost > 1) {
|
||||||
failf(data, "SSL: certificate subject name (%s) does not match "
|
failf(data, "SSL: certificate subject name (%s) does not match "
|
||||||
"target host name '%s'", certbuf, conn->host.dispname);
|
"target host name '%s'", certbuf, conn->host.dispname);
|
||||||
gnutls_x509_crt_deinit(x509_cert);
|
gnutls_x509_crt_deinit(x509_cert);
|
||||||
@@ -431,7 +431,7 @@ Curl_gtls_connect(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(clock < time(NULL)) {
|
if(clock < time(NULL)) {
|
||||||
if (data->set.ssl.verifypeer) {
|
if(data->set.ssl.verifypeer) {
|
||||||
failf(data, "server certificate expiration date has passed.");
|
failf(data, "server certificate expiration date has passed.");
|
||||||
return CURLE_PEER_FAILED_VERIFICATION;
|
return CURLE_PEER_FAILED_VERIFICATION;
|
||||||
}
|
}
|
||||||
@@ -449,7 +449,7 @@ Curl_gtls_connect(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(clock > time(NULL)) {
|
if(clock > time(NULL)) {
|
||||||
if (data->set.ssl.verifypeer) {
|
if(data->set.ssl.verifypeer) {
|
||||||
failf(data, "server certificate not activated yet.");
|
failf(data, "server certificate not activated yet.");
|
||||||
return CURLE_PEER_FAILED_VERIFICATION;
|
return CURLE_PEER_FAILED_VERIFICATION;
|
||||||
}
|
}
|
||||||
@@ -670,12 +670,12 @@ ssize_t Curl_gtls_recv(struct connectdata *conn, /* connection data */
|
|||||||
}
|
}
|
||||||
|
|
||||||
*wouldblock = FALSE;
|
*wouldblock = FALSE;
|
||||||
if (!ret) {
|
if(!ret) {
|
||||||
failf(conn->data, "Peer closed the TLS connection");
|
failf(conn->data, "Peer closed the TLS connection");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret < 0) {
|
if(ret < 0) {
|
||||||
failf(conn->data, "GnuTLS recv error (%d): %s",
|
failf(conn->data, "GnuTLS recv error (%d): %s",
|
||||||
(int)ret, gnutls_strerror(ret));
|
(int)ret, gnutls_strerror(ret));
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
26
lib/hash.c
26
lib/hash.c
@@ -39,7 +39,7 @@ hash_element_dtor(void *user, void *element)
|
|||||||
struct curl_hash *h = (struct curl_hash *) user;
|
struct curl_hash *h = (struct curl_hash *) user;
|
||||||
struct curl_hash_element *e = (struct curl_hash_element *) element;
|
struct curl_hash_element *e = (struct curl_hash_element *) element;
|
||||||
|
|
||||||
if (e->key)
|
if(e->key)
|
||||||
free(e->key);
|
free(e->key);
|
||||||
|
|
||||||
h->dtor(e->ptr);
|
h->dtor(e->ptr);
|
||||||
@@ -57,7 +57,7 @@ Curl_hash_init(struct curl_hash *h,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!slots || !hfunc || !comparator ||!dtor) {
|
if(!slots || !hfunc || !comparator ||!dtor) {
|
||||||
return 1; /* failure */
|
return 1; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,12 +92,12 @@ Curl_hash_alloc(int slots,
|
|||||||
{
|
{
|
||||||
struct curl_hash *h;
|
struct curl_hash *h;
|
||||||
|
|
||||||
if (!slots || !hfunc || !comparator ||!dtor) {
|
if(!slots || !hfunc || !comparator ||!dtor) {
|
||||||
return NULL; /* failure */
|
return NULL; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
|
h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
|
||||||
if (h) {
|
if(h) {
|
||||||
if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
|
if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
|
||||||
/* failure */
|
/* failure */
|
||||||
free(h);
|
free(h);
|
||||||
@@ -148,14 +148,14 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
|
|||||||
|
|
||||||
for (le = l->head; le; le = le->next) {
|
for (le = l->head; le; le = le->next) {
|
||||||
he = (struct curl_hash_element *) le->ptr;
|
he = (struct curl_hash_element *) le->ptr;
|
||||||
if (h->comp_func(he->key, he->key_len, key, key_len)) {
|
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||||
h->dtor(p); /* remove the NEW entry */
|
h->dtor(p); /* remove the NEW entry */
|
||||||
return he->ptr; /* return the EXISTING entry */
|
return he->ptr; /* return the EXISTING entry */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
he = mk_hash_element(key, key_len, p);
|
he = mk_hash_element(key, key_len, p);
|
||||||
if (he) {
|
if(he) {
|
||||||
if(Curl_llist_insert_next(l, l->tail, he)) {
|
if(Curl_llist_insert_next(l, l->tail, he)) {
|
||||||
++h->size;
|
++h->size;
|
||||||
return p; /* return the new entry */
|
return p; /* return the new entry */
|
||||||
@@ -182,7 +182,7 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
|
|||||||
|
|
||||||
for (le = l->head; le; le = le->next) {
|
for (le = l->head; le; le = le->next) {
|
||||||
he = le->ptr;
|
he = le->ptr;
|
||||||
if (h->comp_func(he->key, he->key_len, key, key_len)) {
|
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||||
Curl_llist_remove(l, le, (void *) h);
|
Curl_llist_remove(l, le, (void *) h);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
|
|||||||
|
|
||||||
for (le = l->head; le; le = le->next) {
|
for (le = l->head; le; le = le->next) {
|
||||||
he = le->ptr;
|
he = le->ptr;
|
||||||
if (h->comp_func(he->key, he->key_len, key, key_len)) {
|
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||||
return he->ptr;
|
return he->ptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
|||||||
struct curl_hash_element *he = le->ptr;
|
struct curl_hash_element *he = le->ptr;
|
||||||
lnext = le->next;
|
lnext = le->next;
|
||||||
/* ask the callback function if we shall remove this entry or not */
|
/* ask the callback function if we shall remove this entry or not */
|
||||||
if (comp(user, he->ptr)) {
|
if(comp(user, he->ptr)) {
|
||||||
Curl_llist_remove(list, le, (void *) h);
|
Curl_llist_remove(list, le, (void *) h);
|
||||||
--h->size; /* one less entry in the hash now */
|
--h->size; /* one less entry in the hash now */
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
|||||||
void
|
void
|
||||||
Curl_hash_destroy(struct curl_hash *h)
|
Curl_hash_destroy(struct curl_hash *h)
|
||||||
{
|
{
|
||||||
if (!h)
|
if(!h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Curl_hash_clean(h);
|
Curl_hash_clean(h);
|
||||||
@@ -279,7 +279,7 @@ size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num)
|
|||||||
const char *end = key_str + key_length;
|
const char *end = key_str + key_length;
|
||||||
unsigned long h = 5381;
|
unsigned long h = 5381;
|
||||||
|
|
||||||
while (key_str < end) {
|
while(key_str < end) {
|
||||||
h += h << 5;
|
h += h << 5;
|
||||||
h ^= (unsigned long) *key_str++;
|
h ^= (unsigned long) *key_str++;
|
||||||
}
|
}
|
||||||
@@ -292,7 +292,7 @@ size_t Curl_str_key_compare(void*k1, size_t key1_len, void*k2, size_t key2_len)
|
|||||||
char *key1 = (char *)k1;
|
char *key1 = (char *)k1;
|
||||||
char *key2 = (char *)k2;
|
char *key2 = (char *)k2;
|
||||||
|
|
||||||
if (key1_len == key2_len &&
|
if(key1_len == key2_len &&
|
||||||
*key1 == *key2 &&
|
*key1 == *key2 &&
|
||||||
memcmp(key1, key2, key1_len) == 0) {
|
memcmp(key1, key2, key1_len) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -309,7 +309,7 @@ void Curl_hash_print(struct curl_hash *h,
|
|||||||
struct curl_llist_element *le;
|
struct curl_llist_element *le;
|
||||||
struct curl_llist *list;
|
struct curl_llist *list;
|
||||||
struct curl_hash_element *he;
|
struct curl_hash_element *he;
|
||||||
if (!h)
|
if(!h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fprintf(stderr, "=Hash dump=\n");
|
fprintf(stderr, "=Hash dump=\n");
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */
|
timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */
|
||||||
|
|
||||||
/* Wait for the name resolve query to complete. */
|
/* Wait for the name resolve query to complete. */
|
||||||
while (1) {
|
while(1) {
|
||||||
struct timeval *tvp, tv, store;
|
struct timeval *tvp, tv, store;
|
||||||
struct timeval now = Curl_tvnow();
|
struct timeval now = Curl_tvnow();
|
||||||
long timediff;
|
long timediff;
|
||||||
@@ -262,7 +262,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
|
|
||||||
timediff = Curl_tvdiff(Curl_tvnow(), now); /* spent time */
|
timediff = Curl_tvdiff(Curl_tvnow(), now); /* spent time */
|
||||||
timeout -= timediff?timediff:1; /* always deduct at least 1 */
|
timeout -= timediff?timediff:1; /* always deduct at least 1 */
|
||||||
if (timeout < 0) {
|
if(timeout < 0) {
|
||||||
/* our timeout, so we cancel the ares operation */
|
/* our timeout, so we cancel the ares operation */
|
||||||
ares_cancel(data->state.areschannel);
|
ares_cancel(data->state.areschannel);
|
||||||
break;
|
break;
|
||||||
@@ -316,7 +316,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
|
|
||||||
*waitp = FALSE;
|
*waitp = FALSE;
|
||||||
|
|
||||||
if (in != CURL_INADDR_NONE) {
|
if(in != CURL_INADDR_NONE) {
|
||||||
/* This is a dotted IP address 123.123.123.123-style */
|
/* This is a dotted IP address 123.123.123.123-style */
|
||||||
return Curl_ip2addr(in, hostname, port);
|
return Curl_ip2addr(in, hostname, port);
|
||||||
}
|
}
|
||||||
|
|||||||
22
lib/hostip.c
22
lib/hostip.c
@@ -130,7 +130,7 @@ static void freednsentry(void *freethis);
|
|||||||
*/
|
*/
|
||||||
void Curl_global_host_cache_init(void)
|
void Curl_global_host_cache_init(void)
|
||||||
{
|
{
|
||||||
if (!host_cache_initialized) {
|
if(!host_cache_initialized) {
|
||||||
Curl_hash_init(&hostname_cache, 7, Curl_hash_str, Curl_str_key_compare,
|
Curl_hash_init(&hostname_cache, 7, Curl_hash_str, Curl_str_key_compare,
|
||||||
freednsentry);
|
freednsentry);
|
||||||
host_cache_initialized = 1;
|
host_cache_initialized = 1;
|
||||||
@@ -150,7 +150,7 @@ struct curl_hash *Curl_global_host_cache_get(void)
|
|||||||
*/
|
*/
|
||||||
void Curl_global_host_cache_dtor(void)
|
void Curl_global_host_cache_dtor(void)
|
||||||
{
|
{
|
||||||
if (host_cache_initialized) {
|
if(host_cache_initialized) {
|
||||||
Curl_hash_clean(&hostname_cache);
|
Curl_hash_clean(&hostname_cache);
|
||||||
host_cache_initialized = 0;
|
host_cache_initialized = 0;
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ hostcache_timestamp_remove(void *datap, void *hc)
|
|||||||
(struct hostcache_prune_data *) datap;
|
(struct hostcache_prune_data *) datap;
|
||||||
struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc;
|
struct Curl_dns_entry *c = (struct Curl_dns_entry *) hc;
|
||||||
|
|
||||||
if ((data->now - c->timestamp < data->cache_timeout) ||
|
if((data->now - c->timestamp < data->cache_timeout) ||
|
||||||
c->inuse) {
|
c->inuse) {
|
||||||
/* please don't remove */
|
/* please don't remove */
|
||||||
return 0;
|
return 0;
|
||||||
@@ -284,7 +284,7 @@ remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns)
|
|||||||
time(&user.now);
|
time(&user.now);
|
||||||
user.cache_timeout = data->set.dns_cache_timeout;
|
user.cache_timeout = data->set.dns_cache_timeout;
|
||||||
|
|
||||||
if ( !hostcache_timestamp_remove(&user,dns) )
|
if( !hostcache_timestamp_remove(&user,dns) )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* ok, we do need to clear the cache. although we need to remove just a
|
/* ok, we do need to clear the cache. although we need to remove just a
|
||||||
@@ -336,13 +336,13 @@ Curl_cache_addr(struct SessionHandle *data,
|
|||||||
/* Create an entry id, based upon the hostname and port */
|
/* Create an entry id, based upon the hostname and port */
|
||||||
entry_id = create_hostcache_id(hostname, port);
|
entry_id = create_hostcache_id(hostname, port);
|
||||||
/* If we can't create the entry id, fail */
|
/* If we can't create the entry id, fail */
|
||||||
if (!entry_id)
|
if(!entry_id)
|
||||||
return NULL;
|
return NULL;
|
||||||
entry_len = strlen(entry_id);
|
entry_len = strlen(entry_id);
|
||||||
|
|
||||||
/* Create a new cache entry */
|
/* Create a new cache entry */
|
||||||
dns = (struct Curl_dns_entry *) calloc(sizeof(struct Curl_dns_entry), 1);
|
dns = (struct Curl_dns_entry *) calloc(sizeof(struct Curl_dns_entry), 1);
|
||||||
if (!dns) {
|
if(!dns) {
|
||||||
free(entry_id);
|
free(entry_id);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ int Curl_resolv(struct connectdata *conn,
|
|||||||
/* this allows us to time-out from the name resolver, as the timeout
|
/* this allows us to time-out from the name resolver, as the timeout
|
||||||
will generate a signal and we will siglongjmp() from that here */
|
will generate a signal and we will siglongjmp() from that here */
|
||||||
if(!data->set.no_signal) {
|
if(!data->set.no_signal) {
|
||||||
if (sigsetjmp(curl_jmpenv, 1)) {
|
if(sigsetjmp(curl_jmpenv, 1)) {
|
||||||
/* this is coming from a siglongjmp() */
|
/* this is coming from a siglongjmp() */
|
||||||
failf(data, "name lookup timed out");
|
failf(data, "name lookup timed out");
|
||||||
return CURLRESOLV_ERROR;
|
return CURLRESOLV_ERROR;
|
||||||
@@ -418,7 +418,7 @@ int Curl_resolv(struct connectdata *conn,
|
|||||||
/* Create an entry id, based upon the hostname and port */
|
/* Create an entry id, based upon the hostname and port */
|
||||||
entry_id = create_hostcache_id(hostname, port);
|
entry_id = create_hostcache_id(hostname, port);
|
||||||
/* If we can't create the entry id, fail */
|
/* If we can't create the entry id, fail */
|
||||||
if (!entry_id)
|
if(!entry_id)
|
||||||
return CURLRESOLV_ERROR;
|
return CURLRESOLV_ERROR;
|
||||||
|
|
||||||
entry_len = strlen(entry_id);
|
entry_len = strlen(entry_id);
|
||||||
@@ -437,12 +437,12 @@ int Curl_resolv(struct connectdata *conn,
|
|||||||
|
|
||||||
/* See whether the returned entry is stale. Deliberately done after the
|
/* See whether the returned entry is stale. Deliberately done after the
|
||||||
locked block */
|
locked block */
|
||||||
if ( remove_entry_if_stale(data,dns) )
|
if( remove_entry_if_stale(data,dns) )
|
||||||
dns = NULL; /* the memory deallocation is being handled by the hash */
|
dns = NULL; /* the memory deallocation is being handled by the hash */
|
||||||
|
|
||||||
rc = CURLRESOLV_ERROR; /* default to failure */
|
rc = CURLRESOLV_ERROR; /* default to failure */
|
||||||
|
|
||||||
if (!dns) {
|
if(!dns) {
|
||||||
/* The entry was not in the cache. Resolve it to IP address */
|
/* The entry was not in the cache. Resolve it to IP address */
|
||||||
|
|
||||||
Curl_addrinfo *addr;
|
Curl_addrinfo *addr;
|
||||||
@@ -458,7 +458,7 @@ int Curl_resolv(struct connectdata *conn,
|
|||||||
resolve call */
|
resolve call */
|
||||||
addr = Curl_getaddrinfo(conn, hostname, port, &respwait);
|
addr = Curl_getaddrinfo(conn, hostname, port, &respwait);
|
||||||
|
|
||||||
if (!addr) {
|
if(!addr) {
|
||||||
if(respwait) {
|
if(respwait) {
|
||||||
/* the response to our resolve call will come asynchronously at
|
/* the response to our resolve call will come asynchronously at
|
||||||
a later time, good or bad */
|
a later time, good or bad */
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
#else
|
#else
|
||||||
h = gethostbyname(hostname);
|
h = gethostbyname(hostname);
|
||||||
#endif
|
#endif
|
||||||
if (!h)
|
if(!h)
|
||||||
infof(conn->data, "gethostbyname(2) failed for %s\n", hostname);
|
infof(conn->data, "gethostbyname(2) failed for %s\n", hostname);
|
||||||
#endif /*HAVE_GETHOSTBYNAME_R */
|
#endif /*HAVE_GETHOSTBYNAME_R */
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
if(h) {
|
if(h) {
|
||||||
ai = Curl_he2ai(h, port);
|
ai = Curl_he2ai(h, port);
|
||||||
|
|
||||||
if (buf) /* used a *_r() function */
|
if(buf) /* used a *_r() function */
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ bool Curl_ipvalid(struct SessionHandle *data)
|
|||||||
if(data->set.ip_version == CURL_IPRESOLVE_V6) {
|
if(data->set.ip_version == CURL_IPRESOLVE_V6) {
|
||||||
/* see if we have an IPv6 stack */
|
/* see if we have an IPv6 stack */
|
||||||
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
|
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||||
if (s == CURL_SOCKET_BAD)
|
if(s == CURL_SOCKET_BAD)
|
||||||
/* an ipv6 address was requested and we can't get/use one */
|
/* an ipv6 address was requested and we can't get/use one */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
sclose(s);
|
sclose(s);
|
||||||
@@ -204,7 +204,7 @@ static void dump_addrinfo(struct connectdata *conn, const struct addrinfo *ai)
|
|||||||
|
|
||||||
printf(" fam %2d, CNAME %s, ",
|
printf(" fam %2d, CNAME %s, ",
|
||||||
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
|
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
|
||||||
if (Curl_printable_address(ai, buf, sizeof(buf)))
|
if(Curl_printable_address(ai, buf, sizeof(buf)))
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
else
|
else
|
||||||
printf("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
|
printf("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
|
||||||
@@ -241,7 +241,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
|
|
||||||
/* see if we have an IPv6 stack */
|
/* see if we have an IPv6 stack */
|
||||||
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||||
if (s == CURL_SOCKET_BAD) {
|
if(s == CURL_SOCKET_BAD) {
|
||||||
/* Some non-IPv6 stacks have been found to make very slow name resolves
|
/* Some non-IPv6 stacks have been found to make very slow name resolves
|
||||||
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
|
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
|
||||||
* the stack seems to be a non-ipv6 one. */
|
* the stack seems to be a non-ipv6 one. */
|
||||||
@@ -290,7 +290,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
sbufptr=sbuf;
|
sbufptr=sbuf;
|
||||||
}
|
}
|
||||||
error = getaddrinfo(hostname, sbufptr, &hints, &res);
|
error = getaddrinfo(hostname, sbufptr, &hints, &res);
|
||||||
if (error) {
|
if(error) {
|
||||||
infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port);
|
infof(data, "getaddrinfo(3) failed for %s:%d\n", hostname, port);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
110
lib/hostthre.c
110
lib/hostthre.c
@@ -110,18 +110,18 @@ static bool init_resolve_thread(struct connectdata *conn,
|
|||||||
defined(DEBUG_THREADING_GETADDRINFO)
|
defined(DEBUG_THREADING_GETADDRINFO)
|
||||||
/* If this is defined, provide tracing */
|
/* If this is defined, provide tracing */
|
||||||
#define TRACE(args) \
|
#define TRACE(args) \
|
||||||
do { trace_it("%u: ", __LINE__); trace_it args; } while (0)
|
do { trace_it("%u: ", __LINE__); trace_it args; } while(0)
|
||||||
|
|
||||||
static void trace_it (const char *fmt, ...)
|
static void trace_it (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
static int do_trace = -1;
|
static int do_trace = -1;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (do_trace == -1) {
|
if(do_trace == -1) {
|
||||||
const char *env = getenv("CURL_TRACE");
|
const char *env = getenv("CURL_TRACE");
|
||||||
do_trace = (env && atoi(env) > 0);
|
do_trace = (env && atoi(env) > 0);
|
||||||
}
|
}
|
||||||
if (!do_trace)
|
if(!do_trace)
|
||||||
return;
|
return;
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
vfprintf (stderr, fmt, args);
|
vfprintf (stderr, fmt, args);
|
||||||
@@ -141,7 +141,7 @@ static void dump_addrinfo (struct connectdata *conn, const struct addrinfo *ai)
|
|||||||
|
|
||||||
trace_it(" fam %2d, CNAME %s, ",
|
trace_it(" fam %2d, CNAME %s, ",
|
||||||
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
|
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
|
||||||
if (Curl_printable_address(ai, buf, sizeof(buf)))
|
if(Curl_printable_address(ai, buf, sizeof(buf)))
|
||||||
trace_it("%s\n", buf);
|
trace_it("%s\n", buf);
|
||||||
else
|
else
|
||||||
trace_it("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
|
trace_it("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
|
||||||
@@ -179,13 +179,13 @@ struct thread_sync_data {
|
|||||||
static
|
static
|
||||||
void destroy_thread_sync_data(struct thread_sync_data * tsd)
|
void destroy_thread_sync_data(struct thread_sync_data * tsd)
|
||||||
{
|
{
|
||||||
if (tsd->hostname)
|
if(tsd->hostname)
|
||||||
free(tsd->hostname);
|
free(tsd->hostname);
|
||||||
if (tsd->event_terminate)
|
if(tsd->event_terminate)
|
||||||
CloseHandle(tsd->event_terminate);
|
CloseHandle(tsd->event_terminate);
|
||||||
if (tsd->mutex_terminate)
|
if(tsd->mutex_terminate)
|
||||||
CloseHandle(tsd->mutex_terminate);
|
CloseHandle(tsd->mutex_terminate);
|
||||||
if (tsd->mutex_waiting)
|
if(tsd->mutex_waiting)
|
||||||
CloseHandle(tsd->mutex_waiting);
|
CloseHandle(tsd->mutex_waiting);
|
||||||
memset(tsd,0,sizeof(*tsd));
|
memset(tsd,0,sizeof(*tsd));
|
||||||
}
|
}
|
||||||
@@ -199,21 +199,21 @@ BOOL init_thread_sync_data(struct thread_data * td,
|
|||||||
HANDLE curr_proc = GetCurrentProcess();
|
HANDLE curr_proc = GetCurrentProcess();
|
||||||
|
|
||||||
memset(tsd, 0, sizeof(*tsd));
|
memset(tsd, 0, sizeof(*tsd));
|
||||||
if (!DuplicateHandle(curr_proc, td->mutex_waiting,
|
if(!DuplicateHandle(curr_proc, td->mutex_waiting,
|
||||||
curr_proc, &tsd->mutex_waiting, 0, FALSE,
|
curr_proc, &tsd->mutex_waiting, 0, FALSE,
|
||||||
DUPLICATE_SAME_ACCESS)) {
|
DUPLICATE_SAME_ACCESS)) {
|
||||||
/* failed to duplicate the mutex, no point in continuing */
|
/* failed to duplicate the mutex, no point in continuing */
|
||||||
destroy_thread_sync_data(tsd);
|
destroy_thread_sync_data(tsd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!DuplicateHandle(curr_proc, td->mutex_terminate,
|
if(!DuplicateHandle(curr_proc, td->mutex_terminate,
|
||||||
curr_proc, &tsd->mutex_terminate, 0, FALSE,
|
curr_proc, &tsd->mutex_terminate, 0, FALSE,
|
||||||
DUPLICATE_SAME_ACCESS)) {
|
DUPLICATE_SAME_ACCESS)) {
|
||||||
/* failed to duplicate the mutex, no point in continuing */
|
/* failed to duplicate the mutex, no point in continuing */
|
||||||
destroy_thread_sync_data(tsd);
|
destroy_thread_sync_data(tsd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!DuplicateHandle(curr_proc, td->event_terminate,
|
if(!DuplicateHandle(curr_proc, td->event_terminate,
|
||||||
curr_proc, &tsd->event_terminate, 0, FALSE,
|
curr_proc, &tsd->event_terminate, 0, FALSE,
|
||||||
DUPLICATE_SAME_ACCESS)) {
|
DUPLICATE_SAME_ACCESS)) {
|
||||||
/* failed to duplicate the event, no point in continuing */
|
/* failed to duplicate the event, no point in continuing */
|
||||||
@@ -224,7 +224,7 @@ BOOL init_thread_sync_data(struct thread_data * td,
|
|||||||
* thread during gethostbyname execution.
|
* thread during gethostbyname execution.
|
||||||
*/
|
*/
|
||||||
tsd->hostname = strdup(hostname);
|
tsd->hostname = strdup(hostname);
|
||||||
if (!tsd->hostname) {
|
if(!tsd->hostname) {
|
||||||
/* Memory allocation failed */
|
/* Memory allocation failed */
|
||||||
destroy_thread_sync_data(tsd);
|
destroy_thread_sync_data(tsd);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -237,15 +237,15 @@ static
|
|||||||
BOOL acquire_thread_sync(struct thread_sync_data * tsd)
|
BOOL acquire_thread_sync(struct thread_sync_data * tsd)
|
||||||
{
|
{
|
||||||
/* is the thread initiator still waiting for us ? */
|
/* is the thread initiator still waiting for us ? */
|
||||||
if (WaitForSingleObject(tsd->mutex_waiting, 0) == WAIT_TIMEOUT) {
|
if(WaitForSingleObject(tsd->mutex_waiting, 0) == WAIT_TIMEOUT) {
|
||||||
/* yes, it is */
|
/* yes, it is */
|
||||||
|
|
||||||
/* Waiting access to event_terminate */
|
/* Waiting access to event_terminate */
|
||||||
if (WaitForSingleObject(tsd->mutex_terminate, INFINITE) != WAIT_OBJECT_0) {
|
if(WaitForSingleObject(tsd->mutex_terminate, INFINITE) != WAIT_OBJECT_0) {
|
||||||
/* Something went wrong - now just ignoring */
|
/* Something went wrong - now just ignoring */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (WaitForSingleObject(tsd->event_terminate, 0) != WAIT_TIMEOUT) {
|
if(WaitForSingleObject(tsd->event_terminate, 0) != WAIT_TIMEOUT) {
|
||||||
/* Parent thread signaled us to terminate.
|
/* Parent thread signaled us to terminate.
|
||||||
* This means that all data in conn->async is now destroyed
|
* This means that all data in conn->async is now destroyed
|
||||||
* and we cannot use it.
|
* and we cannot use it.
|
||||||
@@ -287,7 +287,7 @@ static unsigned __stdcall gethostbyname_thread (void *arg)
|
|||||||
*/
|
*/
|
||||||
struct thread_sync_data tsd = { 0,0,0,NULL };
|
struct thread_sync_data tsd = { 0,0,0,NULL };
|
||||||
|
|
||||||
if (!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
|
if(!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
|
||||||
/* thread synchronization data initialization failed */
|
/* thread synchronization data initialization failed */
|
||||||
return (unsigned)-1;
|
return (unsigned)-1;
|
||||||
}
|
}
|
||||||
@@ -302,11 +302,11 @@ static unsigned __stdcall gethostbyname_thread (void *arg)
|
|||||||
he = gethostbyname (tsd.hostname);
|
he = gethostbyname (tsd.hostname);
|
||||||
|
|
||||||
/* is parent thread waiting for us and are we able to access conn members? */
|
/* is parent thread waiting for us and are we able to access conn members? */
|
||||||
if (acquire_thread_sync(&tsd)) {
|
if(acquire_thread_sync(&tsd)) {
|
||||||
/* Mark that we have obtained the information, and that we are calling
|
/* Mark that we have obtained the information, and that we are calling
|
||||||
* back with it. */
|
* back with it. */
|
||||||
SetEvent(td->event_resolved);
|
SetEvent(td->event_resolved);
|
||||||
if (he) {
|
if(he) {
|
||||||
rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he);
|
rc = Curl_addrinfo4_callback(conn, CURL_ASYNC_SUCCESS, he);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -348,7 +348,7 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
|
|||||||
*/
|
*/
|
||||||
struct thread_sync_data tsd = { 0,0,0,NULL };
|
struct thread_sync_data tsd = { 0,0,0,NULL };
|
||||||
|
|
||||||
if (!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
|
if(!init_thread_sync_data(td, conn->async.hostname, &tsd)) {
|
||||||
/* thread synchronization data initialization failed */
|
/* thread synchronization data initialization failed */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -365,12 +365,12 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
|
|||||||
rc = getaddrinfo(tsd.hostname, service, &hints, &res);
|
rc = getaddrinfo(tsd.hostname, service, &hints, &res);
|
||||||
|
|
||||||
/* is parent thread waiting for us and are we able to access conn members? */
|
/* is parent thread waiting for us and are we able to access conn members? */
|
||||||
if (acquire_thread_sync(&tsd)) {
|
if(acquire_thread_sync(&tsd)) {
|
||||||
/* Mark that we have obtained the information, and that we are calling
|
/* Mark that we have obtained the information, and that we are calling
|
||||||
back with it. */
|
back with it. */
|
||||||
SetEvent(td->event_resolved);
|
SetEvent(td->event_resolved);
|
||||||
|
|
||||||
if (rc == 0) {
|
if(rc == 0) {
|
||||||
#ifdef DEBUG_THREADING_GETADDRINFO
|
#ifdef DEBUG_THREADING_GETADDRINFO
|
||||||
dump_addrinfo (conn, res);
|
dump_addrinfo (conn, res);
|
||||||
#endif
|
#endif
|
||||||
@@ -397,16 +397,16 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
|
|||||||
*/
|
*/
|
||||||
void Curl_destroy_thread_data (struct Curl_async *async)
|
void Curl_destroy_thread_data (struct Curl_async *async)
|
||||||
{
|
{
|
||||||
if (async->hostname)
|
if(async->hostname)
|
||||||
free(async->hostname);
|
free(async->hostname);
|
||||||
|
|
||||||
if (async->os_specific) {
|
if(async->os_specific) {
|
||||||
struct thread_data *td = (struct thread_data*) async->os_specific;
|
struct thread_data *td = (struct thread_data*) async->os_specific;
|
||||||
curl_socket_t sock = td->dummy_sock;
|
curl_socket_t sock = td->dummy_sock;
|
||||||
|
|
||||||
if (td->mutex_terminate && td->event_terminate) {
|
if(td->mutex_terminate && td->event_terminate) {
|
||||||
/* Signaling resolver thread to terminate */
|
/* Signaling resolver thread to terminate */
|
||||||
if (WaitForSingleObject(td->mutex_terminate, INFINITE) == WAIT_OBJECT_0) {
|
if(WaitForSingleObject(td->mutex_terminate, INFINITE) == WAIT_OBJECT_0) {
|
||||||
SetEvent(td->event_terminate);
|
SetEvent(td->event_terminate);
|
||||||
ReleaseMutex(td->mutex_terminate);
|
ReleaseMutex(td->mutex_terminate);
|
||||||
}
|
}
|
||||||
@@ -415,24 +415,24 @@ void Curl_destroy_thread_data (struct Curl_async *async)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (td->mutex_terminate)
|
if(td->mutex_terminate)
|
||||||
CloseHandle(td->mutex_terminate);
|
CloseHandle(td->mutex_terminate);
|
||||||
if (td->event_terminate)
|
if(td->event_terminate)
|
||||||
CloseHandle(td->event_terminate);
|
CloseHandle(td->event_terminate);
|
||||||
if (td->event_thread_started)
|
if(td->event_thread_started)
|
||||||
CloseHandle(td->event_thread_started);
|
CloseHandle(td->event_thread_started);
|
||||||
|
|
||||||
if (sock != CURL_SOCKET_BAD)
|
if(sock != CURL_SOCKET_BAD)
|
||||||
sclose(sock);
|
sclose(sock);
|
||||||
|
|
||||||
/* destroy the synchronization objects */
|
/* destroy the synchronization objects */
|
||||||
if (td->mutex_waiting)
|
if(td->mutex_waiting)
|
||||||
CloseHandle(td->mutex_waiting);
|
CloseHandle(td->mutex_waiting);
|
||||||
td->mutex_waiting = NULL;
|
td->mutex_waiting = NULL;
|
||||||
if (td->event_resolved)
|
if(td->event_resolved)
|
||||||
CloseHandle(td->event_resolved);
|
CloseHandle(td->event_resolved);
|
||||||
|
|
||||||
if (td->thread_hnd)
|
if(td->thread_hnd)
|
||||||
CloseHandle(td->thread_hnd);
|
CloseHandle(td->thread_hnd);
|
||||||
|
|
||||||
free(async->os_specific);
|
free(async->os_specific);
|
||||||
@@ -454,14 +454,14 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
struct thread_data *td = calloc(sizeof(*td), 1);
|
struct thread_data *td = calloc(sizeof(*td), 1);
|
||||||
HANDLE thread_and_event[2] = {0};
|
HANDLE thread_and_event[2] = {0};
|
||||||
|
|
||||||
if (!td) {
|
if(!td) {
|
||||||
SET_ERRNO(ENOMEM);
|
SET_ERRNO(ENOMEM);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Curl_safefree(conn->async.hostname);
|
Curl_safefree(conn->async.hostname);
|
||||||
conn->async.hostname = strdup(hostname);
|
conn->async.hostname = strdup(hostname);
|
||||||
if (!conn->async.hostname) {
|
if(!conn->async.hostname) {
|
||||||
free(td);
|
free(td);
|
||||||
SET_ERRNO(ENOMEM);
|
SET_ERRNO(ENOMEM);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -478,7 +478,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
* still waiting, and take initial ownership.
|
* still waiting, and take initial ownership.
|
||||||
*/
|
*/
|
||||||
td->mutex_waiting = CreateMutex(NULL, TRUE, NULL);
|
td->mutex_waiting = CreateMutex(NULL, TRUE, NULL);
|
||||||
if (td->mutex_waiting == NULL) {
|
if(td->mutex_waiting == NULL) {
|
||||||
Curl_destroy_thread_data(&conn->async);
|
Curl_destroy_thread_data(&conn->async);
|
||||||
SET_ERRNO(EAGAIN);
|
SET_ERRNO(EAGAIN);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -488,7 +488,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
* done resolving. Do not signal it.
|
* done resolving. Do not signal it.
|
||||||
*/
|
*/
|
||||||
td->event_resolved = CreateEvent(NULL, TRUE, FALSE, NULL);
|
td->event_resolved = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
if (td->event_resolved == NULL) {
|
if(td->event_resolved == NULL) {
|
||||||
Curl_destroy_thread_data(&conn->async);
|
Curl_destroy_thread_data(&conn->async);
|
||||||
SET_ERRNO(EAGAIN);
|
SET_ERRNO(EAGAIN);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -497,7 +497,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
* between us and resolver thread.
|
* between us and resolver thread.
|
||||||
*/
|
*/
|
||||||
td->mutex_terminate = CreateMutex(NULL, FALSE, NULL);
|
td->mutex_terminate = CreateMutex(NULL, FALSE, NULL);
|
||||||
if (td->mutex_terminate == NULL) {
|
if(td->mutex_terminate == NULL) {
|
||||||
Curl_destroy_thread_data(&conn->async);
|
Curl_destroy_thread_data(&conn->async);
|
||||||
SET_ERRNO(EAGAIN);
|
SET_ERRNO(EAGAIN);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -505,7 +505,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
/* Create the event used to signal thread that it should terminate.
|
/* Create the event used to signal thread that it should terminate.
|
||||||
*/
|
*/
|
||||||
td->event_terminate = CreateEvent(NULL, TRUE, FALSE, NULL);
|
td->event_terminate = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
if (td->event_terminate == NULL) {
|
if(td->event_terminate == NULL) {
|
||||||
Curl_destroy_thread_data(&conn->async);
|
Curl_destroy_thread_data(&conn->async);
|
||||||
SET_ERRNO(EAGAIN);
|
SET_ERRNO(EAGAIN);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -513,7 +513,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
/* Create the event used by thread to inform it has initialized its own data.
|
/* Create the event used by thread to inform it has initialized its own data.
|
||||||
*/
|
*/
|
||||||
td->event_thread_started = CreateEvent(NULL, TRUE, FALSE, NULL);
|
td->event_thread_started = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
if (td->event_thread_started == NULL) {
|
if(td->event_thread_started == NULL) {
|
||||||
Curl_destroy_thread_data(&conn->async);
|
Curl_destroy_thread_data(&conn->async);
|
||||||
SET_ERRNO(EAGAIN);
|
SET_ERRNO(EAGAIN);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -535,7 +535,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
(void) hints;
|
(void) hints;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!td->thread_hnd) {
|
if(!td->thread_hnd) {
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
TRACE(("CreateThread() failed; %s\n", Curl_strerror(conn, ERRNO)));
|
TRACE(("CreateThread() failed; %s\n", Curl_strerror(conn, ERRNO)));
|
||||||
#else
|
#else
|
||||||
@@ -549,7 +549,7 @@ static bool init_resolve_thread (struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
thread_and_event[0] = td->thread_hnd;
|
thread_and_event[0] = td->thread_hnd;
|
||||||
thread_and_event[1] = td->event_thread_started;
|
thread_and_event[1] = td->event_thread_started;
|
||||||
if (WaitForMultipleObjects(sizeof(thread_and_event) /
|
if(WaitForMultipleObjects(sizeof(thread_and_event) /
|
||||||
sizeof(thread_and_event[0]),
|
sizeof(thread_and_event[0]),
|
||||||
(const HANDLE*)thread_and_event, FALSE,
|
(const HANDLE*)thread_and_event, FALSE,
|
||||||
INFINITE) == WAIT_FAILED) {
|
INFINITE) == WAIT_FAILED) {
|
||||||
@@ -608,9 +608,9 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
td->event_resolved = NULL;
|
td->event_resolved = NULL;
|
||||||
|
|
||||||
/* has the resolver thread succeeded in resolving our query ? */
|
/* has the resolver thread succeeded in resolving our query ? */
|
||||||
if (status == WAIT_OBJECT_0) {
|
if(status == WAIT_OBJECT_0) {
|
||||||
/* wait for the thread to exit, it's in the callback sequence */
|
/* wait for the thread to exit, it's in the callback sequence */
|
||||||
if (WaitForSingleObject(td->thread_hnd, 5000) == WAIT_TIMEOUT) {
|
if(WaitForSingleObject(td->thread_hnd, 5000) == WAIT_TIMEOUT) {
|
||||||
TerminateThread(td->thread_hnd, 0);
|
TerminateThread(td->thread_hnd, 0);
|
||||||
conn->async.done = TRUE;
|
conn->async.done = TRUE;
|
||||||
td->thread_status = (DWORD)-1;
|
td->thread_status = (DWORD)-1;
|
||||||
@@ -640,9 +640,9 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
|
|
||||||
rc = CURLE_OK;
|
rc = CURLE_OK;
|
||||||
|
|
||||||
if (!conn->async.dns) {
|
if(!conn->async.dns) {
|
||||||
/* a name was not resolved */
|
/* a name was not resolved */
|
||||||
if (td->thread_status == CURLE_OUT_OF_MEMORY) {
|
if(td->thread_status == CURLE_OUT_OF_MEMORY) {
|
||||||
rc = CURLE_OUT_OF_MEMORY;
|
rc = CURLE_OUT_OF_MEMORY;
|
||||||
failf(data, "Could not resolve host: %s", curl_easy_strerror(rc));
|
failf(data, "Could not resolve host: %s", curl_easy_strerror(rc));
|
||||||
}
|
}
|
||||||
@@ -658,7 +658,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
rc = CURLE_COULDNT_RESOLVE_HOST;
|
rc = CURLE_COULDNT_RESOLVE_HOST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) {
|
else if(td->thread_status == (DWORD)-1 || conn->async.status == NO_DATA) {
|
||||||
failf(data, "Resolving host timed out: %s", conn->host.name);
|
failf(data, "Resolving host timed out: %s", conn->host.name);
|
||||||
rc = CURLE_OPERATION_TIMEDOUT;
|
rc = CURLE_OPERATION_TIMEDOUT;
|
||||||
}
|
}
|
||||||
@@ -684,10 +684,10 @@ CURLcode Curl_is_resolved(struct connectdata *conn,
|
|||||||
{
|
{
|
||||||
*entry = NULL;
|
*entry = NULL;
|
||||||
|
|
||||||
if (conn->async.done) {
|
if(conn->async.done) {
|
||||||
/* we're done */
|
/* we're done */
|
||||||
Curl_destroy_thread_data(&conn->async);
|
Curl_destroy_thread_data(&conn->async);
|
||||||
if (!conn->async.dns) {
|
if(!conn->async.dns) {
|
||||||
TRACE(("Curl_is_resolved(): CURLE_COULDNT_RESOLVE_HOST\n"));
|
TRACE(("Curl_is_resolved(): CURLE_COULDNT_RESOLVE_HOST\n"));
|
||||||
return CURLE_COULDNT_RESOLVE_HOST;
|
return CURLE_COULDNT_RESOLVE_HOST;
|
||||||
}
|
}
|
||||||
@@ -704,7 +704,7 @@ int Curl_resolv_getsock(struct connectdata *conn,
|
|||||||
const struct thread_data *td =
|
const struct thread_data *td =
|
||||||
(const struct thread_data *) conn->async.os_specific;
|
(const struct thread_data *) conn->async.os_specific;
|
||||||
|
|
||||||
if (td && td->dummy_sock != CURL_SOCKET_BAD) {
|
if(td && td->dummy_sock != CURL_SOCKET_BAD) {
|
||||||
if(numsocks) {
|
if(numsocks) {
|
||||||
/* return one socket waiting for writable, even though this is just
|
/* return one socket waiting for writable, even though this is just
|
||||||
a dummy */
|
a dummy */
|
||||||
@@ -731,12 +731,12 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
*waitp = 0; /* don't wait, we act synchronously */
|
*waitp = 0; /* don't wait, we act synchronously */
|
||||||
|
|
||||||
in = inet_addr(hostname);
|
in = inet_addr(hostname);
|
||||||
if (in != CURL_INADDR_NONE)
|
if(in != CURL_INADDR_NONE)
|
||||||
/* This is a dotted IP address 123.123.123.123-style */
|
/* This is a dotted IP address 123.123.123.123-style */
|
||||||
return Curl_ip2addr(in, hostname, port);
|
return Curl_ip2addr(in, hostname, port);
|
||||||
|
|
||||||
/* fire up a new resolver thread! */
|
/* fire up a new resolver thread! */
|
||||||
if (init_resolve_thread(conn, hostname, port, NULL)) {
|
if(init_resolve_thread(conn, hostname, port, NULL)) {
|
||||||
*waitp = TRUE; /* please wait for the response */
|
*waitp = TRUE; /* please wait for the response */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -746,7 +746,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
hostname, Curl_strerror(conn, ERRNO));
|
hostname, Curl_strerror(conn, ERRNO));
|
||||||
|
|
||||||
h = gethostbyname(hostname);
|
h = gethostbyname(hostname);
|
||||||
if (!h) {
|
if(!h) {
|
||||||
infof(data, "gethostbyname(2) failed for %s:%d; %s\n",
|
infof(data, "gethostbyname(2) failed for %s:%d; %s\n",
|
||||||
hostname, port, Curl_strerror(conn, SOCKERRNO));
|
hostname, port, Curl_strerror(conn, SOCKERRNO));
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -775,7 +775,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
|
|
||||||
/* see if we have an IPv6 stack */
|
/* see if we have an IPv6 stack */
|
||||||
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||||
if (s == CURL_SOCKET_BAD) {
|
if(s == CURL_SOCKET_BAD) {
|
||||||
/* Some non-IPv6 stacks have been found to make very slow name resolves
|
/* Some non-IPv6 stacks have been found to make very slow name resolves
|
||||||
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
|
* when PF_UNSPEC is used, so thus we switch to a mere PF_INET lookup if
|
||||||
* the stack seems to be a non-ipv6 one. */
|
* the stack seems to be a non-ipv6 one. */
|
||||||
@@ -813,7 +813,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
itoa(port, sbuf, 10);
|
itoa(port, sbuf, 10);
|
||||||
|
|
||||||
/* fire up a new resolver thread! */
|
/* fire up a new resolver thread! */
|
||||||
if (init_resolve_thread(conn, hostname, port, &hints)) {
|
if(init_resolve_thread(conn, hostname, port, &hints)) {
|
||||||
*waitp = TRUE; /* please wait for the response */
|
*waitp = TRUE; /* please wait for the response */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -823,7 +823,7 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||||||
hostname, Curl_strerror(conn, ERRNO));
|
hostname, Curl_strerror(conn, ERRNO));
|
||||||
|
|
||||||
error = getaddrinfo(hostname, sbuf, &hints, &res);
|
error = getaddrinfo(hostname, sbuf, &hints, &res);
|
||||||
if (error) {
|
if(error) {
|
||||||
infof(data, "getaddrinfo() failed for %s:%d; %s\n",
|
infof(data, "getaddrinfo() failed for %s:%d; %s\n",
|
||||||
hostname, port, Curl_strerror(conn, SOCKERRNO));
|
hostname, port, Curl_strerror(conn, SOCKERRNO));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
135
lib/http.c
135
lib/http.c
@@ -385,7 +385,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
|
|||||||
|
|
||||||
if(pickhost || pickproxy) {
|
if(pickhost || pickproxy) {
|
||||||
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
|
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
|
||||||
if (!data->reqdata.newurl)
|
if(!data->reqdata.newurl)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
if((data->set.httpreq != HTTPREQ_GET) &&
|
if((data->set.httpreq != HTTPREQ_GET) &&
|
||||||
@@ -407,12 +407,12 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
|
|||||||
if((data->set.httpreq != HTTPREQ_GET) &&
|
if((data->set.httpreq != HTTPREQ_GET) &&
|
||||||
(data->set.httpreq != HTTPREQ_HEAD)) {
|
(data->set.httpreq != HTTPREQ_HEAD)) {
|
||||||
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
|
data->reqdata.newurl = strdup(data->change.url); /* clone URL */
|
||||||
if (!data->reqdata.newurl)
|
if(!data->reqdata.newurl)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
data->state.authhost.done = TRUE;
|
data->state.authhost.done = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Curl_http_should_fail(conn)) {
|
if(Curl_http_should_fail(conn)) {
|
||||||
failf (data, "The requested URL returned error: %d",
|
failf (data, "The requested URL returned error: %d",
|
||||||
data->reqdata.keep.httpcode);
|
data->reqdata.keep.httpcode);
|
||||||
code = CURLE_HTTP_RETURNED_ERROR;
|
code = CURLE_HTTP_RETURNED_ERROR;
|
||||||
@@ -475,7 +475,7 @@ Curl_http_output_auth(struct connectdata *conn,
|
|||||||
authproxy->picked = authproxy->want;
|
authproxy->picked = authproxy->want;
|
||||||
|
|
||||||
/* Send proxy authentication header if needed */
|
/* Send proxy authentication header if needed */
|
||||||
if (conn->bits.httpproxy &&
|
if(conn->bits.httpproxy &&
|
||||||
(conn->bits.tunnel_proxy == proxytunnel)) {
|
(conn->bits.tunnel_proxy == proxytunnel)) {
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
if((authproxy->picked == CURLAUTH_GSSNEGOTIATE) &&
|
if((authproxy->picked == CURLAUTH_GSSNEGOTIATE) &&
|
||||||
@@ -483,7 +483,7 @@ Curl_http_output_auth(struct connectdata *conn,
|
|||||||
!GSS_ERROR(data->state.negotiate.status)) {
|
!GSS_ERROR(data->state.negotiate.status)) {
|
||||||
auth="GSS-Negotiate";
|
auth="GSS-Negotiate";
|
||||||
result = Curl_output_negotiate(conn, TRUE);
|
result = Curl_output_negotiate(conn, TRUE);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
authproxy->done = TRUE;
|
authproxy->done = TRUE;
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ Curl_http_output_auth(struct connectdata *conn,
|
|||||||
!GSS_ERROR(data->state.negotiate.status)) {
|
!GSS_ERROR(data->state.negotiate.status)) {
|
||||||
auth="GSS-Negotiate";
|
auth="GSS-Negotiate";
|
||||||
result = Curl_output_negotiate(conn, FALSE);
|
result = Curl_output_negotiate(conn, FALSE);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
authhost->done = TRUE;
|
authhost->done = TRUE;
|
||||||
}
|
}
|
||||||
@@ -627,7 +627,7 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
|
|||||||
const char *start;
|
const char *start;
|
||||||
struct auth *authp;
|
struct auth *authp;
|
||||||
|
|
||||||
if (httpcode == 407) {
|
if(httpcode == 407) {
|
||||||
start = header+strlen("Proxy-authenticate:");
|
start = header+strlen("Proxy-authenticate:");
|
||||||
availp = &data->info.proxyauthavail;
|
availp = &data->info.proxyauthavail;
|
||||||
authp = &data->state.authproxy;
|
authp = &data->state.authproxy;
|
||||||
@@ -652,14 +652,14 @@ CURLcode Curl_http_input_auth(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
if (checkprefix("GSS-Negotiate", start) ||
|
if(checkprefix("GSS-Negotiate", start) ||
|
||||||
checkprefix("Negotiate", start)) {
|
checkprefix("Negotiate", start)) {
|
||||||
*availp |= CURLAUTH_GSSNEGOTIATE;
|
*availp |= CURLAUTH_GSSNEGOTIATE;
|
||||||
authp->avail |= CURLAUTH_GSSNEGOTIATE;
|
authp->avail |= CURLAUTH_GSSNEGOTIATE;
|
||||||
if(authp->picked == CURLAUTH_GSSNEGOTIATE) {
|
if(authp->picked == CURLAUTH_GSSNEGOTIATE) {
|
||||||
/* if exactly this is wanted, go */
|
/* if exactly this is wanted, go */
|
||||||
int neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start);
|
int neg = Curl_input_negotiate(conn, (bool)(httpcode == 407), start);
|
||||||
if (neg == 0) {
|
if(neg == 0) {
|
||||||
data->reqdata.newurl = strdup(data->change.url);
|
data->reqdata.newurl = strdup(data->change.url);
|
||||||
data->state.authproblem = (data->reqdata.newurl == NULL);
|
data->state.authproblem = (data->reqdata.newurl == NULL);
|
||||||
}
|
}
|
||||||
@@ -758,16 +758,16 @@ int Curl_http_should_fail(struct connectdata *conn)
|
|||||||
** If we haven't been asked to fail on error,
|
** If we haven't been asked to fail on error,
|
||||||
** don't fail.
|
** don't fail.
|
||||||
*/
|
*/
|
||||||
if (!data->set.http_fail_on_error)
|
if(!data->set.http_fail_on_error)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Any code < 400 is never terminal.
|
** Any code < 400 is never terminal.
|
||||||
*/
|
*/
|
||||||
if (k->httpcode < 400)
|
if(k->httpcode < 400)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data->reqdata.resume_from &&
|
if(data->reqdata.resume_from &&
|
||||||
(data->set.httpreq==HTTPREQ_GET) &&
|
(data->set.httpreq==HTTPREQ_GET) &&
|
||||||
(k->httpcode == 416)) {
|
(k->httpcode == 416)) {
|
||||||
/* "Requested Range Not Satisfiable", just proceed and
|
/* "Requested Range Not Satisfiable", just proceed and
|
||||||
@@ -779,7 +779,7 @@ int Curl_http_should_fail(struct connectdata *conn)
|
|||||||
** Any code >= 400 that's not 401 or 407 is always
|
** Any code >= 400 that's not 401 or 407 is always
|
||||||
** a terminal error
|
** a terminal error
|
||||||
*/
|
*/
|
||||||
if ((k->httpcode != 401) &&
|
if((k->httpcode != 401) &&
|
||||||
(k->httpcode != 407))
|
(k->httpcode != 407))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -932,6 +932,7 @@ CURLcode add_buffer_send(send_buffer *in,
|
|||||||
struct HTTP *http = conn->data->reqdata.proto.http;
|
struct HTTP *http = conn->data->reqdata.proto.http;
|
||||||
size_t sendsize;
|
size_t sendsize;
|
||||||
curl_socket_t sockfd;
|
curl_socket_t sockfd;
|
||||||
|
size_t headersize;
|
||||||
|
|
||||||
DEBUGASSERT(socketindex <= SECONDARYSOCKET);
|
DEBUGASSERT(socketindex <= SECONDARYSOCKET);
|
||||||
|
|
||||||
@@ -943,17 +944,20 @@ CURLcode add_buffer_send(send_buffer *in,
|
|||||||
ptr = in->buffer;
|
ptr = in->buffer;
|
||||||
size = in->size_used;
|
size = in->size_used;
|
||||||
|
|
||||||
|
headersize = size - included_body_bytes; /* the initial part that isn't body
|
||||||
|
is header */
|
||||||
|
|
||||||
|
DEBUGASSERT(size > included_body_bytes);
|
||||||
|
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
if(size - included_body_bytes > 0) {
|
res = Curl_convert_to_network(conn->data, ptr, headersize);
|
||||||
res = Curl_convert_to_network(conn->data, ptr, size - included_body_bytes);
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
if(res != CURLE_OK) {
|
||||||
if(res != CURLE_OK) {
|
/* conversion failed, free memory and return to the caller */
|
||||||
/* conversion failed, free memory and return to the caller */
|
if(in->buffer)
|
||||||
if(in->buffer)
|
free(in->buffer);
|
||||||
free(in->buffer);
|
free(in);
|
||||||
free(in);
|
return res;
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
@@ -981,20 +985,29 @@ CURLcode add_buffer_send(send_buffer *in,
|
|||||||
res = Curl_write(conn, sockfd, ptr, sendsize, &amount);
|
res = Curl_write(conn, sockfd, ptr, sendsize, &amount);
|
||||||
|
|
||||||
if(CURLE_OK == res) {
|
if(CURLE_OK == res) {
|
||||||
|
/*
|
||||||
|
* Note that we may not send the entire chunk at once, and we have a set
|
||||||
|
* number of data bytes at the end of the big buffer (out of which we may
|
||||||
|
* only send away a part).
|
||||||
|
*/
|
||||||
|
/* how much of the header that was sent */
|
||||||
|
size_t headlen = (size_t)amount>headersize?headersize:(size_t)amount;
|
||||||
|
size_t bodylen = amount - headlen;
|
||||||
|
|
||||||
if(conn->data->set.verbose) {
|
if(conn->data->set.verbose) {
|
||||||
/* this data _may_ contain binary stuff */
|
/* this data _may_ contain binary stuff */
|
||||||
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr,
|
Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, headlen, conn);
|
||||||
(size_t)(amount-included_body_bytes), conn);
|
if((size_t)amount > headlen) {
|
||||||
if (included_body_bytes)
|
/* there was body data sent beyond the initial header part, pass that
|
||||||
|
on to the debug callback too */
|
||||||
Curl_debug(conn->data, CURLINFO_DATA_OUT,
|
Curl_debug(conn->data, CURLINFO_DATA_OUT,
|
||||||
ptr+amount-included_body_bytes,
|
ptr+headlen, bodylen, conn);
|
||||||
(size_t)included_body_bytes, conn);
|
}
|
||||||
}
|
}
|
||||||
if (included_body_bytes)
|
if(bodylen)
|
||||||
/* since we sent a piece of the body here, up the byte counter for it
|
/* since we sent a piece of the body here, up the byte counter for it
|
||||||
accordingly */
|
accordingly */
|
||||||
http->writebytecount = included_body_bytes;
|
http->writebytecount += bodylen;
|
||||||
|
|
||||||
*bytes_written += amount;
|
*bytes_written += amount;
|
||||||
|
|
||||||
@@ -1083,9 +1096,28 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
|
|||||||
char *new_rb;
|
char *new_rb;
|
||||||
size_t new_size;
|
size_t new_size;
|
||||||
|
|
||||||
|
if(~size < in->size_used) {
|
||||||
|
/* If resulting used size of send buffer would wrap size_t, cleanup
|
||||||
|
the whole buffer and return error. Otherwise the required buffer
|
||||||
|
size will fit into a single allocatable memory chunk */
|
||||||
|
Curl_safefree(in->buffer);
|
||||||
|
free(in);
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if(!in->buffer ||
|
if(!in->buffer ||
|
||||||
((in->size_used + size) > (in->size_max - 1))) {
|
((in->size_used + size) > (in->size_max - 1))) {
|
||||||
new_size = (in->size_used+size)*2;
|
|
||||||
|
/* If current buffer size isn't enough to hold the result, use a
|
||||||
|
buffer size that doubles the required size. If this new size
|
||||||
|
would wrap size_t, then just use the largest possible one */
|
||||||
|
|
||||||
|
if((size > (size_t)-1/2) || (in->size_used > (size_t)-1/2) ||
|
||||||
|
(~(size*2) < (in->size_used*2)))
|
||||||
|
new_size = (size_t)-1;
|
||||||
|
else
|
||||||
|
new_size = (in->size_used+size)*2;
|
||||||
|
|
||||||
if(in->buffer)
|
if(in->buffer)
|
||||||
/* we have a buffer, enlarge the existing one */
|
/* we have a buffer, enlarge the existing one */
|
||||||
new_rb = (char *)realloc(in->buffer, new_size);
|
new_rb = (char *)realloc(in->buffer, new_size);
|
||||||
@@ -1207,7 +1239,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
conn->bits.proxy_connect_closed = FALSE;
|
conn->bits.proxy_connect_closed = FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!conn->bits.tunnel_connecting) { /* BEGIN CONNECT PHASE */
|
if(!conn->bits.tunnel_connecting) { /* BEGIN CONNECT PHASE */
|
||||||
char *host_port;
|
char *host_port;
|
||||||
send_buffer *req_buffer;
|
send_buffer *req_buffer;
|
||||||
|
|
||||||
@@ -1314,8 +1346,8 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if we're in multi-mode and we would block, return instead for a retry */
|
/* if we're in multi-mode and we would block, return instead for a retry */
|
||||||
if (Curl_if_multi == data->state.used_interface) {
|
if(Curl_if_multi == data->state.used_interface) {
|
||||||
if (0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
|
if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
|
||||||
/* return so we'll be called again polling-style */
|
/* return so we'll be called again polling-style */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
else {
|
else {
|
||||||
@@ -1571,7 +1603,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
headers. 'newurl' is set to a new URL if we must loop. */
|
headers. 'newurl' is set to a new URL if we must loop. */
|
||||||
Curl_http_auth_act(conn);
|
Curl_http_auth_act(conn);
|
||||||
|
|
||||||
if (closeConnection && data->reqdata.newurl) {
|
if(closeConnection && data->reqdata.newurl) {
|
||||||
/* Connection closed by server. Don't use it anymore */
|
/* Connection closed by server. Don't use it anymore */
|
||||||
sclose(conn->sock[sockindex]);
|
sclose(conn->sock[sockindex]);
|
||||||
conn->sock[sockindex] = CURL_SOCKET_BAD;
|
conn->sock[sockindex] = CURL_SOCKET_BAD;
|
||||||
@@ -1584,7 +1616,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
|||||||
failf(data, "Received HTTP code %d from proxy after CONNECT",
|
failf(data, "Received HTTP code %d from proxy after CONNECT",
|
||||||
k->httpcode);
|
k->httpcode);
|
||||||
|
|
||||||
if (closeConnection && data->reqdata.newurl)
|
if(closeConnection && data->reqdata.newurl)
|
||||||
conn->bits.proxy_connect_closed = TRUE;
|
conn->bits.proxy_connect_closed = TRUE;
|
||||||
|
|
||||||
return CURLE_RECV_ERROR;
|
return CURLE_RECV_ERROR;
|
||||||
@@ -1634,14 +1666,14 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->bits.tunnel_connecting) {
|
if(conn->bits.tunnel_connecting) {
|
||||||
/* nothing else to do except wait right now - we're not done here. */
|
/* nothing else to do except wait right now - we're not done here. */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!data->state.this_is_a_follow) {
|
if(!data->state.this_is_a_follow) {
|
||||||
/* this is not a followed location, get the original host name */
|
/* this is not a followed location, get the original host name */
|
||||||
if (data->state.first_host)
|
if(data->state.first_host)
|
||||||
/* Free to avoid leaking memory on multiple requests*/
|
/* Free to avoid leaking memory on multiple requests*/
|
||||||
free(data->state.first_host);
|
free(data->state.first_host);
|
||||||
|
|
||||||
@@ -1692,18 +1724,18 @@ static int Curl_https_getsock(struct connectdata *conn,
|
|||||||
curl_socket_t *socks,
|
curl_socket_t *socks,
|
||||||
int numsocks)
|
int numsocks)
|
||||||
{
|
{
|
||||||
if (conn->protocol & PROT_HTTPS) {
|
if(conn->protocol & PROT_HTTPS) {
|
||||||
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
|
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
|
||||||
|
|
||||||
if(!numsocks)
|
if(!numsocks)
|
||||||
return GETSOCK_BLANK;
|
return GETSOCK_BLANK;
|
||||||
|
|
||||||
if (connssl->connecting_state == ssl_connect_2_writing) {
|
if(connssl->connecting_state == ssl_connect_2_writing) {
|
||||||
/* write mode */
|
/* write mode */
|
||||||
socks[0] = conn->sock[FIRSTSOCKET];
|
socks[0] = conn->sock[FIRSTSOCKET];
|
||||||
return GETSOCK_WRITESOCK(0);
|
return GETSOCK_WRITESOCK(0);
|
||||||
}
|
}
|
||||||
else if (connssl->connecting_state == ssl_connect_2_reading) {
|
else if(connssl->connecting_state == ssl_connect_2_reading) {
|
||||||
/* read mode */
|
/* read mode */
|
||||||
socks[0] = conn->sock[FIRSTSOCKET];
|
socks[0] = conn->sock[FIRSTSOCKET];
|
||||||
return GETSOCK_READSOCK(0);
|
return GETSOCK_READSOCK(0);
|
||||||
@@ -1766,7 +1798,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
|
|||||||
conn->fread_func = data->set.fread_func; /* restore */
|
conn->fread_func = data->set.fread_func; /* restore */
|
||||||
conn->fread_in = data->set.in; /* restore */
|
conn->fread_in = data->set.in; /* restore */
|
||||||
|
|
||||||
if (http == NULL)
|
if(http == NULL)
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
if(http->send_buffer) {
|
if(http->send_buffer) {
|
||||||
@@ -1790,7 +1822,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
|
|||||||
else if(HTTPREQ_PUT == data->set.httpreq)
|
else if(HTTPREQ_PUT == data->set.httpreq)
|
||||||
k->bytecount = http->readbytecount + http->writebytecount;
|
k->bytecount = http->readbytecount + http->writebytecount;
|
||||||
|
|
||||||
if (status != CURLE_OK)
|
if(status != CURLE_OK)
|
||||||
return (status);
|
return (status);
|
||||||
|
|
||||||
if(!conn->bits.retry &&
|
if(!conn->bits.retry &&
|
||||||
@@ -1909,7 +1941,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
else
|
else
|
||||||
http = data->reqdata.proto.http;
|
http = data->reqdata.proto.http;
|
||||||
|
|
||||||
if ( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
|
if( (conn->protocol&(PROT_HTTP|PROT_FTP)) &&
|
||||||
data->set.upload) {
|
data->set.upload) {
|
||||||
httpreq = HTTPREQ_PUT;
|
httpreq = HTTPREQ_PUT;
|
||||||
}
|
}
|
||||||
@@ -1990,7 +2022,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
|
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (httpreq == HTTPREQ_GET)
|
if(httpreq == HTTPREQ_GET)
|
||||||
conn->bits.upload_chunky = FALSE;
|
conn->bits.upload_chunky = FALSE;
|
||||||
if(conn->bits.upload_chunky)
|
if(conn->bits.upload_chunky)
|
||||||
te = "Transfer-Encoding: chunked\r\n";
|
te = "Transfer-Encoding: chunked\r\n";
|
||||||
@@ -2035,7 +2067,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
|
if(((conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTPS)) ||
|
||||||
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
|
(!(conn->protocol&PROT_HTTPS) && (conn->remote_port == PORT_HTTP)) )
|
||||||
/* If (HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
|
/* if(HTTPS on port 443) OR (non-HTTPS on port 80) then don't include
|
||||||
the port number in the host string */
|
the port number in the host string */
|
||||||
conn->allocptr.host = aprintf("Host: %s%s%s\r\n",
|
conn->allocptr.host = aprintf("Host: %s%s%s\r\n",
|
||||||
conn->bits.ipv6_ip?"[":"",
|
conn->bits.ipv6_ip?"[":"",
|
||||||
@@ -2053,7 +2085,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
|
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
|
||||||
/* Using a proxy but does not tunnel through it */
|
/* Using a proxy but does not tunnel through it */
|
||||||
|
|
||||||
/* The path sent to the proxy is in fact the entire URL. But if the remote
|
/* The path sent to the proxy is in fact the entire URL. But if the remote
|
||||||
@@ -2095,9 +2127,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
ppath = data->change.url;
|
ppath = data->change.url;
|
||||||
/* when doing ftp, append ;type=<a|i> if not present */
|
/* when doing ftp, append ;type=<a|i> if not present */
|
||||||
if (checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
|
if(checkprefix("ftp://", ppath) || checkprefix("ftps://", ppath)) {
|
||||||
char *p = strstr(ppath, ";type=");
|
char *p = strstr(ppath, ";type=");
|
||||||
if (p && p[6] && p[7] == 0) {
|
if(p && p[6] && p[7] == 0) {
|
||||||
switch (toupper((int)((unsigned char)p[6]))) {
|
switch (toupper((int)((unsigned char)p[6]))) {
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'D':
|
case 'D':
|
||||||
@@ -2107,7 +2139,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!p)
|
if(!p)
|
||||||
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
|
snprintf(ftp_typecode, sizeof(ftp_typecode), ";type=%c",
|
||||||
data->set.prefer_ascii ? 'a' : 'i');
|
data->set.prefer_ascii ? 'a' : 'i');
|
||||||
}
|
}
|
||||||
@@ -2307,7 +2339,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
|
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
|
||||||
co = Curl_cookie_getlist(data->cookies,
|
co = Curl_cookie_getlist(data->cookies,
|
||||||
conn->allocptr.cookiehost?
|
conn->allocptr.cookiehost?
|
||||||
conn->allocptr.cookiehost:host, data->reqdata.path,
|
conn->allocptr.cookiehost:host,
|
||||||
|
data->reqdata.path,
|
||||||
(bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE));
|
(bool)(conn->protocol&PROT_HTTPS?TRUE:FALSE));
|
||||||
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
|
|
||||||
/* the original data is written to the client, but we go on with the
|
/* the original data is written to the client, but we go on with the
|
||||||
chunk read process, to properly calculate the content length*/
|
chunk read process, to properly calculate the content length*/
|
||||||
if (data->set.http_te_skip && !k->ignorebody)
|
if(data->set.http_te_skip && !k->ignorebody)
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, datap,datalen);
|
Curl_client_write(conn, CLIENTWRITE_BODY, datap,datalen);
|
||||||
|
|
||||||
while(length) {
|
while(length) {
|
||||||
@@ -178,7 +178,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
if(*datap == 0x0a) {
|
if(*datap == 0x0a) {
|
||||||
/* we're now expecting data to come, unless size was zero! */
|
/* we're now expecting data to come, unless size was zero! */
|
||||||
if(0 == ch->datasize) {
|
if(0 == ch->datasize) {
|
||||||
if (conn->bits.trailerHdrPresent!=TRUE) {
|
if(conn->bits.trailerhdrpresent!=TRUE) {
|
||||||
/* No Trailer: header found - revert to original Curl processing */
|
/* No Trailer: header found - revert to original Curl processing */
|
||||||
ch->state = CHUNK_STOPCR;
|
ch->state = CHUNK_STOPCR;
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
case IDENTITY:
|
case IDENTITY:
|
||||||
#endif
|
#endif
|
||||||
if(!k->ignorebody) {
|
if(!k->ignorebody) {
|
||||||
if ( !data->set.http_te_skip )
|
if( !data->set.http_te_skip )
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
|
||||||
piece);
|
piece);
|
||||||
else
|
else
|
||||||
@@ -298,7 +298,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
case CHUNK_TRAILER:
|
case CHUNK_TRAILER:
|
||||||
/* conn->trailer is assumed to be freed in url.c on a
|
/* conn->trailer is assumed to be freed in url.c on a
|
||||||
connection basis */
|
connection basis */
|
||||||
if (conn->trlPos >= conn->trlMax) {
|
if(conn->trlPos >= conn->trlMax) {
|
||||||
char *ptr;
|
char *ptr;
|
||||||
if(conn->trlMax) {
|
if(conn->trlMax) {
|
||||||
conn->trlMax *= 2;
|
conn->trlMax *= 2;
|
||||||
@@ -333,10 +333,10 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CHUNK_TRAILER_POSTCR:
|
case CHUNK_TRAILER_POSTCR:
|
||||||
if (*datap == 0x0a) {
|
if(*datap == 0x0a) {
|
||||||
conn->trailer[conn->trlPos++]=0x0a;
|
conn->trailer[conn->trlPos++]=0x0a;
|
||||||
conn->trailer[conn->trlPos]=0;
|
conn->trailer[conn->trlPos]=0;
|
||||||
if (conn->trlPos==2) {
|
if(conn->trlPos==2) {
|
||||||
ch->state = CHUNK_STOP;
|
ch->state = CHUNK_STOP;
|
||||||
datap++;
|
datap++;
|
||||||
length--;
|
length--;
|
||||||
@@ -362,7 +362,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
return(CHUNKE_BAD_CHUNK);
|
return(CHUNKE_BAD_CHUNK);
|
||||||
}
|
}
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
if ( !data->set.http_te_skip )
|
if( !data->set.http_te_skip )
|
||||||
Curl_client_write(conn, CLIENTWRITE_HEADER,
|
Curl_client_write(conn, CLIENTWRITE_HEADER,
|
||||||
conn->trailer, conn->trlPos);
|
conn->trailer, conn->trlPos);
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CHUNK_STOP:
|
case CHUNK_STOP:
|
||||||
if (*datap == 0x0a) {
|
if(*datap == 0x0a) {
|
||||||
datap++;
|
datap++;
|
||||||
length--;
|
length--;
|
||||||
|
|
||||||
|
|||||||
@@ -133,23 +133,23 @@ CURLdigest Curl_input_digest(struct connectdata *conn,
|
|||||||
if(!tmp)
|
if(!tmp)
|
||||||
return CURLDIGEST_NOMEM;
|
return CURLDIGEST_NOMEM;
|
||||||
token = strtok_r(tmp, ",", &tok_buf);
|
token = strtok_r(tmp, ",", &tok_buf);
|
||||||
while (token != NULL) {
|
while(token != NULL) {
|
||||||
if (strequal(token, "auth")) {
|
if(strequal(token, "auth")) {
|
||||||
foundAuth = TRUE;
|
foundAuth = TRUE;
|
||||||
}
|
}
|
||||||
else if (strequal(token, "auth-int")) {
|
else if(strequal(token, "auth-int")) {
|
||||||
foundAuthInt = TRUE;
|
foundAuthInt = TRUE;
|
||||||
}
|
}
|
||||||
token = strtok_r(NULL, ",", &tok_buf);
|
token = strtok_r(NULL, ",", &tok_buf);
|
||||||
}
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
/*select only auth o auth-int. Otherwise, ignore*/
|
/*select only auth o auth-int. Otherwise, ignore*/
|
||||||
if (foundAuth) {
|
if(foundAuth) {
|
||||||
d->qop = strdup("auth");
|
d->qop = strdup("auth");
|
||||||
if(!d->qop)
|
if(!d->qop)
|
||||||
return CURLDIGEST_NOMEM;
|
return CURLDIGEST_NOMEM;
|
||||||
}
|
}
|
||||||
else if (foundAuthInt) {
|
else if(foundAuthInt) {
|
||||||
d->qop = strdup("auth-int");
|
d->qop = strdup("auth-int");
|
||||||
if(!d->qop)
|
if(!d->qop)
|
||||||
return CURLDIGEST_NOMEM;
|
return CURLDIGEST_NOMEM;
|
||||||
@@ -243,7 +243,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
|
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
|
||||||
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
|
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
|
||||||
if (rc != CURLE_OK) { \
|
if(rc != CURLE_OK) { \
|
||||||
free(b); \
|
free(b); \
|
||||||
return rc; \
|
return rc; \
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
authp = &data->state.authhost;
|
authp = &data->state.authhost;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*allocuserpwd) {
|
if(*allocuserpwd) {
|
||||||
Curl_safefree(*allocuserpwd);
|
Curl_safefree(*allocuserpwd);
|
||||||
*allocuserpwd = NULL;
|
*allocuserpwd = NULL;
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->qop && strequal(d->qop, "auth-int")) {
|
if(d->qop && strequal(d->qop, "auth-int")) {
|
||||||
/* We don't support auth-int at the moment. I can't see a easy way to get
|
/* We don't support auth-int at the moment. I can't see a easy way to get
|
||||||
entity-body here */
|
entity-body here */
|
||||||
/* TODO: Append H(entity-body)*/
|
/* TODO: Append H(entity-body)*/
|
||||||
@@ -363,7 +363,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
free(md5this); /* free this again */
|
free(md5this); /* free this again */
|
||||||
md5_to_ascii(md5buf, ha2);
|
md5_to_ascii(md5buf, ha2);
|
||||||
|
|
||||||
if (d->qop) {
|
if(d->qop) {
|
||||||
md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s",
|
md5this = (unsigned char *)aprintf("%s:%s:%08x:%s:%s:%s",
|
||||||
ha1,
|
ha1,
|
||||||
d->nonce,
|
d->nonce,
|
||||||
@@ -393,7 +393,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"
|
nonce="1053604145", uri="/64", response="c55f7f30d83d774a3d2dcacf725abaca"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (d->qop) {
|
if(d->qop) {
|
||||||
*allocuserpwd =
|
*allocuserpwd =
|
||||||
aprintf( "%sAuthorization: Digest "
|
aprintf( "%sAuthorization: Digest "
|
||||||
"username=\"%s\", "
|
"username=\"%s\", "
|
||||||
|
|||||||
@@ -51,7 +51,8 @@
|
|||||||
static int
|
static int
|
||||||
get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
|
get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
|
||||||
{
|
{
|
||||||
struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
|
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
|
||||||
|
&conn->data->state.negotiate;
|
||||||
OM_uint32 major_status, minor_status;
|
OM_uint32 major_status, minor_status;
|
||||||
gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
|
gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
|
||||||
char name[2048];
|
char name[2048];
|
||||||
@@ -64,16 +65,18 @@ get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
|
|||||||
|
|
||||||
/* IIS uses the <service>@<fqdn> form but uses 'http' as the service name */
|
/* IIS uses the <service>@<fqdn> form but uses 'http' as the service name */
|
||||||
|
|
||||||
if (neg_ctx->gss)
|
if(neg_ctx->gss)
|
||||||
service = "KHTTP";
|
service = "KHTTP";
|
||||||
else
|
else
|
||||||
service = "HTTP";
|
service = "HTTP";
|
||||||
|
|
||||||
token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name : conn->host.name) + 1;
|
token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name :
|
||||||
if (token.length + 1 > sizeof(name))
|
conn->host.name) + 1;
|
||||||
|
if(token.length + 1 > sizeof(name))
|
||||||
return EMSGSIZE;
|
return EMSGSIZE;
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name : conn->host.name);
|
snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name :
|
||||||
|
conn->host.name);
|
||||||
|
|
||||||
token.value = (void *) name;
|
token.value = (void *) name;
|
||||||
major_status = gss_import_name(&minor_status,
|
major_status = gss_import_name(&minor_status,
|
||||||
@@ -96,26 +99,28 @@ log_gss_error(struct connectdata *conn, OM_uint32 error_status, char *prefix)
|
|||||||
snprintf(buf, sizeof(buf), "%s", prefix);
|
snprintf(buf, sizeof(buf), "%s", prefix);
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
do {
|
do {
|
||||||
maj_stat = gss_display_status (&min_stat,
|
maj_stat = gss_display_status(&min_stat,
|
||||||
error_status,
|
error_status,
|
||||||
GSS_C_MECH_CODE,
|
GSS_C_MECH_CODE,
|
||||||
GSS_C_NO_OID,
|
GSS_C_NO_OID,
|
||||||
&msg_ctx,
|
&msg_ctx,
|
||||||
&status_string);
|
&status_string);
|
||||||
if (sizeof(buf) > len + status_string.length + 1) {
|
if(sizeof(buf) > len + status_string.length + 1) {
|
||||||
snprintf(buf + len, sizeof(buf) - len,
|
snprintf(buf + len, sizeof(buf) - len,
|
||||||
": %s", (char*) status_string.value);
|
": %s", (char*) status_string.value);
|
||||||
len += status_string.length;
|
len += status_string.length;
|
||||||
}
|
}
|
||||||
gss_release_buffer(&min_stat, &status_string);
|
gss_release_buffer(&min_stat, &status_string);
|
||||||
} while (!GSS_ERROR(maj_stat) && msg_ctx != 0);
|
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
|
||||||
|
|
||||||
infof(conn->data, "%s", buf);
|
infof(conn->data, "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *header)
|
int Curl_input_negotiate(struct connectdata *conn, bool proxy,
|
||||||
|
const char *header)
|
||||||
{
|
{
|
||||||
struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
|
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
|
||||||
|
&conn->data->state.negotiate;
|
||||||
OM_uint32 major_status, minor_status, minor_status2;
|
OM_uint32 major_status, minor_status, minor_status2;
|
||||||
gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
|
gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
|
||||||
gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
|
gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
|
||||||
@@ -130,15 +135,15 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
protocol = "GSS-Negotiate";
|
protocol = "GSS-Negotiate";
|
||||||
gss = TRUE;
|
gss = TRUE;
|
||||||
}
|
}
|
||||||
else if (checkprefix("Negotiate", header)) {
|
else if(checkprefix("Negotiate", header)) {
|
||||||
protocol = "Negotiate";
|
protocol = "Negotiate";
|
||||||
gss = FALSE;
|
gss = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (neg_ctx->context) {
|
if(neg_ctx->context) {
|
||||||
if (neg_ctx->gss != gss) {
|
if(neg_ctx->gss != gss) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +152,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
neg_ctx->gss = gss;
|
neg_ctx->gss = gss;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) {
|
if(neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) {
|
||||||
/* We finished succesfully our part of authentication, but server
|
/* We finished succesfully our part of authentication, but server
|
||||||
* rejected it (since we're again here). Exit with an error since we
|
* rejected it (since we're again here). Exit with an error since we
|
||||||
* can't invent anything better */
|
* can't invent anything better */
|
||||||
@@ -155,7 +160,7 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neg_ctx->server_name == NULL &&
|
if(neg_ctx->server_name == NULL &&
|
||||||
(ret = get_gss_name(conn, proxy, &neg_ctx->server_name)))
|
(ret = get_gss_name(conn, proxy, &neg_ctx->server_name)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -164,14 +169,15 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
header++;
|
header++;
|
||||||
|
|
||||||
len = strlen(header);
|
len = strlen(header);
|
||||||
if (len > 0) {
|
if(len > 0) {
|
||||||
int rawlen = Curl_base64_decode(header, (unsigned char **)&input_token.value);
|
int rawlen = Curl_base64_decode(header,
|
||||||
if (rawlen < 0)
|
(unsigned char **)&input_token.value);
|
||||||
|
if(rawlen < 0)
|
||||||
return -1;
|
return -1;
|
||||||
input_token.length = rawlen;
|
input_token.length = rawlen;
|
||||||
|
|
||||||
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
|
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
|
||||||
if (checkprefix("Negotiate", header)) {
|
if(checkprefix("Negotiate", header)) {
|
||||||
ASN1_OBJECT * object = NULL;
|
ASN1_OBJECT * object = NULL;
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
unsigned char * spnegoToken = NULL;
|
unsigned char * spnegoToken = NULL;
|
||||||
@@ -180,12 +186,12 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
size_t mechTokenLength = 0;
|
size_t mechTokenLength = 0;
|
||||||
|
|
||||||
spnegoToken = malloc(input_token.length);
|
spnegoToken = malloc(input_token.length);
|
||||||
if (input_token.value == NULL)
|
if(input_token.value == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
spnegoTokenLength = input_token.length;
|
spnegoTokenLength = input_token.length;
|
||||||
|
|
||||||
object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
|
object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
|
||||||
if (!parseSpnegoTargetToken(spnegoToken,
|
if(!parseSpnegoTargetToken(spnegoToken,
|
||||||
spnegoTokenLength,
|
spnegoTokenLength,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -224,17 +230,17 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
&output_token,
|
&output_token,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (input_token.length > 0)
|
if(input_token.length > 0)
|
||||||
gss_release_buffer(&minor_status2, &input_token);
|
gss_release_buffer(&minor_status2, &input_token);
|
||||||
neg_ctx->status = major_status;
|
neg_ctx->status = major_status;
|
||||||
if (GSS_ERROR(major_status)) {
|
if(GSS_ERROR(major_status)) {
|
||||||
/* Curl_cleanup_negotiate(conn->data) ??? */
|
/* Curl_cleanup_negotiate(conn->data) ??? */
|
||||||
log_gss_error(conn, minor_status,
|
log_gss_error(conn, minor_status,
|
||||||
(char *)"gss_init_sec_context() failed: ");
|
(char *)"gss_init_sec_context() failed: ");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_token.length == 0) {
|
if(output_token.length == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,13 +253,14 @@ int Curl_input_negotiate(struct connectdata *conn, bool proxy, const char *heade
|
|||||||
|
|
||||||
CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
|
CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
|
||||||
{
|
{
|
||||||
struct negotiatedata *neg_ctx = &conn->data->state.negotiate;
|
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
|
||||||
|
&conn->data->state.negotiate;
|
||||||
OM_uint32 minor_status;
|
OM_uint32 minor_status;
|
||||||
char *encoded = NULL;
|
char *encoded = NULL;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
|
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
|
||||||
if (checkprefix("Negotiate",neg_ctx->protocol)) {
|
if(checkprefix("Negotiate", neg_ctx->protocol)) {
|
||||||
ASN1_OBJECT * object = NULL;
|
ASN1_OBJECT * object = NULL;
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
unsigned char * spnegoToken = NULL;
|
unsigned char * spnegoToken = NULL;
|
||||||
@@ -262,14 +269,14 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
|
|||||||
size_t responseTokenLength = 0;
|
size_t responseTokenLength = 0;
|
||||||
|
|
||||||
responseToken = malloc(neg_ctx->output_token.length);
|
responseToken = malloc(neg_ctx->output_token.length);
|
||||||
if ( responseToken == NULL)
|
if( responseToken == NULL)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
memcpy(responseToken, neg_ctx->output_token.value,
|
memcpy(responseToken, neg_ctx->output_token.value,
|
||||||
neg_ctx->output_token.length);
|
neg_ctx->output_token.length);
|
||||||
responseTokenLength = neg_ctx->output_token.length;
|
responseTokenLength = neg_ctx->output_token.length;
|
||||||
|
|
||||||
object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
|
object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
|
||||||
if (!makeSpnegoInitialToken (object,
|
if(!makeSpnegoInitialToken (object,
|
||||||
responseToken,
|
responseToken,
|
||||||
responseTokenLength,
|
responseTokenLength,
|
||||||
&spnegoToken,
|
&spnegoToken,
|
||||||
@@ -295,33 +302,38 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
|
|||||||
neg_ctx->output_token.length,
|
neg_ctx->output_token.length,
|
||||||
&encoded);
|
&encoded);
|
||||||
|
|
||||||
if (len == 0)
|
if(len == 0)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
conn->allocptr.userpwd =
|
conn->allocptr.userpwd =
|
||||||
aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "", neg_ctx->protocol, encoded);
|
aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "",
|
||||||
|
neg_ctx->protocol, encoded);
|
||||||
free(encoded);
|
free(encoded);
|
||||||
gss_release_buffer(&minor_status, &neg_ctx->output_token);
|
gss_release_buffer(&minor_status, &neg_ctx->output_token);
|
||||||
return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
|
return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Curl_cleanup_negotiate(struct SessionHandle *data)
|
static void cleanup(struct negotiatedata *neg_ctx)
|
||||||
{
|
{
|
||||||
OM_uint32 minor_status;
|
OM_uint32 minor_status;
|
||||||
struct negotiatedata *neg_ctx = &data->state.negotiate;
|
if(neg_ctx->context != GSS_C_NO_CONTEXT)
|
||||||
|
|
||||||
if (neg_ctx->context != GSS_C_NO_CONTEXT)
|
|
||||||
gss_delete_sec_context(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER);
|
gss_delete_sec_context(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER);
|
||||||
|
|
||||||
if (neg_ctx->output_token.length != 0)
|
if(neg_ctx->output_token.length != 0)
|
||||||
gss_release_buffer(&minor_status, &neg_ctx->output_token);
|
gss_release_buffer(&minor_status, &neg_ctx->output_token);
|
||||||
|
|
||||||
if (neg_ctx->server_name != GSS_C_NO_NAME)
|
if(neg_ctx->server_name != GSS_C_NO_NAME)
|
||||||
gss_release_name(&minor_status, &neg_ctx->server_name);
|
gss_release_name(&minor_status, &neg_ctx->server_name);
|
||||||
|
|
||||||
memset(neg_ctx, 0, sizeof(*neg_ctx));
|
memset(neg_ctx, 0, sizeof(*neg_ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Curl_cleanup_negotiate(struct SessionHandle *data)
|
||||||
|
{
|
||||||
|
cleanup(&data->state.negotiate);
|
||||||
|
cleanup(&data->state.proxyneg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ static void print_hex(FILE *handle, const char *buf, size_t len)
|
|||||||
{
|
{
|
||||||
const char *p = buf;
|
const char *p = buf;
|
||||||
fprintf(stderr, "0x");
|
fprintf(stderr, "0x");
|
||||||
while (len-- > 0)
|
while(len-- > 0)
|
||||||
fprintf(stderr, "%02.2x", (unsigned int)*p++);
|
fprintf(stderr, "%02.2x", (unsigned int)*p++);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -263,7 +263,7 @@ CURLntlm Curl_input_ntlm(struct connectdata *conn,
|
|||||||
|
|
||||||
#ifdef USE_WINDOWS_SSPI
|
#ifdef USE_WINDOWS_SSPI
|
||||||
ntlm->type_2 = malloc(size+1);
|
ntlm->type_2 = malloc(size+1);
|
||||||
if (ntlm->type_2 == NULL) {
|
if(ntlm->type_2 == NULL) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -368,7 +368,7 @@ static void mk_lm_hash(struct SessionHandle *data,
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
size_t len = strlen(password);
|
size_t len = strlen(password);
|
||||||
|
|
||||||
if (len > 14)
|
if(len > 14)
|
||||||
len = 14;
|
len = 14;
|
||||||
|
|
||||||
for (i=0; i<len; i++)
|
for (i=0; i<len; i++)
|
||||||
@@ -425,7 +425,7 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
size_t len = strlen(password);
|
size_t len = strlen(password);
|
||||||
unsigned char *pw = malloc(len*2);
|
unsigned char *pw = malloc(len*2);
|
||||||
if (!pw)
|
if(!pw)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
utf8_to_unicode_le(pw, password, len);
|
utf8_to_unicode_le(pw, password, len);
|
||||||
@@ -465,19 +465,19 @@ static CURLcode mk_nt_hash(struct SessionHandle *data,
|
|||||||
static void
|
static void
|
||||||
ntlm_sspi_cleanup(struct ntlmdata *ntlm)
|
ntlm_sspi_cleanup(struct ntlmdata *ntlm)
|
||||||
{
|
{
|
||||||
if (ntlm->type_2) {
|
if(ntlm->type_2) {
|
||||||
free(ntlm->type_2);
|
free(ntlm->type_2);
|
||||||
ntlm->type_2 = NULL;
|
ntlm->type_2 = NULL;
|
||||||
}
|
}
|
||||||
if (ntlm->has_handles) {
|
if(ntlm->has_handles) {
|
||||||
s_pSecFn->DeleteSecurityContext(&ntlm->c_handle);
|
s_pSecFn->DeleteSecurityContext(&ntlm->c_handle);
|
||||||
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
|
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
|
||||||
ntlm->has_handles = 0;
|
ntlm->has_handles = 0;
|
||||||
}
|
}
|
||||||
if (ntlm->p_identity) {
|
if(ntlm->p_identity) {
|
||||||
if (ntlm->identity.User) free(ntlm->identity.User);
|
if(ntlm->identity.User) free(ntlm->identity.User);
|
||||||
if (ntlm->identity.Password) free(ntlm->identity.Password);
|
if(ntlm->identity.Password) free(ntlm->identity.Password);
|
||||||
if (ntlm->identity.Domain) free(ntlm->identity.Domain);
|
if(ntlm->identity.Domain) free(ntlm->identity.Domain);
|
||||||
ntlm->p_identity = NULL;
|
ntlm->p_identity = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,7 +546,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
|
|
||||||
#ifdef USE_WINDOWS_SSPI
|
#ifdef USE_WINDOWS_SSPI
|
||||||
/* If security interface is not yet initialized try to do this */
|
/* If security interface is not yet initialized try to do this */
|
||||||
if (s_hSecDll == NULL) {
|
if(s_hSecDll == NULL) {
|
||||||
/* Determine Windows version. Security functions are located in
|
/* Determine Windows version. Security functions are located in
|
||||||
* security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
|
* security.dll on WinNT 4.0 and in secur32.dll on Win9x. Win2K and XP
|
||||||
* contain both these DLLs (security.dll just forwards calls to
|
* contain both these DLLs (security.dll just forwards calls to
|
||||||
@@ -555,21 +555,21 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
OSVERSIONINFO osver;
|
OSVERSIONINFO osver;
|
||||||
osver.dwOSVersionInfoSize = sizeof(osver);
|
osver.dwOSVersionInfoSize = sizeof(osver);
|
||||||
GetVersionEx(&osver);
|
GetVersionEx(&osver);
|
||||||
if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT
|
if(osver.dwPlatformId == VER_PLATFORM_WIN32_NT
|
||||||
&& osver.dwMajorVersion == 4)
|
&& osver.dwMajorVersion == 4)
|
||||||
s_hSecDll = LoadLibrary("security.dll");
|
s_hSecDll = LoadLibrary("security.dll");
|
||||||
else
|
else
|
||||||
s_hSecDll = LoadLibrary("secur32.dll");
|
s_hSecDll = LoadLibrary("secur32.dll");
|
||||||
if (s_hSecDll != NULL) {
|
if(s_hSecDll != NULL) {
|
||||||
INIT_SECURITY_INTERFACE pInitSecurityInterface;
|
INIT_SECURITY_INTERFACE pInitSecurityInterface;
|
||||||
pInitSecurityInterface =
|
pInitSecurityInterface =
|
||||||
(INIT_SECURITY_INTERFACE)GetProcAddress(s_hSecDll,
|
(INIT_SECURITY_INTERFACE)GetProcAddress(s_hSecDll,
|
||||||
"InitSecurityInterfaceA");
|
"InitSecurityInterfaceA");
|
||||||
if (pInitSecurityInterface != NULL)
|
if(pInitSecurityInterface != NULL)
|
||||||
s_pSecFn = pInitSecurityInterface();
|
s_pSecFn = pInitSecurityInterface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s_pSecFn == NULL)
|
if(s_pSecFn == NULL)
|
||||||
return CURLE_RECV_ERROR;
|
return CURLE_RECV_ERROR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -589,10 +589,10 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
ntlm_sspi_cleanup(ntlm);
|
ntlm_sspi_cleanup(ntlm);
|
||||||
|
|
||||||
user = strchr(userp, '\\');
|
user = strchr(userp, '\\');
|
||||||
if (!user)
|
if(!user)
|
||||||
user = strchr(userp, '/');
|
user = strchr(userp, '/');
|
||||||
|
|
||||||
if (user) {
|
if(user) {
|
||||||
domain = userp;
|
domain = userp;
|
||||||
domlen = user - userp;
|
domlen = user - userp;
|
||||||
user++;
|
user++;
|
||||||
@@ -603,19 +603,19 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
domlen = 0;
|
domlen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user && *user) {
|
if(user && *user) {
|
||||||
/* note: initialize all of this before doing the mallocs so that
|
/* note: initialize all of this before doing the mallocs so that
|
||||||
* it can be cleaned up later without leaking memory.
|
* it can be cleaned up later without leaking memory.
|
||||||
*/
|
*/
|
||||||
ntlm->p_identity = &ntlm->identity;
|
ntlm->p_identity = &ntlm->identity;
|
||||||
memset(ntlm->p_identity, 0, sizeof(*ntlm->p_identity));
|
memset(ntlm->p_identity, 0, sizeof(*ntlm->p_identity));
|
||||||
if ((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL)
|
if((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
ntlm->identity.UserLength = strlen(user);
|
ntlm->identity.UserLength = strlen(user);
|
||||||
if ((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL)
|
if((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
ntlm->identity.PasswordLength = strlen(passwdp);
|
ntlm->identity.PasswordLength = strlen(passwdp);
|
||||||
if ((ntlm->identity.Domain = malloc(domlen+1)) == NULL)
|
if((ntlm->identity.Domain = malloc(domlen+1)) == NULL)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
strncpy((char *)ntlm->identity.Domain, domain, domlen);
|
strncpy((char *)ntlm->identity.Domain, domain, domlen);
|
||||||
ntlm->identity.Domain[domlen] = '\0';
|
ntlm->identity.Domain[domlen] = '\0';
|
||||||
@@ -626,7 +626,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
ntlm->p_identity = NULL;
|
ntlm->p_identity = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_pSecFn->AcquireCredentialsHandle(
|
if(s_pSecFn->AcquireCredentialsHandle(
|
||||||
NULL, (char *)"NTLM", SECPKG_CRED_OUTBOUND, NULL, ntlm->p_identity,
|
NULL, (char *)"NTLM", SECPKG_CRED_OUTBOUND, NULL, ntlm->p_identity,
|
||||||
NULL, NULL, &ntlm->handle, &tsDummy
|
NULL, NULL, &ntlm->handle, &tsDummy
|
||||||
) != SEC_E_OK) {
|
) != SEC_E_OK) {
|
||||||
@@ -650,11 +650,11 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
&ntlm->c_handle, &desc,
|
&ntlm->c_handle, &desc,
|
||||||
&attrs, &tsDummy);
|
&attrs, &tsDummy);
|
||||||
|
|
||||||
if (status == SEC_I_COMPLETE_AND_CONTINUE ||
|
if(status == SEC_I_COMPLETE_AND_CONTINUE ||
|
||||||
status == SEC_I_CONTINUE_NEEDED) {
|
status == SEC_I_CONTINUE_NEEDED) {
|
||||||
s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &desc);
|
s_pSecFn->CompleteAuthToken(&ntlm->c_handle, &desc);
|
||||||
}
|
}
|
||||||
else if (status != SEC_E_OK) {
|
else if(status != SEC_E_OK) {
|
||||||
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
|
s_pSecFn->FreeCredentialsHandle(&ntlm->handle);
|
||||||
return CURLE_RECV_ERROR;
|
return CURLE_RECV_ERROR;
|
||||||
}
|
}
|
||||||
@@ -805,7 +805,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
0, &ntlm->c_handle, &type_3_desc,
|
0, &ntlm->c_handle, &type_3_desc,
|
||||||
&attrs, &tsDummy);
|
&attrs, &tsDummy);
|
||||||
|
|
||||||
if (status != SEC_E_OK)
|
if(status != SEC_E_OK)
|
||||||
return CURLE_RECV_ERROR;
|
return CURLE_RECV_ERROR;
|
||||||
|
|
||||||
size = type_3.cbBuffer;
|
size = type_3.cbBuffer;
|
||||||
@@ -827,7 +827,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
if(!user)
|
if(!user)
|
||||||
user = strchr(userp, '/');
|
user = strchr(userp, '/');
|
||||||
|
|
||||||
if (user) {
|
if(user) {
|
||||||
domain = userp;
|
domain = userp;
|
||||||
domlen = (user - domain);
|
domlen = (user - domain);
|
||||||
user++;
|
user++;
|
||||||
@@ -836,7 +836,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
user = userp;
|
user = userp;
|
||||||
userlen = strlen(user);
|
userlen = strlen(user);
|
||||||
|
|
||||||
if (gethostname(host, HOSTNAME_MAX)) {
|
if(gethostname(host, HOSTNAME_MAX)) {
|
||||||
infof(conn->data, "gethostname() failed, continuing without!");
|
infof(conn->data, "gethostname() failed, continuing without!");
|
||||||
hostlen = 0;
|
hostlen = 0;
|
||||||
}
|
}
|
||||||
@@ -846,14 +846,14 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
* name, which NTLM doesn't like.
|
* name, which NTLM doesn't like.
|
||||||
*/
|
*/
|
||||||
char *dot = strchr(host, '.');
|
char *dot = strchr(host, '.');
|
||||||
if (dot)
|
if(dot)
|
||||||
*dot = '\0';
|
*dot = '\0';
|
||||||
hostlen = strlen(host);
|
hostlen = strlen(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_NTLM2SESSION
|
#if USE_NTLM2SESSION
|
||||||
/* We don't support NTLM2 if we don't have USE_NTRESPONSES */
|
/* We don't support NTLM2 if we don't have USE_NTRESPONSES */
|
||||||
if (ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
|
if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
|
||||||
unsigned char ntbuffer[0x18];
|
unsigned char ntbuffer[0x18];
|
||||||
unsigned char tmp[0x18];
|
unsigned char tmp[0x18];
|
||||||
unsigned char md5sum[MD5_DIGEST_LENGTH];
|
unsigned char md5sum[MD5_DIGEST_LENGTH];
|
||||||
@@ -878,7 +878,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
MD5_Final(md5sum, &MD5pw);
|
MD5_Final(md5sum, &MD5pw);
|
||||||
/* We shall only use the first 8 bytes of md5sum,
|
/* We shall only use the first 8 bytes of md5sum,
|
||||||
but the des code in lm_resp only encrypt the first 8 bytes */
|
but the des code in lm_resp only encrypt the first 8 bytes */
|
||||||
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
|
if(mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
lm_resp(ntbuffer, md5sum, ntresp);
|
lm_resp(ntbuffer, md5sum, ntresp);
|
||||||
|
|
||||||
@@ -893,7 +893,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn,
|
|||||||
unsigned char lmbuffer[0x18];
|
unsigned char lmbuffer[0x18];
|
||||||
|
|
||||||
#if USE_NTRESPONSES
|
#if USE_NTRESPONSES
|
||||||
if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
|
if(mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
lm_resp(ntbuffer, &ntlm->nonce[0], ntresp);
|
lm_resp(ntbuffer, &ntlm->nonce[0], ntresp);
|
||||||
#endif
|
#endif
|
||||||
@@ -1113,7 +1113,7 @@ Curl_ntlm_cleanup(struct connectdata *conn)
|
|||||||
#ifdef USE_WINDOWS_SSPI
|
#ifdef USE_WINDOWS_SSPI
|
||||||
ntlm_sspi_cleanup(&conn->ntlm);
|
ntlm_sspi_cleanup(&conn->ntlm);
|
||||||
ntlm_sspi_cleanup(&conn->proxyntlm);
|
ntlm_sspi_cleanup(&conn->proxyntlm);
|
||||||
if (s_hSecDll != NULL) {
|
if(s_hSecDll != NULL) {
|
||||||
FreeLibrary(s_hSecDll);
|
FreeLibrary(s_hSecDll);
|
||||||
s_hSecDll = NULL;
|
s_hSecDll = NULL;
|
||||||
s_pSecFn = NULL;
|
s_pSecFn = NULL;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
dummy = socket(AF_INET, SOCK_STREAM, 0);
|
dummy = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (SYS_ERROR == dummy) {
|
if(SYS_ERROR == dummy) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -105,9 +105,9 @@ char *Curl_if2ip(const char *interface, char *buf, int buf_size)
|
|||||||
memcpy(req.ifr_name, interface, len+1);
|
memcpy(req.ifr_name, interface, len+1);
|
||||||
req.ifr_addr.sa_family = AF_INET;
|
req.ifr_addr.sa_family = AF_INET;
|
||||||
#ifdef IOCTL_3_ARGS
|
#ifdef IOCTL_3_ARGS
|
||||||
if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
|
if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req)) {
|
||||||
#else
|
#else
|
||||||
if (SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
|
if(SYS_ERROR == ioctl(dummy, SIOCGIFADDR, &req, sizeof(req))) {
|
||||||
#endif
|
#endif
|
||||||
sclose(dummy);
|
sclose(dummy);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
|
|||||||
#else
|
#else
|
||||||
const char *addr = inet_ntoa(*(struct in_addr*)src);
|
const char *addr = inet_ntoa(*(struct in_addr*)src);
|
||||||
|
|
||||||
if (strlen(addr) >= size)
|
if(strlen(addr) >= size)
|
||||||
{
|
{
|
||||||
SET_ERRNO(ENOSPC);
|
SET_ERRNO(ENOSPC);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@@ -125,23 +125,23 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
|
|||||||
|
|
||||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
|
||||||
{
|
{
|
||||||
if (words[i] == 0)
|
if(words[i] == 0)
|
||||||
{
|
{
|
||||||
if (cur.base == -1)
|
if(cur.base == -1)
|
||||||
cur.base = i, cur.len = 1;
|
cur.base = i, cur.len = 1;
|
||||||
else
|
else
|
||||||
cur.len++;
|
cur.len++;
|
||||||
}
|
}
|
||||||
else if (cur.base != -1)
|
else if(cur.base != -1)
|
||||||
{
|
{
|
||||||
if (best.base == -1 || cur.len > best.len)
|
if(best.base == -1 || cur.len > best.len)
|
||||||
best = cur;
|
best = cur;
|
||||||
cur.base = -1;
|
cur.base = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
|
if((cur.base != -1) && (best.base == -1 || cur.len > best.len))
|
||||||
best = cur;
|
best = cur;
|
||||||
if (best.base != -1 && best.len < 2)
|
if(best.base != -1 && best.len < 2)
|
||||||
best.base = -1;
|
best.base = -1;
|
||||||
|
|
||||||
/* Format the result.
|
/* Format the result.
|
||||||
@@ -151,24 +151,24 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
|
|||||||
{
|
{
|
||||||
/* Are we inside the best run of 0x00's?
|
/* Are we inside the best run of 0x00's?
|
||||||
*/
|
*/
|
||||||
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
|
if(best.base != -1 && i >= best.base && i < (best.base + best.len))
|
||||||
{
|
{
|
||||||
if (i == best.base)
|
if(i == best.base)
|
||||||
*tp++ = ':';
|
*tp++ = ':';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Are we following an initial run of 0x00s or any real hex?
|
/* Are we following an initial run of 0x00s or any real hex?
|
||||||
*/
|
*/
|
||||||
if (i != 0)
|
if(i != 0)
|
||||||
*tp++ = ':';
|
*tp++ = ':';
|
||||||
|
|
||||||
/* Is this address an encapsulated IPv4?
|
/* Is this address an encapsulated IPv4?
|
||||||
*/
|
*/
|
||||||
if (i == 6 && best.base == 0 &&
|
if(i == 6 && best.base == 0 &&
|
||||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||||
{
|
{
|
||||||
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
|
if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
|
||||||
{
|
{
|
||||||
SET_ERRNO(ENOSPC);
|
SET_ERRNO(ENOSPC);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@@ -181,13 +181,13 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
|
|||||||
|
|
||||||
/* Was it a trailing run of 0x00's?
|
/* Was it a trailing run of 0x00's?
|
||||||
*/
|
*/
|
||||||
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
|
if(best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
|
||||||
*tp++ = ':';
|
*tp++ = ':';
|
||||||
*tp++ = '\0';
|
*tp++ = '\0';
|
||||||
|
|
||||||
/* Check for overflow, copy, and we're done.
|
/* Check for overflow, copy, and we're done.
|
||||||
*/
|
*/
|
||||||
if ((size_t)(tp - tmp) > size)
|
if((size_t)(tp - tmp) > size)
|
||||||
{
|
{
|
||||||
SET_ERRNO(ENOSPC);
|
SET_ERRNO(ENOSPC);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|||||||
@@ -108,29 +108,31 @@ inet_pton4(const char *src, unsigned char *dst)
|
|||||||
octets = 0;
|
octets = 0;
|
||||||
tp = tmp;
|
tp = tmp;
|
||||||
*tp = 0;
|
*tp = 0;
|
||||||
while ((ch = *src++) != '\0') {
|
while((ch = *src++) != '\0') {
|
||||||
const char *pch;
|
const char *pch;
|
||||||
|
|
||||||
if ((pch = strchr(digits, ch)) != NULL) {
|
if((pch = strchr(digits, ch)) != NULL) {
|
||||||
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
|
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
|
||||||
|
|
||||||
if (val > 255)
|
if(val > 255)
|
||||||
return (0);
|
return (0);
|
||||||
*tp = (unsigned char)val;
|
*tp = (unsigned char)val;
|
||||||
if (! saw_digit) {
|
if(! saw_digit) {
|
||||||
if (++octets > 4)
|
if(++octets > 4)
|
||||||
return (0);
|
return (0);
|
||||||
saw_digit = 1;
|
saw_digit = 1;
|
||||||
}
|
}
|
||||||
} else if (ch == '.' && saw_digit) {
|
}
|
||||||
if (octets == 4)
|
else if(ch == '.' && saw_digit) {
|
||||||
|
if(octets == 4)
|
||||||
return (0);
|
return (0);
|
||||||
*++tp = 0;
|
*++tp = 0;
|
||||||
saw_digit = 0;
|
saw_digit = 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (octets < 4)
|
if(octets < 4)
|
||||||
return (0);
|
return (0);
|
||||||
/* bcopy(tmp, dst, INADDRSZ); */
|
/* bcopy(tmp, dst, INADDRSZ); */
|
||||||
memcpy(dst, tmp, INADDRSZ);
|
memcpy(dst, tmp, INADDRSZ);
|
||||||
@@ -165,34 +167,34 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||||||
endp = tp + IN6ADDRSZ;
|
endp = tp + IN6ADDRSZ;
|
||||||
colonp = NULL;
|
colonp = NULL;
|
||||||
/* Leading :: requires some special handling. */
|
/* Leading :: requires some special handling. */
|
||||||
if (*src == ':')
|
if(*src == ':')
|
||||||
if (*++src != ':')
|
if(*++src != ':')
|
||||||
return (0);
|
return (0);
|
||||||
curtok = src;
|
curtok = src;
|
||||||
saw_xdigit = 0;
|
saw_xdigit = 0;
|
||||||
val = 0;
|
val = 0;
|
||||||
while ((ch = *src++) != '\0') {
|
while((ch = *src++) != '\0') {
|
||||||
const char *pch;
|
const char *pch;
|
||||||
|
|
||||||
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
if((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
||||||
pch = strchr((xdigits = xdigits_u), ch);
|
pch = strchr((xdigits = xdigits_u), ch);
|
||||||
if (pch != NULL) {
|
if(pch != NULL) {
|
||||||
val <<= 4;
|
val <<= 4;
|
||||||
val |= (pch - xdigits);
|
val |= (pch - xdigits);
|
||||||
if (val > 0xffff)
|
if(val > 0xffff)
|
||||||
return (0);
|
return (0);
|
||||||
saw_xdigit = 1;
|
saw_xdigit = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ch == ':') {
|
if(ch == ':') {
|
||||||
curtok = src;
|
curtok = src;
|
||||||
if (!saw_xdigit) {
|
if(!saw_xdigit) {
|
||||||
if (colonp)
|
if(colonp)
|
||||||
return (0);
|
return (0);
|
||||||
colonp = tp;
|
colonp = tp;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (tp + INT16SZ > endp)
|
if(tp + INT16SZ > endp)
|
||||||
return (0);
|
return (0);
|
||||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||||
*tp++ = (unsigned char) val & 0xff;
|
*tp++ = (unsigned char) val & 0xff;
|
||||||
@@ -200,7 +202,7 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||||||
val = 0;
|
val = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
|
if(ch == '.' && ((tp + INADDRSZ) <= endp) &&
|
||||||
inet_pton4(curtok, tp) > 0) {
|
inet_pton4(curtok, tp) > 0) {
|
||||||
tp += INADDRSZ;
|
tp += INADDRSZ;
|
||||||
saw_xdigit = 0;
|
saw_xdigit = 0;
|
||||||
@@ -208,13 +210,13 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (saw_xdigit) {
|
if(saw_xdigit) {
|
||||||
if (tp + INT16SZ > endp)
|
if(tp + INT16SZ > endp)
|
||||||
return (0);
|
return (0);
|
||||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||||
*tp++ = (unsigned char) val & 0xff;
|
*tp++ = (unsigned char) val & 0xff;
|
||||||
}
|
}
|
||||||
if (colonp != NULL) {
|
if(colonp != NULL) {
|
||||||
/*
|
/*
|
||||||
* Since some memmove()'s erroneously fail to handle
|
* Since some memmove()'s erroneously fail to handle
|
||||||
* overlapping regions, we'll do the shift by hand.
|
* overlapping regions, we'll do the shift by hand.
|
||||||
@@ -228,7 +230,7 @@ inet_pton6(const char *src, unsigned char *dst)
|
|||||||
}
|
}
|
||||||
tp = endp;
|
tp = endp;
|
||||||
}
|
}
|
||||||
if (tp != endp)
|
if(tp != endp)
|
||||||
return (0);
|
return (0);
|
||||||
/* bcopy(tmp, dst, IN6ADDRSZ); */
|
/* bcopy(tmp, dst, IN6ADDRSZ); */
|
||||||
memcpy(dst, tmp, IN6ADDRSZ);
|
memcpy(dst, tmp, IN6ADDRSZ);
|
||||||
|
|||||||
10
lib/krb4.c
10
lib/krb4.c
@@ -97,7 +97,7 @@ strlcpy (char *dst, const char *src, size_t dst_sz)
|
|||||||
++p, ++src, ++n)
|
++p, ++src, ++n)
|
||||||
*p = *src;
|
*p = *src;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (*src == '\0')
|
if(*src == '\0')
|
||||||
return n;
|
return n;
|
||||||
else
|
else
|
||||||
return n + strlen (src);
|
return n + strlen (src);
|
||||||
@@ -228,17 +228,17 @@ krb4_auth(void *app_data, struct connectdata *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_KRB_GET_OUR_IP_FOR_REALM
|
#ifdef HAVE_KRB_GET_OUR_IP_FOR_REALM
|
||||||
if (krb_get_config_bool("nat_in_use")) {
|
if(krb_get_config_bool("nat_in_use")) {
|
||||||
struct sockaddr_in *localaddr = (struct sockaddr_in *)LOCAL_ADDR;
|
struct sockaddr_in *localaddr = (struct sockaddr_in *)LOCAL_ADDR;
|
||||||
struct in_addr natAddr;
|
struct in_addr natAddr;
|
||||||
|
|
||||||
if (krb_get_our_ip_for_realm(krb_realmofhost(host),
|
if(krb_get_our_ip_for_realm(krb_realmofhost(host),
|
||||||
&natAddr) != KSUCCESS
|
&natAddr) != KSUCCESS
|
||||||
&& krb_get_our_ip_for_realm(NULL, &natAddr) != KSUCCESS)
|
&& krb_get_our_ip_for_realm(NULL, &natAddr) != KSUCCESS)
|
||||||
infof(data, "Can't get address for realm %s\n",
|
infof(data, "Can't get address for realm %s\n",
|
||||||
krb_realmofhost(host));
|
krb_realmofhost(host));
|
||||||
else {
|
else {
|
||||||
if (natAddr.s_addr != localaddr->sin_addr.s_addr) {
|
if(natAddr.s_addr != localaddr->sin_addr.s_addr) {
|
||||||
#ifdef HAVE_INET_NTOA_R
|
#ifdef HAVE_INET_NTOA_R
|
||||||
char ntoa_buf[64];
|
char ntoa_buf[64];
|
||||||
char *ip = (char *)inet_ntoa_r(natAddr, ntoa_buf, sizeof(ntoa_buf));
|
char *ip = (char *)inet_ntoa_r(natAddr, ntoa_buf, sizeof(ntoa_buf));
|
||||||
@@ -387,7 +387,7 @@ CURLcode Curl_krb_kauth(struct connectdata *conn)
|
|||||||
des_pcbc_encrypt((void *)tkt.dat, (void *)tktcopy.dat,
|
des_pcbc_encrypt((void *)tkt.dat, (void *)tktcopy.dat,
|
||||||
tkt.length,
|
tkt.length,
|
||||||
schedule, &key, DES_DECRYPT);
|
schedule, &key, DES_DECRYPT);
|
||||||
if (strcmp ((char*)tktcopy.dat + 8,
|
if(strcmp ((char*)tktcopy.dat + 8,
|
||||||
KRB_TICKET_GRANTING_TICKET) != 0) {
|
KRB_TICKET_GRANTING_TICKET) != 0) {
|
||||||
afs_string_to_key(passwd,
|
afs_string_to_key(passwd,
|
||||||
krb_realmofhost(conn->host.name),
|
krb_realmofhost(conn->host.name),
|
||||||
|
|||||||
138
lib/ldap.c
138
lib/ldap.c
@@ -110,7 +110,7 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp);
|
|||||||
#define LDAP_TRACE(x) do { \
|
#define LDAP_TRACE(x) do { \
|
||||||
_ldap_trace ("%u: ", __LINE__); \
|
_ldap_trace ("%u: ", __LINE__); \
|
||||||
_ldap_trace x; \
|
_ldap_trace x; \
|
||||||
} while (0)
|
} while(0)
|
||||||
|
|
||||||
static void _ldap_trace (const char *fmt, ...);
|
static void _ldap_trace (const char *fmt, ...);
|
||||||
#else
|
#else
|
||||||
@@ -191,14 +191,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
#else
|
#else
|
||||||
rc = _ldap_url_parse(conn, &ludp);
|
rc = _ldap_url_parse(conn, &ludp);
|
||||||
#endif
|
#endif
|
||||||
if (rc != 0) {
|
if(rc != 0) {
|
||||||
failf(data, "LDAP local: %s", ldap_err2string(rc));
|
failf(data, "LDAP local: %s", ldap_err2string(rc));
|
||||||
status = CURLE_LDAP_INVALID_URL;
|
status = CURLE_LDAP_INVALID_URL;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the URL scheme ( either ldap or ldaps ) */
|
/* Get the URL scheme ( either ldap or ldaps ) */
|
||||||
if (strequal(conn->protostr, "LDAPS"))
|
if(strequal(conn->protostr, "LDAPS"))
|
||||||
ldap_ssl = 1;
|
ldap_ssl = 1;
|
||||||
infof(data, "LDAP local: trying to establish %s connection\n",
|
infof(data, "LDAP local: trying to establish %s connection\n",
|
||||||
ldap_ssl ? "encrypted" : "cleartext");
|
ldap_ssl ? "encrypted" : "cleartext");
|
||||||
@@ -208,7 +208,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
#endif
|
#endif
|
||||||
ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
||||||
|
|
||||||
if (ldap_ssl) {
|
if(ldap_ssl) {
|
||||||
#ifdef HAVE_LDAP_SSL
|
#ifdef HAVE_LDAP_SSL
|
||||||
#ifdef CURL_LDAP_WIN
|
#ifdef CURL_LDAP_WIN
|
||||||
/* Win32 LDAP SDK doesnt support insecure mode without CA! */
|
/* Win32 LDAP SDK doesnt support insecure mode without CA! */
|
||||||
@@ -219,18 +219,18 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
|
char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
|
||||||
#if defined(CURL_HAS_NOVELL_LDAPSDK)
|
#if defined(CURL_HAS_NOVELL_LDAPSDK)
|
||||||
rc = ldapssl_client_init(NULL, NULL);
|
rc = ldapssl_client_init(NULL, NULL);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
|
failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
if (data->set.ssl.verifypeer) {
|
if(data->set.ssl.verifypeer) {
|
||||||
/* Novell SDK supports DER or BASE64 files. */
|
/* Novell SDK supports DER or BASE64 files. */
|
||||||
int cert_type = LDAPSSL_CERT_FILETYPE_B64;
|
int cert_type = LDAPSSL_CERT_FILETYPE_B64;
|
||||||
if ((data->set.str[STRING_CERT_TYPE]) &&
|
if((data->set.str[STRING_CERT_TYPE]) &&
|
||||||
(strequal(data->set.str[STRING_CERT_TYPE], "DER")))
|
(strequal(data->set.str[STRING_CERT_TYPE], "DER")))
|
||||||
cert_type = LDAPSSL_CERT_FILETYPE_DER;
|
cert_type = LDAPSSL_CERT_FILETYPE_DER;
|
||||||
if (!ldap_ca) {
|
if(!ldap_ca) {
|
||||||
failf(data, "LDAP local: ERROR %s CA cert not set!",
|
failf(data, "LDAP local: ERROR %s CA cert not set!",
|
||||||
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
|
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
@@ -240,7 +240,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
|
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
|
||||||
ldap_ca);
|
ldap_ca);
|
||||||
rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
|
rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ERROR setting %s CA cert: %s",
|
failf(data, "LDAP local: ERROR setting %s CA cert: %s",
|
||||||
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
|
(cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
@@ -252,36 +252,36 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
ldap_option = LDAPSSL_VERIFY_NONE;
|
ldap_option = LDAPSSL_VERIFY_NONE;
|
||||||
}
|
}
|
||||||
rc = ldapssl_set_verify_mode(ldap_option);
|
rc = ldapssl_set_verify_mode(ldap_option);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
|
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
server = ldapssl_init(conn->host.name, (int)conn->port, 1);
|
server = ldapssl_init(conn->host.name, (int)conn->port, 1);
|
||||||
if (server == NULL) {
|
if(server == NULL) {
|
||||||
failf(data, "LDAP local: Cannot connect to %s:%d",
|
failf(data, "LDAP local: Cannot connect to %s:%d",
|
||||||
conn->host.name, conn->port);
|
conn->host.name, conn->port);
|
||||||
status = CURLE_COULDNT_CONNECT;
|
status = CURLE_COULDNT_CONNECT;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
#elif defined(LDAP_OPT_X_TLS)
|
#elif defined(LDAP_OPT_X_TLS)
|
||||||
if (data->set.ssl.verifypeer) {
|
if(data->set.ssl.verifypeer) {
|
||||||
/* OpenLDAP SDK supports BASE64 files. */
|
/* OpenLDAP SDK supports BASE64 files. */
|
||||||
if ((data->set.str[STRING_CERT_TYPE]) &&
|
if((data->set.str[STRING_CERT_TYPE]) &&
|
||||||
(!strequal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
|
(!strequal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
|
||||||
failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!");
|
failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!");
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
if (!ldap_ca) {
|
if(!ldap_ca) {
|
||||||
failf(data, "LDAP local: ERROR PEM CA cert not set!");
|
failf(data, "LDAP local: ERROR PEM CA cert not set!");
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
|
infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
|
||||||
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
|
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
|
failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
@@ -292,14 +292,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
ldap_option = LDAP_OPT_X_TLS_NEVER;
|
ldap_option = LDAP_OPT_X_TLS_NEVER;
|
||||||
}
|
}
|
||||||
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
|
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
|
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
server = ldap_init(conn->host.name, (int)conn->port);
|
server = ldap_init(conn->host.name, (int)conn->port);
|
||||||
if (server == NULL) {
|
if(server == NULL) {
|
||||||
failf(data, "LDAP local: Cannot connect to %s:%d",
|
failf(data, "LDAP local: Cannot connect to %s:%d",
|
||||||
conn->host.name, conn->port);
|
conn->host.name, conn->port);
|
||||||
status = CURLE_COULDNT_CONNECT;
|
status = CURLE_COULDNT_CONNECT;
|
||||||
@@ -307,7 +307,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
ldap_option = LDAP_OPT_X_TLS_HARD;
|
ldap_option = LDAP_OPT_X_TLS_HARD;
|
||||||
rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
|
rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
|
failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
@@ -315,7 +315,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
rc = ldap_start_tls_s(server, NULL, NULL);
|
rc = ldap_start_tls_s(server, NULL, NULL);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
|
failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
|
||||||
ldap_err2string(rc));
|
ldap_err2string(rc));
|
||||||
status = CURLE_SSL_CERTPROBLEM;
|
status = CURLE_SSL_CERTPROBLEM;
|
||||||
@@ -334,7 +334,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
#endif /* CURL_LDAP_USE_SSL */
|
#endif /* CURL_LDAP_USE_SSL */
|
||||||
} else {
|
} else {
|
||||||
server = ldap_init(conn->host.name, (int)conn->port);
|
server = ldap_init(conn->host.name, (int)conn->port);
|
||||||
if (server == NULL) {
|
if(server == NULL) {
|
||||||
failf(data, "LDAP local: Cannot connect to %s:%d",
|
failf(data, "LDAP local: Cannot connect to %s:%d",
|
||||||
conn->host.name, conn->port);
|
conn->host.name, conn->port);
|
||||||
status = CURLE_COULDNT_CONNECT;
|
status = CURLE_COULDNT_CONNECT;
|
||||||
@@ -348,14 +348,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
rc = ldap_simple_bind_s(server,
|
rc = ldap_simple_bind_s(server,
|
||||||
conn->bits.user_passwd ? conn->user : NULL,
|
conn->bits.user_passwd ? conn->user : NULL,
|
||||||
conn->bits.user_passwd ? conn->passwd : NULL);
|
conn->bits.user_passwd ? conn->passwd : NULL);
|
||||||
if (!ldap_ssl && rc != 0) {
|
if(!ldap_ssl && rc != 0) {
|
||||||
ldap_proto = LDAP_VERSION2;
|
ldap_proto = LDAP_VERSION2;
|
||||||
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
|
||||||
rc = ldap_simple_bind_s(server,
|
rc = ldap_simple_bind_s(server,
|
||||||
conn->bits.user_passwd ? conn->user : NULL,
|
conn->bits.user_passwd ? conn->user : NULL,
|
||||||
conn->bits.user_passwd ? conn->passwd : NULL);
|
conn->bits.user_passwd ? conn->passwd : NULL);
|
||||||
}
|
}
|
||||||
if (rc != 0) {
|
if(rc != 0) {
|
||||||
failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
|
failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
|
||||||
status = CURLE_LDAP_CANNOT_BIND;
|
status = CURLE_LDAP_CANNOT_BIND;
|
||||||
goto quit;
|
goto quit;
|
||||||
@@ -364,7 +364,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
|
rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
|
||||||
ludp->lud_filter, ludp->lud_attrs, 0, &result);
|
ludp->lud_filter, ludp->lud_attrs, 0, &result);
|
||||||
|
|
||||||
if (rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
|
if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
|
||||||
failf(data, "LDAP remote: %s", ldap_err2string(rc));
|
failf(data, "LDAP remote: %s", ldap_err2string(rc));
|
||||||
status = CURLE_LDAP_SEARCH_FAILED;
|
status = CURLE_LDAP_SEARCH_FAILED;
|
||||||
goto quit;
|
goto quit;
|
||||||
@@ -389,14 +389,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
{
|
{
|
||||||
BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);
|
BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);
|
||||||
|
|
||||||
if (vals != NULL)
|
if(vals != NULL)
|
||||||
{
|
{
|
||||||
for (i = 0; (vals[i] != NULL); i++)
|
for (i = 0; (vals[i] != NULL); i++)
|
||||||
{
|
{
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
|
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
|
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
|
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
|
||||||
if ((strlen(attribute) > 7) &&
|
if((strlen(attribute) > 7) &&
|
||||||
(strcmp(";binary",
|
(strcmp(";binary",
|
||||||
(char *)attribute +
|
(char *)attribute +
|
||||||
(strlen((char *)attribute) - 7)) == 0)) {
|
(strlen((char *)attribute) - 7)) == 0)) {
|
||||||
@@ -405,7 +405,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
vals[i]->bv_val,
|
vals[i]->bv_val,
|
||||||
vals[i]->bv_len,
|
vals[i]->bv_len,
|
||||||
&val_b64);
|
&val_b64);
|
||||||
if (val_b64_sz > 0) {
|
if(val_b64_sz > 0) {
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
|
Curl_client_write(conn, CLIENTWRITE_BODY, val_b64, val_b64_sz);
|
||||||
free(val_b64);
|
free(val_b64);
|
||||||
}
|
}
|
||||||
@@ -423,23 +423,23 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
|
|||||||
ldap_memfree(attribute);
|
ldap_memfree(attribute);
|
||||||
}
|
}
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
if (ber)
|
if(ber)
|
||||||
ber_free(ber, 0);
|
ber_free(ber, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
quit:
|
quit:
|
||||||
if (result) {
|
if(result) {
|
||||||
ldap_msgfree(result);
|
ldap_msgfree(result);
|
||||||
LDAP_TRACE (("Received %d entries\n", num));
|
LDAP_TRACE (("Received %d entries\n", num));
|
||||||
}
|
}
|
||||||
if (rc == LDAP_SIZELIMIT_EXCEEDED)
|
if(rc == LDAP_SIZELIMIT_EXCEEDED)
|
||||||
infof(data, "There are more than %d entries\n", num);
|
infof(data, "There are more than %d entries\n", num);
|
||||||
if (ludp)
|
if(ludp)
|
||||||
ldap_free_urldesc(ludp);
|
ldap_free_urldesc(ludp);
|
||||||
if (server)
|
if(server)
|
||||||
ldap_unbind_s(server);
|
ldap_unbind_s(server);
|
||||||
#if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
|
#if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
|
||||||
if (ldap_ssl)
|
if(ldap_ssl)
|
||||||
ldapssl_client_deinit();
|
ldapssl_client_deinit();
|
||||||
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
|
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
|
||||||
|
|
||||||
@@ -456,11 +456,11 @@ static void _ldap_trace (const char *fmt, ...)
|
|||||||
static int do_trace = -1;
|
static int do_trace = -1;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (do_trace == -1) {
|
if(do_trace == -1) {
|
||||||
const char *env = getenv("CURL_TRACE");
|
const char *env = getenv("CURL_TRACE");
|
||||||
do_trace = (env && atoi(env) > 0);
|
do_trace = (env && atoi(env) > 0);
|
||||||
}
|
}
|
||||||
if (!do_trace)
|
if(!do_trace)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
@@ -476,15 +476,15 @@ static void _ldap_trace (const char *fmt, ...)
|
|||||||
*/
|
*/
|
||||||
static int str2scope (const char *p)
|
static int str2scope (const char *p)
|
||||||
{
|
{
|
||||||
if (!stricmp(p, "one"))
|
if(!stricmp(p, "one"))
|
||||||
return LDAP_SCOPE_ONELEVEL;
|
return LDAP_SCOPE_ONELEVEL;
|
||||||
if (!stricmp(p, "onetree"))
|
if(!stricmp(p, "onetree"))
|
||||||
return LDAP_SCOPE_ONELEVEL;
|
return LDAP_SCOPE_ONELEVEL;
|
||||||
if (!stricmp(p, "base"))
|
if(!stricmp(p, "base"))
|
||||||
return LDAP_SCOPE_BASE;
|
return LDAP_SCOPE_BASE;
|
||||||
if (!stricmp(p, "sub"))
|
if(!stricmp(p, "sub"))
|
||||||
return LDAP_SCOPE_SUBTREE;
|
return LDAP_SCOPE_SUBTREE;
|
||||||
if (!stricmp( p, "subtree"))
|
if(!stricmp( p, "subtree"))
|
||||||
return LDAP_SCOPE_SUBTREE;
|
return LDAP_SCOPE_SUBTREE;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -502,7 +502,7 @@ static char **split_str (char *str)
|
|||||||
s = strchr(++s,',');
|
s = strchr(++s,',');
|
||||||
|
|
||||||
res = calloc(i, sizeof(char*));
|
res = calloc(i, sizeof(char*));
|
||||||
if (!res)
|
if(!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0, s = strtok_r(str, ",", &lasts); s;
|
for (i = 0, s = strtok_r(str, ",", &lasts); s;
|
||||||
@@ -518,31 +518,31 @@ static bool unescape_elements (void *data, LDAPURLDesc *ludp)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (ludp->lud_filter) {
|
if(ludp->lud_filter) {
|
||||||
ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL);
|
ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL);
|
||||||
if (!ludp->lud_filter)
|
if(!ludp->lud_filter)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
|
for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
|
||||||
ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], 0, NULL);
|
ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], 0, NULL);
|
||||||
if (!ludp->lud_attrs[i])
|
if(!ludp->lud_attrs[i])
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
|
for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
|
||||||
ludp->lud_exts[i] = curl_easy_unescape(data, ludp->lud_exts[i], 0, NULL);
|
ludp->lud_exts[i] = curl_easy_unescape(data, ludp->lud_exts[i], 0, NULL);
|
||||||
if (!ludp->lud_exts[i])
|
if(!ludp->lud_exts[i])
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ludp->lud_dn) {
|
if(ludp->lud_dn) {
|
||||||
char *dn = ludp->lud_dn;
|
char *dn = ludp->lud_dn;
|
||||||
char *new_dn = curl_easy_unescape(data, dn, 0, NULL);
|
char *new_dn = curl_easy_unescape(data, dn, 0, NULL);
|
||||||
|
|
||||||
free(dn);
|
free(dn);
|
||||||
ludp->lud_dn = new_dn;
|
ludp->lud_dn = new_dn;
|
||||||
if (!new_dn)
|
if(!new_dn)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@@ -567,7 +567,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
|||||||
char *p, *q;
|
char *p, *q;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!conn->data ||
|
if(!conn->data ||
|
||||||
!conn->data->reqdata.path ||
|
!conn->data->reqdata.path ||
|
||||||
conn->data->reqdata.path[0] != '/' ||
|
conn->data->reqdata.path[0] != '/' ||
|
||||||
!checkprefix(conn->protostr, conn->data->change.url))
|
!checkprefix(conn->protostr, conn->data->change.url))
|
||||||
@@ -580,14 +580,14 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
|||||||
/* parse DN (Distinguished Name).
|
/* parse DN (Distinguished Name).
|
||||||
*/
|
*/
|
||||||
ludp->lud_dn = strdup(conn->data->reqdata.path+1);
|
ludp->lud_dn = strdup(conn->data->reqdata.path+1);
|
||||||
if (!ludp->lud_dn)
|
if(!ludp->lud_dn)
|
||||||
return LDAP_NO_MEMORY;
|
return LDAP_NO_MEMORY;
|
||||||
|
|
||||||
p = strchr(ludp->lud_dn, '?');
|
p = strchr(ludp->lud_dn, '?');
|
||||||
LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) :
|
LDAP_TRACE (("DN '%.*s'\n", p ? (size_t)(p-ludp->lud_dn) :
|
||||||
strlen(ludp->lud_dn), ludp->lud_dn));
|
strlen(ludp->lud_dn), ludp->lud_dn));
|
||||||
|
|
||||||
if (!p)
|
if(!p)
|
||||||
goto success;
|
goto success;
|
||||||
|
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
@@ -595,12 +595,12 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
|||||||
/* parse attributes. skip "??".
|
/* parse attributes. skip "??".
|
||||||
*/
|
*/
|
||||||
q = strchr(p, '?');
|
q = strchr(p, '?');
|
||||||
if (q)
|
if(q)
|
||||||
*q++ = '\0';
|
*q++ = '\0';
|
||||||
|
|
||||||
if (*p && *p != '?') {
|
if(*p && *p != '?') {
|
||||||
ludp->lud_attrs = split_str(p);
|
ludp->lud_attrs = split_str(p);
|
||||||
if (!ludp->lud_attrs)
|
if(!ludp->lud_attrs)
|
||||||
return LDAP_NO_MEMORY;
|
return LDAP_NO_MEMORY;
|
||||||
|
|
||||||
for (i = 0; ludp->lud_attrs[i]; i++)
|
for (i = 0; ludp->lud_attrs[i]; i++)
|
||||||
@@ -608,52 +608,52 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = q;
|
p = q;
|
||||||
if (!p)
|
if(!p)
|
||||||
goto success;
|
goto success;
|
||||||
|
|
||||||
/* parse scope. skip "??"
|
/* parse scope. skip "??"
|
||||||
*/
|
*/
|
||||||
q = strchr(p, '?');
|
q = strchr(p, '?');
|
||||||
if (q)
|
if(q)
|
||||||
*q++ = '\0';
|
*q++ = '\0';
|
||||||
|
|
||||||
if (*p && *p != '?') {
|
if(*p && *p != '?') {
|
||||||
ludp->lud_scope = str2scope(p);
|
ludp->lud_scope = str2scope(p);
|
||||||
if (ludp->lud_scope == -1)
|
if(ludp->lud_scope == -1)
|
||||||
return LDAP_INVALID_SYNTAX;
|
return LDAP_INVALID_SYNTAX;
|
||||||
LDAP_TRACE (("scope %d\n", ludp->lud_scope));
|
LDAP_TRACE (("scope %d\n", ludp->lud_scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
p = q;
|
p = q;
|
||||||
if (!p)
|
if(!p)
|
||||||
goto success;
|
goto success;
|
||||||
|
|
||||||
/* parse filter
|
/* parse filter
|
||||||
*/
|
*/
|
||||||
q = strchr(p, '?');
|
q = strchr(p, '?');
|
||||||
if (q)
|
if(q)
|
||||||
*q++ = '\0';
|
*q++ = '\0';
|
||||||
if (!*p)
|
if(!*p)
|
||||||
return LDAP_INVALID_SYNTAX;
|
return LDAP_INVALID_SYNTAX;
|
||||||
|
|
||||||
ludp->lud_filter = p;
|
ludp->lud_filter = p;
|
||||||
LDAP_TRACE (("filter '%s'\n", ludp->lud_filter));
|
LDAP_TRACE (("filter '%s'\n", ludp->lud_filter));
|
||||||
|
|
||||||
p = q;
|
p = q;
|
||||||
if (!p)
|
if(!p)
|
||||||
goto success;
|
goto success;
|
||||||
|
|
||||||
/* parse extensions
|
/* parse extensions
|
||||||
*/
|
*/
|
||||||
ludp->lud_exts = split_str(p);
|
ludp->lud_exts = split_str(p);
|
||||||
if (!ludp->lud_exts)
|
if(!ludp->lud_exts)
|
||||||
return LDAP_NO_MEMORY;
|
return LDAP_NO_MEMORY;
|
||||||
|
|
||||||
for (i = 0; ludp->lud_exts[i]; i++)
|
for (i = 0; ludp->lud_exts[i]; i++)
|
||||||
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
|
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
|
||||||
|
|
||||||
success:
|
success:
|
||||||
if (!unescape_elements(conn->data, ludp))
|
if(!unescape_elements(conn->data, ludp))
|
||||||
return LDAP_NO_MEMORY;
|
return LDAP_NO_MEMORY;
|
||||||
return LDAP_SUCCESS;
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -665,11 +665,11 @@ static int _ldap_url_parse (const struct connectdata *conn,
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
*ludpp = NULL;
|
*ludpp = NULL;
|
||||||
if (!ludp)
|
if(!ludp)
|
||||||
return LDAP_NO_MEMORY;
|
return LDAP_NO_MEMORY;
|
||||||
|
|
||||||
rc = _ldap_url_parse2 (conn, ludp);
|
rc = _ldap_url_parse2 (conn, ludp);
|
||||||
if (rc != LDAP_SUCCESS) {
|
if(rc != LDAP_SUCCESS) {
|
||||||
_ldap_free_urldesc(ludp);
|
_ldap_free_urldesc(ludp);
|
||||||
ludp = NULL;
|
ludp = NULL;
|
||||||
}
|
}
|
||||||
@@ -681,22 +681,22 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!ludp)
|
if(!ludp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ludp->lud_dn)
|
if(ludp->lud_dn)
|
||||||
free(ludp->lud_dn);
|
free(ludp->lud_dn);
|
||||||
|
|
||||||
if (ludp->lud_filter)
|
if(ludp->lud_filter)
|
||||||
free(ludp->lud_filter);
|
free(ludp->lud_filter);
|
||||||
|
|
||||||
if (ludp->lud_attrs) {
|
if(ludp->lud_attrs) {
|
||||||
for (i = 0; ludp->lud_attrs[i]; i++)
|
for (i = 0; ludp->lud_attrs[i]; i++)
|
||||||
free(ludp->lud_attrs[i]);
|
free(ludp->lud_attrs[i]);
|
||||||
free(ludp->lud_attrs);
|
free(ludp->lud_attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ludp->lud_exts) {
|
if(ludp->lud_exts) {
|
||||||
for (i = 0; ludp->lud_exts[i]; i++)
|
for (i = 0; ludp->lud_exts[i]; i++)
|
||||||
free(ludp->lud_exts[i]);
|
free(ludp->lud_exts[i]);
|
||||||
free(ludp->lud_exts);
|
free(ludp->lud_exts);
|
||||||
|
|||||||
16
lib/llist.c
16
lib/llist.c
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -68,7 +68,7 @@ Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ne->ptr = (void *) p;
|
ne->ptr = (void *) p;
|
||||||
if (list->size == 0) {
|
if(list->size == 0) {
|
||||||
list->head = ne;
|
list->head = ne;
|
||||||
list->head->prev = NULL;
|
list->head->prev = NULL;
|
||||||
list->head->next = NULL;
|
list->head->next = NULL;
|
||||||
@@ -77,7 +77,7 @@ Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
|
|||||||
else {
|
else {
|
||||||
ne->next = e->next;
|
ne->next = e->next;
|
||||||
ne->prev = e;
|
ne->prev = e;
|
||||||
if (e->next) {
|
if(e->next) {
|
||||||
e->next->prev = ne;
|
e->next->prev = ne;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -95,19 +95,19 @@ int
|
|||||||
Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
|
Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
|
||||||
void *user)
|
void *user)
|
||||||
{
|
{
|
||||||
if (e == NULL || list->size == 0)
|
if(e == NULL || list->size == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (e == list->head) {
|
if(e == list->head) {
|
||||||
list->head = e->next;
|
list->head = e->next;
|
||||||
|
|
||||||
if (list->head == NULL)
|
if(list->head == NULL)
|
||||||
list->tail = NULL;
|
list->tail = NULL;
|
||||||
else
|
else
|
||||||
e->next->prev = NULL;
|
e->next->prev = NULL;
|
||||||
} else {
|
} else {
|
||||||
e->prev->next = e->next;
|
e->prev->next = e->next;
|
||||||
if (!e->next)
|
if(!e->next)
|
||||||
list->tail = e->prev;
|
list->tail = e->prev;
|
||||||
else
|
else
|
||||||
e->next->prev = e->prev;
|
e->next->prev = e->prev;
|
||||||
@@ -124,7 +124,7 @@ void
|
|||||||
Curl_llist_destroy(struct curl_llist *list, void *user)
|
Curl_llist_destroy(struct curl_llist *list, void *user)
|
||||||
{
|
{
|
||||||
if(list) {
|
if(list) {
|
||||||
while (list->size > 0)
|
while(list->size > 0)
|
||||||
Curl_llist_remove(list, list->tail, user);
|
Curl_llist_remove(list, list->tail, user);
|
||||||
|
|
||||||
free(list);
|
free(list);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -161,7 +161,7 @@ static void MD5_Update (struct md5_ctx *context, /* context */
|
|||||||
bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
|
bufindex = (unsigned int)((context->count[0] >> 3) & 0x3F);
|
||||||
|
|
||||||
/* Update number of bits */
|
/* Update number of bits */
|
||||||
if ((context->count[0] += ((UINT4)inputLen << 3))
|
if((context->count[0] += ((UINT4)inputLen << 3))
|
||||||
< ((UINT4)inputLen << 3))
|
< ((UINT4)inputLen << 3))
|
||||||
context->count[1]++;
|
context->count[1]++;
|
||||||
context->count[1] += ((UINT4)inputLen >> 29);
|
context->count[1] += ((UINT4)inputLen >> 29);
|
||||||
@@ -169,7 +169,7 @@ static void MD5_Update (struct md5_ctx *context, /* context */
|
|||||||
partLen = 64 - bufindex;
|
partLen = 64 - bufindex;
|
||||||
|
|
||||||
/* Transform as many times as possible. */
|
/* Transform as many times as possible. */
|
||||||
if (inputLen >= partLen) {
|
if(inputLen >= partLen) {
|
||||||
memcpy((void *)&context->buffer[bufindex], (void *)input, partLen);
|
memcpy((void *)&context->buffer[bufindex], (void *)input, partLen);
|
||||||
MD5Transform(context->state, context->buffer);
|
MD5Transform(context->state, context->buffer);
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static long memsize = 0; /* set number of mallocs allowed */
|
|||||||
/* this sets the log file name */
|
/* this sets the log file name */
|
||||||
void curl_memdebug(const char *logname)
|
void curl_memdebug(const char *logname)
|
||||||
{
|
{
|
||||||
if (!logfile) {
|
if(!logfile) {
|
||||||
if(logname)
|
if(logname)
|
||||||
logfile = fopen(logname, "w");
|
logfile = fopen(logname, "w");
|
||||||
else
|
else
|
||||||
@@ -87,7 +87,7 @@ void curl_memdebug(const char *logname)
|
|||||||
successfully! */
|
successfully! */
|
||||||
void curl_memlimit(long limit)
|
void curl_memlimit(long limit)
|
||||||
{
|
{
|
||||||
if (!memlimit) {
|
if(!memlimit) {
|
||||||
memlimit = TRUE;
|
memlimit = TRUE;
|
||||||
memsize = limit;
|
memsize = limit;
|
||||||
}
|
}
|
||||||
@@ -185,8 +185,8 @@ char *curl_dostrdup(const char *str, int line, const char *source)
|
|||||||
len=strlen(str)+1;
|
len=strlen(str)+1;
|
||||||
|
|
||||||
mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */
|
mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */
|
||||||
if (mem)
|
if(mem)
|
||||||
memcpy(mem, str, len);
|
memcpy(mem, str, len);
|
||||||
|
|
||||||
if(logfile)
|
if(logfile)
|
||||||
fprintf(logfile, "MEM %s:%d strdup(%p) (%zd) = %p\n",
|
fprintf(logfile, "MEM %s:%d strdup(%p) (%zd) = %p\n",
|
||||||
|
|||||||
141
lib/mprintf.c
141
lib/mprintf.c
@@ -308,9 +308,9 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
long max_param=0;
|
long max_param=0;
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
while (*fmt) {
|
while(*fmt) {
|
||||||
if (*fmt++ == '%') {
|
if(*fmt++ == '%') {
|
||||||
if (*fmt == '%') {
|
if(*fmt == '%') {
|
||||||
fmt++;
|
fmt++;
|
||||||
continue; /* while */
|
continue; /* while */
|
||||||
}
|
}
|
||||||
@@ -322,11 +322,11 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
param_num++;
|
param_num++;
|
||||||
|
|
||||||
this_param = dprintf_DollarString(fmt, &fmt);
|
this_param = dprintf_DollarString(fmt, &fmt);
|
||||||
if (0 == this_param)
|
if(0 == this_param)
|
||||||
/* we got no positional, get the next counter */
|
/* we got no positional, get the next counter */
|
||||||
this_param = param_num;
|
this_param = param_num;
|
||||||
|
|
||||||
if (this_param > max_param)
|
if(this_param > max_param)
|
||||||
max_param = this_param;
|
max_param = this_param;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -340,7 +340,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
|
|
||||||
/* Handle the flags */
|
/* Handle the flags */
|
||||||
|
|
||||||
while (dprintf_IsQualifierNoDollar(*fmt)) {
|
while(dprintf_IsQualifierNoDollar(*fmt)) {
|
||||||
switch (*fmt++) {
|
switch (*fmt++) {
|
||||||
case ' ':
|
case ' ':
|
||||||
flags |= FLAGS_SPACE;
|
flags |= FLAGS_SPACE;
|
||||||
@@ -357,7 +357,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
flags |= FLAGS_PREC;
|
flags |= FLAGS_PREC;
|
||||||
if ('*' == *fmt) {
|
if('*' == *fmt) {
|
||||||
/* The precision is picked from a specified parameter */
|
/* The precision is picked from a specified parameter */
|
||||||
|
|
||||||
flags |= FLAGS_PRECPARAM;
|
flags |= FLAGS_PRECPARAM;
|
||||||
@@ -365,12 +365,12 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
param_num++;
|
param_num++;
|
||||||
|
|
||||||
i = dprintf_DollarString(fmt, &fmt);
|
i = dprintf_DollarString(fmt, &fmt);
|
||||||
if (i)
|
if(i)
|
||||||
precision = i;
|
precision = i;
|
||||||
else
|
else
|
||||||
precision = param_num;
|
precision = param_num;
|
||||||
|
|
||||||
if (precision > max_param)
|
if(precision > max_param)
|
||||||
max_param = precision;
|
max_param = precision;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -382,7 +382,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
flags |= FLAGS_SHORT;
|
flags |= FLAGS_SHORT;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (flags & FLAGS_LONG)
|
if(flags & FLAGS_LONG)
|
||||||
flags |= FLAGS_LONGLONG;
|
flags |= FLAGS_LONGLONG;
|
||||||
else
|
else
|
||||||
flags |= FLAGS_LONG;
|
flags |= FLAGS_LONG;
|
||||||
@@ -410,7 +410,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
if (!(flags & FLAGS_LEFT))
|
if(!(flags & FLAGS_LEFT))
|
||||||
flags |= FLAGS_PAD_NIL;
|
flags |= FLAGS_PAD_NIL;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case '1': case '2': case '3': case '4':
|
case '1': case '2': case '3': case '4':
|
||||||
@@ -503,7 +503,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
vto[i].width = width;
|
vto[i].width = width;
|
||||||
vto[i].precision = precision;
|
vto[i].precision = precision;
|
||||||
|
|
||||||
if (flags & FLAGS_WIDTHPARAM) {
|
if(flags & FLAGS_WIDTHPARAM) {
|
||||||
/* we have the width specified from a parameter, so we make that
|
/* we have the width specified from a parameter, so we make that
|
||||||
parameter's info setup properly */
|
parameter's info setup properly */
|
||||||
vto[i].width = width - 1;
|
vto[i].width = width - 1;
|
||||||
@@ -513,7 +513,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
vto[i].precision = vto[i].width = 0; /* can't use width or precision
|
vto[i].precision = vto[i].width = 0; /* can't use width or precision
|
||||||
of width! */
|
of width! */
|
||||||
}
|
}
|
||||||
if (flags & FLAGS_PRECPARAM) {
|
if(flags & FLAGS_PRECPARAM) {
|
||||||
/* we have the precision specified from a parameter, so we make that
|
/* we have the precision specified from a parameter, so we make that
|
||||||
parameter's info setup properly */
|
parameter's info setup properly */
|
||||||
vto[i].precision = precision - 1;
|
vto[i].precision = precision - 1;
|
||||||
@@ -533,7 +533,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||||||
|
|
||||||
/* Read the arg list parameters into our data list */
|
/* Read the arg list parameters into our data list */
|
||||||
for (i=0; i<max_param; i++) {
|
for (i=0; i<max_param; i++) {
|
||||||
if ((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
|
if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
|
||||||
{
|
{
|
||||||
/* Width/precision arguments must be read before the main argument
|
/* Width/precision arguments must be read before the main argument
|
||||||
* they are attached to
|
* they are attached to
|
||||||
@@ -620,7 +620,7 @@ static int dprintf_formatf(
|
|||||||
created for us */
|
created for us */
|
||||||
|
|
||||||
f = (char *)format;
|
f = (char *)format;
|
||||||
while (*f != '\0') {
|
while(*f != '\0') {
|
||||||
/* Format spec modifiers. */
|
/* Format spec modifiers. */
|
||||||
char alt;
|
char alt;
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ static int dprintf_formatf(
|
|||||||
#endif
|
#endif
|
||||||
long signed_num;
|
long signed_num;
|
||||||
|
|
||||||
if (*f != '%') {
|
if(*f != '%') {
|
||||||
/* This isn't a format spec, so write everything out until the next one
|
/* This isn't a format spec, so write everything out until the next one
|
||||||
OR end of string is reached. */
|
OR end of string is reached. */
|
||||||
do {
|
do {
|
||||||
@@ -659,7 +659,7 @@ static int dprintf_formatf(
|
|||||||
'%' as a conversion specifier, it says "The complete format
|
'%' as a conversion specifier, it says "The complete format
|
||||||
specification shall be `%%'," so we can avoid all the width
|
specification shall be `%%'," so we can avoid all the width
|
||||||
and precision processing. */
|
and precision processing. */
|
||||||
if (*f == '%') {
|
if(*f == '%') {
|
||||||
++f;
|
++f;
|
||||||
OUTCHAR('%');
|
OUTCHAR('%');
|
||||||
continue;
|
continue;
|
||||||
@@ -686,8 +686,11 @@ static int dprintf_formatf(
|
|||||||
width = p->width;
|
width = p->width;
|
||||||
|
|
||||||
/* pick up the specified precision */
|
/* pick up the specified precision */
|
||||||
if(p->flags & FLAGS_PRECPARAM)
|
if(p->flags & FLAGS_PRECPARAM) {
|
||||||
prec = vto[p->precision].data.num;
|
prec = vto[p->precision].data.num;
|
||||||
|
param_num++; /* since the precision is extraced from a parameter, we
|
||||||
|
must skip that to get to the next one properly */
|
||||||
|
}
|
||||||
else if(p->flags & FLAGS_PREC)
|
else if(p->flags & FLAGS_PREC)
|
||||||
prec = p->precision;
|
prec = p->precision;
|
||||||
else
|
else
|
||||||
@@ -700,12 +703,12 @@ static int dprintf_formatf(
|
|||||||
num = p->data.num;
|
num = p->data.num;
|
||||||
if(p->flags & FLAGS_CHAR) {
|
if(p->flags & FLAGS_CHAR) {
|
||||||
/* Character. */
|
/* Character. */
|
||||||
if (!(p->flags & FLAGS_LEFT))
|
if(!(p->flags & FLAGS_LEFT))
|
||||||
while (--width > 0)
|
while(--width > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
OUTCHAR((char) num);
|
OUTCHAR((char) num);
|
||||||
if (p->flags & FLAGS_LEFT)
|
if(p->flags & FLAGS_LEFT)
|
||||||
while (--width > 0)
|
while(--width > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -756,47 +759,47 @@ static int dprintf_formatf(
|
|||||||
char *w;
|
char *w;
|
||||||
|
|
||||||
/* Supply a default precision if none was given. */
|
/* Supply a default precision if none was given. */
|
||||||
if (prec == -1)
|
if(prec == -1)
|
||||||
prec = 1;
|
prec = 1;
|
||||||
|
|
||||||
/* Put the number in WORK. */
|
/* Put the number in WORK. */
|
||||||
w = workend;
|
w = workend;
|
||||||
while (num > 0) {
|
while(num > 0) {
|
||||||
*w-- = digits[num % base];
|
*w-- = digits[num % base];
|
||||||
num /= base;
|
num /= base;
|
||||||
}
|
}
|
||||||
width -= (long)(workend - w);
|
width -= (long)(workend - w);
|
||||||
prec -= (long)(workend - w);
|
prec -= (long)(workend - w);
|
||||||
|
|
||||||
if (alt && base == 8 && prec <= 0) {
|
if(alt && base == 8 && prec <= 0) {
|
||||||
*w-- = '0';
|
*w-- = '0';
|
||||||
--width;
|
--width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prec > 0) {
|
if(prec > 0) {
|
||||||
width -= prec;
|
width -= prec;
|
||||||
while (prec-- > 0)
|
while(prec-- > 0)
|
||||||
*w-- = '0';
|
*w-- = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alt && base == 16)
|
if(alt && base == 16)
|
||||||
width -= 2;
|
width -= 2;
|
||||||
|
|
||||||
if (is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
|
if(is_neg || (p->flags & FLAGS_SHOWSIGN) || (p->flags & FLAGS_SPACE))
|
||||||
--width;
|
--width;
|
||||||
|
|
||||||
if (!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
|
if(!(p->flags & FLAGS_LEFT) && !(p->flags & FLAGS_PAD_NIL))
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
|
|
||||||
if (is_neg)
|
if(is_neg)
|
||||||
OUTCHAR('-');
|
OUTCHAR('-');
|
||||||
else if (p->flags & FLAGS_SHOWSIGN)
|
else if(p->flags & FLAGS_SHOWSIGN)
|
||||||
OUTCHAR('+');
|
OUTCHAR('+');
|
||||||
else if (p->flags & FLAGS_SPACE)
|
else if(p->flags & FLAGS_SPACE)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
|
|
||||||
if (alt && base == 16) {
|
if(alt && base == 16) {
|
||||||
OUTCHAR('0');
|
OUTCHAR('0');
|
||||||
if(p->flags & FLAGS_UPPER)
|
if(p->flags & FLAGS_UPPER)
|
||||||
OUTCHAR('X');
|
OUTCHAR('X');
|
||||||
@@ -804,17 +807,17 @@ static int dprintf_formatf(
|
|||||||
OUTCHAR('x');
|
OUTCHAR('x');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
|
if(!(p->flags & FLAGS_LEFT) && (p->flags & FLAGS_PAD_NIL))
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR('0');
|
OUTCHAR('0');
|
||||||
|
|
||||||
/* Write the number. */
|
/* Write the number. */
|
||||||
while (++w <= workend) {
|
while(++w <= workend) {
|
||||||
OUTCHAR(*w);
|
OUTCHAR(*w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->flags & FLAGS_LEFT)
|
if(p->flags & FLAGS_LEFT)
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -827,9 +830,9 @@ static int dprintf_formatf(
|
|||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
str = (char *) p->data.str;
|
str = (char *) p->data.str;
|
||||||
if ( str == NULL) {
|
if( str == NULL) {
|
||||||
/* Write null[] if there's space. */
|
/* Write null[] if there's space. */
|
||||||
if (prec == -1 || prec >= (long) sizeof(null) - 1) {
|
if(prec == -1 || prec >= (long) sizeof(null) - 1) {
|
||||||
str = null;
|
str = null;
|
||||||
len = sizeof(null) - 1;
|
len = sizeof(null) - 1;
|
||||||
/* Disable quotes around (nil) */
|
/* Disable quotes around (nil) */
|
||||||
@@ -843,24 +846,24 @@ static int dprintf_formatf(
|
|||||||
else
|
else
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
if (prec != -1 && (size_t) prec < len)
|
if(prec != -1 && (size_t) prec < len)
|
||||||
len = prec;
|
len = prec;
|
||||||
width -= (long)len;
|
width -= (long)len;
|
||||||
|
|
||||||
if (p->flags & FLAGS_ALT)
|
if(p->flags & FLAGS_ALT)
|
||||||
OUTCHAR('"');
|
OUTCHAR('"');
|
||||||
|
|
||||||
if (!(p->flags&FLAGS_LEFT))
|
if(!(p->flags&FLAGS_LEFT))
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
|
|
||||||
while (len-- > 0)
|
while(len-- > 0)
|
||||||
OUTCHAR(*str++);
|
OUTCHAR(*str++);
|
||||||
if (p->flags&FLAGS_LEFT)
|
if(p->flags&FLAGS_LEFT)
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
|
|
||||||
if (p->flags & FLAGS_ALT)
|
if(p->flags & FLAGS_ALT)
|
||||||
OUTCHAR('"');
|
OUTCHAR('"');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -870,7 +873,7 @@ static int dprintf_formatf(
|
|||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
ptr = (void *) p->data.ptr;
|
ptr = (void *) p->data.ptr;
|
||||||
if (ptr != NULL) {
|
if(ptr != NULL) {
|
||||||
/* If the pointer is not NULL, write it as a %#x spec. */
|
/* If the pointer is not NULL, write it as a %#x spec. */
|
||||||
base = 16;
|
base = 16;
|
||||||
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
|
digits = (p->flags & FLAGS_UPPER)? upper_digits : lower_digits;
|
||||||
@@ -885,13 +888,13 @@ static int dprintf_formatf(
|
|||||||
const char *point;
|
const char *point;
|
||||||
|
|
||||||
width -= sizeof(strnil) - 1;
|
width -= sizeof(strnil) - 1;
|
||||||
if (p->flags & FLAGS_LEFT)
|
if(p->flags & FLAGS_LEFT)
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
for (point = strnil; *point != '\0'; ++point)
|
for (point = strnil; *point != '\0'; ++point)
|
||||||
OUTCHAR(*point);
|
OUTCHAR(*point);
|
||||||
if (! (p->flags & FLAGS_LEFT))
|
if(! (p->flags & FLAGS_LEFT))
|
||||||
while (width-- > 0)
|
while(width-- > 0)
|
||||||
OUTCHAR(' ');
|
OUTCHAR(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -905,24 +908,24 @@ static int dprintf_formatf(
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
width = -1;
|
width = -1;
|
||||||
if (p->flags & FLAGS_WIDTH)
|
if(p->flags & FLAGS_WIDTH)
|
||||||
width = p->width;
|
width = p->width;
|
||||||
else if (p->flags & FLAGS_WIDTHPARAM)
|
else if(p->flags & FLAGS_WIDTHPARAM)
|
||||||
width = vto[p->width].data.num;
|
width = vto[p->width].data.num;
|
||||||
|
|
||||||
prec = -1;
|
prec = -1;
|
||||||
if (p->flags & FLAGS_PREC)
|
if(p->flags & FLAGS_PREC)
|
||||||
prec = p->precision;
|
prec = p->precision;
|
||||||
else if (p->flags & FLAGS_PRECPARAM)
|
else if(p->flags & FLAGS_PRECPARAM)
|
||||||
prec = vto[p->precision].data.num;
|
prec = vto[p->precision].data.num;
|
||||||
|
|
||||||
if (p->flags & FLAGS_LEFT)
|
if(p->flags & FLAGS_LEFT)
|
||||||
strcat(formatbuf, "-");
|
strcat(formatbuf, "-");
|
||||||
if (p->flags & FLAGS_SHOWSIGN)
|
if(p->flags & FLAGS_SHOWSIGN)
|
||||||
strcat(formatbuf, "+");
|
strcat(formatbuf, "+");
|
||||||
if (p->flags & FLAGS_SPACE)
|
if(p->flags & FLAGS_SPACE)
|
||||||
strcat(formatbuf, " ");
|
strcat(formatbuf, " ");
|
||||||
if (p->flags & FLAGS_ALT)
|
if(p->flags & FLAGS_ALT)
|
||||||
strcat(formatbuf, "#");
|
strcat(formatbuf, "#");
|
||||||
|
|
||||||
fptr=&formatbuf[strlen(formatbuf)];
|
fptr=&formatbuf[strlen(formatbuf)];
|
||||||
@@ -939,12 +942,12 @@ static int dprintf_formatf(
|
|||||||
fptr += len;
|
fptr += len;
|
||||||
left -= len;
|
left -= len;
|
||||||
}
|
}
|
||||||
if (p->flags & FLAGS_LONG)
|
if(p->flags & FLAGS_LONG)
|
||||||
*fptr++ = 'l';
|
*fptr++ = 'l';
|
||||||
|
|
||||||
if (p->flags & FLAGS_FLOATE)
|
if(p->flags & FLAGS_FLOATE)
|
||||||
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
|
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'E':'e');
|
||||||
else if (p->flags & FLAGS_FLOATG)
|
else if(p->flags & FLAGS_FLOATG)
|
||||||
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
|
*fptr++ = (char)((p->flags & FLAGS_UPPER) ? 'G' : 'g');
|
||||||
else
|
else
|
||||||
*fptr++ = 'f';
|
*fptr++ = 'f';
|
||||||
@@ -963,13 +966,13 @@ static int dprintf_formatf(
|
|||||||
case FORMAT_INTPTR:
|
case FORMAT_INTPTR:
|
||||||
/* Answer the count of characters written. */
|
/* Answer the count of characters written. */
|
||||||
#ifdef ENABLE_64BIT
|
#ifdef ENABLE_64BIT
|
||||||
if (p->flags & FLAGS_LONGLONG)
|
if(p->flags & FLAGS_LONGLONG)
|
||||||
*(LONG_LONG *) p->data.ptr = (LONG_LONG)done;
|
*(LONG_LONG *) p->data.ptr = (LONG_LONG)done;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (p->flags & FLAGS_LONG)
|
if(p->flags & FLAGS_LONG)
|
||||||
*(long *) p->data.ptr = (long)done;
|
*(long *) p->data.ptr = (long)done;
|
||||||
else if (!(p->flags & FLAGS_SHORT))
|
else if(!(p->flags & FLAGS_SHORT))
|
||||||
*(int *) p->data.ptr = (int)done;
|
*(int *) p->data.ptr = (int)done;
|
||||||
else
|
else
|
||||||
*(short *) p->data.ptr = (short)done;
|
*(short *) p->data.ptr = (short)done;
|
||||||
|
|||||||
147
lib/multi.c
147
lib/multi.c
@@ -446,14 +446,14 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
|||||||
|
|
||||||
/* for multi interface connections, we share DNS cache automatically if the
|
/* for multi interface connections, we share DNS cache automatically if the
|
||||||
easy handle's one is currently private. */
|
easy handle's one is currently private. */
|
||||||
if (easy->easy_handle->dns.hostcache &&
|
if(easy->easy_handle->dns.hostcache &&
|
||||||
(easy->easy_handle->dns.hostcachetype == HCACHE_PRIVATE)) {
|
(easy->easy_handle->dns.hostcachetype == HCACHE_PRIVATE)) {
|
||||||
Curl_hash_destroy(easy->easy_handle->dns.hostcache);
|
Curl_hash_destroy(easy->easy_handle->dns.hostcache);
|
||||||
easy->easy_handle->dns.hostcache = NULL;
|
easy->easy_handle->dns.hostcache = NULL;
|
||||||
easy->easy_handle->dns.hostcachetype = HCACHE_NONE;
|
easy->easy_handle->dns.hostcachetype = HCACHE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!easy->easy_handle->dns.hostcache ||
|
if(!easy->easy_handle->dns.hostcache ||
|
||||||
(easy->easy_handle->dns.hostcachetype == HCACHE_NONE)) {
|
(easy->easy_handle->dns.hostcachetype == HCACHE_NONE)) {
|
||||||
easy->easy_handle->dns.hostcache = multi->hostcache;
|
easy->easy_handle->dns.hostcache = multi->hostcache;
|
||||||
easy->easy_handle->dns.hostcachetype = HCACHE_MULTI;
|
easy->easy_handle->dns.hostcachetype = HCACHE_MULTI;
|
||||||
@@ -578,7 +578,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
|||||||
alive connections when this is removed */
|
alive connections when this is removed */
|
||||||
multi->num_alive--;
|
multi->num_alive--;
|
||||||
|
|
||||||
if (easy->easy_handle->state.is_in_pipeline &&
|
if(easy->easy_handle->state.is_in_pipeline &&
|
||||||
easy->state > CURLM_STATE_DO &&
|
easy->state > CURLM_STATE_DO &&
|
||||||
easy->state < CURLM_STATE_COMPLETED) {
|
easy->state < CURLM_STATE_COMPLETED) {
|
||||||
/* If the handle is in a pipeline and has finished sending off its
|
/* If the handle is in a pipeline and has finished sending off its
|
||||||
@@ -679,7 +679,7 @@ CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
|||||||
|
|
||||||
/* NOTE NOTE NOTE
|
/* NOTE NOTE NOTE
|
||||||
We do not touch the easy handle here! */
|
We do not touch the easy handle here! */
|
||||||
if (easy->msg)
|
if(easy->msg)
|
||||||
free(easy->msg);
|
free(easy->msg);
|
||||||
free(easy);
|
free(easy);
|
||||||
|
|
||||||
@@ -701,7 +701,7 @@ void Curl_multi_handlePipeBreak(struct SessionHandle *data)
|
|||||||
{
|
{
|
||||||
struct Curl_one_easy *one_easy = data->set.one_easy;
|
struct Curl_one_easy *one_easy = data->set.one_easy;
|
||||||
|
|
||||||
if (one_easy)
|
if(one_easy)
|
||||||
one_easy->easy_conn = NULL;
|
one_easy->easy_conn = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,12 +745,12 @@ static int multi_getsock(struct Curl_one_easy *easy,
|
|||||||
singlesocket() => multi_getsock().
|
singlesocket() => multi_getsock().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (easy->easy_handle->state.pipe_broke ||
|
if(easy->easy_handle->state.pipe_broke ||
|
||||||
!easy->easy_conn) {
|
!easy->easy_conn) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (easy->state > CURLM_STATE_CONNECT &&
|
if(easy->state > CURLM_STATE_CONNECT &&
|
||||||
easy->state < CURLM_STATE_COMPLETED) {
|
easy->state < CURLM_STATE_COMPLETED) {
|
||||||
/* Set up ownership correctly */
|
/* Set up ownership correctly */
|
||||||
easy->easy_conn->data = easy->easy_handle;
|
easy->easy_conn->data = easy->easy_handle;
|
||||||
@@ -855,7 +855,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
|
|
||||||
/* Handle the case when the pipe breaks, i.e., the connection
|
/* Handle the case when the pipe breaks, i.e., the connection
|
||||||
we're using gets cleaned up and we're left with nothing. */
|
we're using gets cleaned up and we're left with nothing. */
|
||||||
if (easy->easy_handle->state.pipe_broke) {
|
if(easy->easy_handle->state.pipe_broke) {
|
||||||
infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n",
|
infof(easy->easy_handle, "Pipe broke: handle 0x%x, url = %s\n",
|
||||||
easy, easy->easy_handle->reqdata.path);
|
easy, easy->easy_handle->reqdata.path);
|
||||||
|
|
||||||
@@ -875,13 +875,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (easy->state > CURLM_STATE_CONNECT &&
|
if(easy->state > CURLM_STATE_CONNECT &&
|
||||||
easy->state < CURLM_STATE_COMPLETED) {
|
easy->state < CURLM_STATE_COMPLETED) {
|
||||||
/* Make sure we set the connection's current owner */
|
/* Make sure we set the connection's current owner */
|
||||||
easy->easy_conn->data = easy->easy_handle;
|
easy->easy_conn->data = easy->easy_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CURLM_STATE_WAITCONNECT <= easy->state &&
|
if(CURLM_STATE_WAITCONNECT <= easy->state &&
|
||||||
easy->state <= CURLM_STATE_DO &&
|
easy->state <= CURLM_STATE_DO &&
|
||||||
easy->easy_handle->change.url_changed) {
|
easy->easy_handle->change.url_changed) {
|
||||||
char *gotourl;
|
char *gotourl;
|
||||||
@@ -935,28 +935,28 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
/* Add this handle to the send pipeline */
|
/* Add this handle to the send pipeline */
|
||||||
easy->result = Curl_addHandleToPipeline(easy->easy_handle,
|
easy->result = Curl_addHandleToPipeline(easy->easy_handle,
|
||||||
easy->easy_conn->send_pipe);
|
easy->easy_conn->send_pipe);
|
||||||
if(CURLE_OK == easy->result) {
|
if(CURLE_OK == easy->result) {
|
||||||
if(async)
|
if(async)
|
||||||
/* We're now waiting for an asynchronous name lookup */
|
/* We're now waiting for an asynchronous name lookup */
|
||||||
multistate(easy, CURLM_STATE_WAITRESOLVE);
|
multistate(easy, CURLM_STATE_WAITRESOLVE);
|
||||||
else {
|
else {
|
||||||
/* after the connect has been sent off, go WAITCONNECT unless the
|
/* after the connect has been sent off, go WAITCONNECT unless the
|
||||||
protocol connect is already done and we can go directly to
|
protocol connect is already done and we can go directly to
|
||||||
WAITDO! */
|
WAITDO! */
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
|
|
||||||
if(protocol_connect)
|
if(protocol_connect)
|
||||||
multistate(easy, CURLM_STATE_WAITDO);
|
multistate(easy, CURLM_STATE_WAITDO);
|
||||||
else {
|
else {
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if (easy->easy_conn->bits.tunnel_connecting)
|
if(easy->easy_conn->bits.tunnel_connecting)
|
||||||
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
multistate(easy, CURLM_STATE_WAITCONNECT);
|
multistate(easy, CURLM_STATE_WAITCONNECT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -985,7 +985,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
multistate(easy, CURLM_STATE_WAITDO);
|
multistate(easy, CURLM_STATE_WAITDO);
|
||||||
else {
|
else {
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if (easy->easy_conn->bits.tunnel_connecting)
|
if(easy->easy_conn->bits.tunnel_connecting)
|
||||||
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -1008,7 +1008,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
easy->result = Curl_http_connect(easy->easy_conn, &protocol_connect);
|
easy->result = Curl_http_connect(easy->easy_conn, &protocol_connect);
|
||||||
|
|
||||||
if(CURLE_OK == easy->result) {
|
if(CURLE_OK == easy->result) {
|
||||||
if (!easy->easy_conn->bits.tunnel_connecting)
|
if(!easy->easy_conn->bits.tunnel_connecting)
|
||||||
multistate(easy, CURLM_STATE_WAITCONNECT);
|
multistate(easy, CURLM_STATE_WAITCONNECT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1038,7 +1038,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
BUT if we are using a proxy we must change to WAITPROXYCONNECT
|
BUT if we are using a proxy we must change to WAITPROXYCONNECT
|
||||||
*/
|
*/
|
||||||
#ifndef CURL_DISABLE_HTTP
|
#ifndef CURL_DISABLE_HTTP
|
||||||
if (easy->easy_conn->bits.tunnel_connecting)
|
if(easy->easy_conn->bits.tunnel_connecting)
|
||||||
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
multistate(easy, CURLM_STATE_WAITPROXYCONNECT);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -1057,7 +1057,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
/* protocol-specific connect phase */
|
/* protocol-specific connect phase */
|
||||||
easy->result = Curl_protocol_connecting(easy->easy_conn,
|
easy->result = Curl_protocol_connecting(easy->easy_conn,
|
||||||
&protocol_connect);
|
&protocol_connect);
|
||||||
if(protocol_connect) {
|
if((easy->result == CURLE_OK) && protocol_connect) {
|
||||||
/* after the connect has completed, go WAITDO */
|
/* after the connect has completed, go WAITDO */
|
||||||
multistate(easy, CURLM_STATE_WAITDO);
|
multistate(easy, CURLM_STATE_WAITDO);
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
@@ -1080,7 +1080,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
Curl_isHandleAtHead(easy->easy_handle,
|
Curl_isHandleAtHead(easy->easy_handle,
|
||||||
easy->easy_conn->send_pipe));
|
easy->easy_conn->send_pipe));
|
||||||
#endif
|
#endif
|
||||||
if (!easy->easy_conn->writechannel_inuse &&
|
if(!easy->easy_conn->writechannel_inuse &&
|
||||||
Curl_isHandleAtHead(easy->easy_handle,
|
Curl_isHandleAtHead(easy->easy_handle,
|
||||||
easy->easy_conn->send_pipe)) {
|
easy->easy_conn->send_pipe)) {
|
||||||
/* Grab the channel */
|
/* Grab the channel */
|
||||||
@@ -1121,11 +1121,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* we're done with the DO, now DO_DONE */
|
/* we're done with the DO, now DO_DONE */
|
||||||
easy->result = Curl_readwrite_init(easy->easy_conn);
|
multistate(easy, CURLM_STATE_DO_DONE);
|
||||||
if(CURLE_OK == easy->result) {
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
multistate(easy, CURLM_STATE_DO_DONE);
|
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1152,11 +1149,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* we're done with the DO, now DO_DONE */
|
/* we're done with the DO, now DO_DONE */
|
||||||
easy->result = Curl_readwrite_init(easy->easy_conn);
|
multistate(easy, CURLM_STATE_DO_DONE);
|
||||||
if(CURLE_OK == easy->result) {
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
multistate(easy, CURLM_STATE_DO_DONE);
|
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} /* dophase_done */
|
} /* dophase_done */
|
||||||
}
|
}
|
||||||
@@ -1179,17 +1173,19 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
*/
|
*/
|
||||||
easy->result = Curl_do_more(easy->easy_conn);
|
easy->result = Curl_do_more(easy->easy_conn);
|
||||||
|
|
||||||
if(CURLE_OK == easy->result)
|
/* No need to remove ourselves from the send pipeline here since that
|
||||||
easy->result = Curl_readwrite_init(easy->easy_conn);
|
is done for us in Curl_done() */
|
||||||
else
|
|
||||||
/* Remove ourselves from the send pipeline */
|
|
||||||
Curl_removeHandleFromPipeline(easy->easy_handle,
|
|
||||||
easy->easy_conn->send_pipe);
|
|
||||||
|
|
||||||
if(CURLE_OK == easy->result) {
|
if(CURLE_OK == easy->result) {
|
||||||
multistate(easy, CURLM_STATE_DO_DONE);
|
multistate(easy, CURLM_STATE_DO_DONE);
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* failure detected */
|
||||||
|
Curl_posttransfer(easy->easy_handle);
|
||||||
|
Curl_done(&easy->easy_conn, easy->result, FALSE);
|
||||||
|
disconnect_conn = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1202,9 +1198,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
easy->easy_conn->recv_pipe);
|
easy->easy_conn->recv_pipe);
|
||||||
multistate(easy, CURLM_STATE_WAITPERFORM);
|
multistate(easy, CURLM_STATE_WAITPERFORM);
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
|
|
||||||
Curl_pre_readwrite(easy->easy_conn);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLM_STATE_WAITPERFORM:
|
case CURLM_STATE_WAITPERFORM:
|
||||||
@@ -1217,7 +1210,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
easy->easy_conn->recv_pipe));
|
easy->easy_conn->recv_pipe));
|
||||||
#endif
|
#endif
|
||||||
/* Wait for our turn to PERFORM */
|
/* Wait for our turn to PERFORM */
|
||||||
if (!easy->easy_conn->readchannel_inuse &&
|
if(!easy->easy_conn->readchannel_inuse &&
|
||||||
Curl_isHandleAtHead(easy->easy_handle,
|
Curl_isHandleAtHead(easy->easy_handle,
|
||||||
easy->easy_conn->recv_pipe)) {
|
easy->easy_conn->recv_pipe)) {
|
||||||
/* Grab the channel */
|
/* Grab the channel */
|
||||||
@@ -1230,7 +1223,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
|
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
|
||||||
/* if both rates are within spec, resume transfer */
|
/* if both rates are within spec, resume transfer */
|
||||||
Curl_pgrsUpdate(easy->easy_conn);
|
Curl_pgrsUpdate(easy->easy_conn);
|
||||||
if ( ( ( easy->easy_handle->set.max_send_speed == 0 ) ||
|
if( ( ( easy->easy_handle->set.max_send_speed == 0 ) ||
|
||||||
( easy->easy_handle->progress.ulspeed <
|
( easy->easy_handle->progress.ulspeed <
|
||||||
easy->easy_handle->set.max_send_speed ) ) &&
|
easy->easy_handle->set.max_send_speed ) ) &&
|
||||||
( ( easy->easy_handle->set.max_recv_speed == 0 ) ||
|
( ( easy->easy_handle->set.max_recv_speed == 0 ) ||
|
||||||
@@ -1242,7 +1235,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
|
|
||||||
case CURLM_STATE_PERFORM:
|
case CURLM_STATE_PERFORM:
|
||||||
/* check if over speed */
|
/* check if over speed */
|
||||||
if ( ( ( easy->easy_handle->set.max_send_speed > 0 ) &&
|
if( ( ( easy->easy_handle->set.max_send_speed > 0 ) &&
|
||||||
( easy->easy_handle->progress.ulspeed >
|
( easy->easy_handle->progress.ulspeed >
|
||||||
easy->easy_handle->set.max_send_speed ) ) ||
|
easy->easy_handle->set.max_send_speed ) ) ||
|
||||||
( ( easy->easy_handle->set.max_recv_speed > 0 ) &&
|
( ( easy->easy_handle->set.max_recv_speed > 0 ) &&
|
||||||
@@ -1261,12 +1254,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
|
|
||||||
k = &easy->easy_handle->reqdata.keep;
|
k = &easy->easy_handle->reqdata.keep;
|
||||||
|
|
||||||
if (!(k->keepon & KEEP_READ)) {
|
if(!(k->keepon & KEEP_READ)) {
|
||||||
/* We're done reading */
|
/* We're done reading */
|
||||||
easy->easy_conn->readchannel_inuse = FALSE;
|
easy->easy_conn->readchannel_inuse = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(k->keepon & KEEP_WRITE)) {
|
if(!(k->keepon & KEEP_WRITE)) {
|
||||||
/* We're done writing */
|
/* We're done writing */
|
||||||
easy->easy_conn->writechannel_inuse = FALSE;
|
easy->easy_conn->writechannel_inuse = FALSE;
|
||||||
}
|
}
|
||||||
@@ -1332,14 +1325,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
easy->easy_conn->recv_pipe);
|
easy->easy_conn->recv_pipe);
|
||||||
easy->easy_handle->state.is_in_pipeline = FALSE;
|
easy->easy_handle->state.is_in_pipeline = FALSE;
|
||||||
|
|
||||||
if (easy->easy_conn->bits.stream_was_rewound) {
|
if(easy->easy_conn->bits.stream_was_rewound) {
|
||||||
/* This request read past its response boundary so we quickly
|
/* This request read past its response boundary so we quickly
|
||||||
let the other requests consume those bytes since there is no
|
let the other requests consume those bytes since there is no
|
||||||
guarantee that the socket will become active again */
|
guarantee that the socket will become active again */
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!easy->easy_handle->state.cancelled) {
|
if(!easy->easy_handle->state.cancelled) {
|
||||||
/* post-transfer command */
|
/* post-transfer command */
|
||||||
easy->result = Curl_done(&easy->easy_conn, CURLE_OK, FALSE);
|
easy->result = Curl_done(&easy->easy_conn, CURLE_OK, FALSE);
|
||||||
|
|
||||||
@@ -1351,7 +1344,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLM_STATE_COMPLETED:
|
case CURLM_STATE_COMPLETED:
|
||||||
if (easy->easy_handle->state.cancelled)
|
if(easy->easy_handle->state.cancelled)
|
||||||
/* Go into the CANCELLED state if we were cancelled */
|
/* Go into the CANCELLED state if we were cancelled */
|
||||||
multistate(easy, CURLM_STATE_CANCELLED);
|
multistate(easy, CURLM_STATE_CANCELLED);
|
||||||
|
|
||||||
@@ -1399,7 +1392,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
easy->easy_conn->recv_pipe);
|
easy->easy_conn->recv_pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disconnect_conn) {
|
if(disconnect_conn) {
|
||||||
Curl_disconnect(easy->easy_conn); /* disconnect properly */
|
Curl_disconnect(easy->easy_conn); /* disconnect properly */
|
||||||
|
|
||||||
/* This is where we make sure that the easy_conn pointer is reset.
|
/* This is where we make sure that the easy_conn pointer is reset.
|
||||||
@@ -1412,9 +1405,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (easy->easy_handle->change.url_changed);
|
} while(easy->easy_handle->change.url_changed);
|
||||||
|
|
||||||
if ((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
|
if((CURLM_STATE_COMPLETED == easy->state) && !easy->msg) {
|
||||||
if(easy->easy_handle->dns.hostcachetype == HCACHE_MULTI) {
|
if(easy->easy_handle->dns.hostcachetype == HCACHE_MULTI) {
|
||||||
/* clear out the usage of the shared DNS cache */
|
/* clear out the usage of the shared DNS cache */
|
||||||
easy->easy_handle->dns.hostcache = NULL;
|
easy->easy_handle->dns.hostcache = NULL;
|
||||||
@@ -1467,7 +1460,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||||||
while(easy != &multi->easy) {
|
while(easy != &multi->easy) {
|
||||||
CURLMcode result;
|
CURLMcode result;
|
||||||
|
|
||||||
if (easy->easy_handle->state.cancelled &&
|
if(easy->easy_handle->state.cancelled &&
|
||||||
easy->state == CURLM_STATE_CANCELLED) {
|
easy->state == CURLM_STATE_CANCELLED) {
|
||||||
/* Remove cancelled handles once it's safe to do so */
|
/* Remove cancelled handles once it's safe to do so */
|
||||||
Curl_multi_rmeasy(multi_handle, easy->easy_handle);
|
Curl_multi_rmeasy(multi_handle, easy->easy_handle);
|
||||||
@@ -1493,7 +1486,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||||||
int key = now.tv_sec; /* drop the usec part */
|
int key = now.tv_sec; /* drop the usec part */
|
||||||
|
|
||||||
multi->timetree = Curl_splaygetbest(key, multi->timetree, &t);
|
multi->timetree = Curl_splaygetbest(key, multi->timetree, &t);
|
||||||
if (t) {
|
if(t) {
|
||||||
struct SessionHandle *d = t->payload;
|
struct SessionHandle *d = t->payload;
|
||||||
struct timeval* tv = &d->state.expiretime;
|
struct timeval* tv = &d->state.expiretime;
|
||||||
|
|
||||||
@@ -1507,7 +1500,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
|
|||||||
|
|
||||||
*running_handles = multi->num_alive;
|
*running_handles = multi->num_alive;
|
||||||
|
|
||||||
if ( CURLM_OK >= returncode )
|
if( CURLM_OK >= returncode )
|
||||||
update_timer(multi);
|
update_timer(multi);
|
||||||
return returncode;
|
return returncode;
|
||||||
}
|
}
|
||||||
@@ -1573,7 +1566,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
|
|||||||
|
|
||||||
Curl_easy_addmulti(easy->easy_handle, NULL); /* clear the association */
|
Curl_easy_addmulti(easy->easy_handle, NULL); /* clear the association */
|
||||||
|
|
||||||
if (easy->msg)
|
if(easy->msg)
|
||||||
free(easy->msg);
|
free(easy->msg);
|
||||||
free(easy);
|
free(easy);
|
||||||
easy = nexteasy;
|
easy = nexteasy;
|
||||||
@@ -1748,7 +1741,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
|
|||||||
/* or should we fall-through and do the timer-based stuff? */
|
/* or should we fall-through and do the timer-based stuff? */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (s != CURL_SOCKET_TIMEOUT) {
|
else if(s != CURL_SOCKET_TIMEOUT) {
|
||||||
|
|
||||||
struct Curl_sh_entry *entry =
|
struct Curl_sh_entry *entry =
|
||||||
Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s));
|
Curl_hash_pick(multi->sockhash, (char *)&s, sizeof(s));
|
||||||
@@ -1763,12 +1756,12 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
|
|||||||
/* bad bad bad bad bad bad bad */
|
/* bad bad bad bad bad bad bad */
|
||||||
return CURLM_INTERNAL_ERROR;
|
return CURLM_INTERNAL_ERROR;
|
||||||
|
|
||||||
if (data->set.one_easy->easy_conn) /* set socket event bitmask */
|
if(data->set.one_easy->easy_conn) /* set socket event bitmask */
|
||||||
data->set.one_easy->easy_conn->cselect_bits = ev_bitmask;
|
data->set.one_easy->easy_conn->cselect_bits = ev_bitmask;
|
||||||
|
|
||||||
result = multi_runsingle(multi, data->set.one_easy);
|
result = multi_runsingle(multi, data->set.one_easy);
|
||||||
|
|
||||||
if (data->set.one_easy->easy_conn)
|
if(data->set.one_easy->easy_conn)
|
||||||
data->set.one_easy->easy_conn->cselect_bits = 0;
|
data->set.one_easy->easy_conn->cselect_bits = 0;
|
||||||
|
|
||||||
if(CURLM_OK >= result)
|
if(CURLM_OK >= result)
|
||||||
@@ -1873,7 +1866,7 @@ CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
|||||||
{
|
{
|
||||||
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
|
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
|
||||||
0, running_handles);
|
0, running_handles);
|
||||||
if (CURLM_OK >= result)
|
if(CURLM_OK >= result)
|
||||||
update_timer((struct Curl_multi *)multi_handle);
|
update_timer((struct Curl_multi *)multi_handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1883,7 +1876,7 @@ CURLMcode curl_multi_socket_action(CURLM *multi_handle, curl_socket_t s,
|
|||||||
{
|
{
|
||||||
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
|
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle, FALSE, s,
|
||||||
ev_bitmask, running_handles);
|
ev_bitmask, running_handles);
|
||||||
if (CURLM_OK >= result)
|
if(CURLM_OK >= result)
|
||||||
update_timer((struct Curl_multi *)multi_handle);
|
update_timer((struct Curl_multi *)multi_handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1893,7 +1886,7 @@ CURLMcode curl_multi_socket_all(CURLM *multi_handle, int *running_handles)
|
|||||||
{
|
{
|
||||||
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle,
|
CURLMcode result = multi_socket((struct Curl_multi *)multi_handle,
|
||||||
TRUE, CURL_SOCKET_BAD, 0, running_handles);
|
TRUE, CURL_SOCKET_BAD, 0, running_handles);
|
||||||
if (CURLM_OK >= result)
|
if(CURLM_OK >= result)
|
||||||
update_timer((struct Curl_multi *)multi_handle);
|
update_timer((struct Curl_multi *)multi_handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1940,11 +1933,11 @@ CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
|||||||
static int update_timer(struct Curl_multi *multi)
|
static int update_timer(struct Curl_multi *multi)
|
||||||
{
|
{
|
||||||
long timeout_ms;
|
long timeout_ms;
|
||||||
if (!multi->timer_cb)
|
if(!multi->timer_cb)
|
||||||
return 0;
|
return 0;
|
||||||
if ( multi_timeout(multi, &timeout_ms) != CURLM_OK )
|
if( multi_timeout(multi, &timeout_ms) != CURLM_OK )
|
||||||
return -1;
|
return -1;
|
||||||
if ( timeout_ms < 0 )
|
if( timeout_ms < 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* When multi_timeout() is done, multi->timetree points to the node with the
|
/* When multi_timeout() is done, multi->timetree points to the node with the
|
||||||
|
|||||||
12
lib/netrc.c
12
lib/netrc.c
@@ -99,7 +99,7 @@ int Curl_parsenetrc(char *host,
|
|||||||
|
|
||||||
char *override = curl_getenv("CURL_DEBUG_NETRC");
|
char *override = curl_getenv("CURL_DEBUG_NETRC");
|
||||||
|
|
||||||
if (override) {
|
if(override) {
|
||||||
fprintf(stderr, "NETRC: overridden " NETRC " file: %s\n", override);
|
fprintf(stderr, "NETRC: overridden " NETRC " file: %s\n", override);
|
||||||
netrcfile = override;
|
netrcfile = override;
|
||||||
netrc_alloc = TRUE;
|
netrc_alloc = TRUE;
|
||||||
@@ -115,7 +115,7 @@ int Curl_parsenetrc(char *host,
|
|||||||
else {
|
else {
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
pw= getpwuid(geteuid());
|
pw= getpwuid(geteuid());
|
||||||
if (pw) {
|
if(pw) {
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
home = decc$translate_vms(pw->pw_dir);
|
home = decc$translate_vms(pw->pw_dir);
|
||||||
#else
|
#else
|
||||||
@@ -148,7 +148,7 @@ int Curl_parsenetrc(char *host,
|
|||||||
tok=strtok_r(netrcbuffer, " \t\n", &tok_buf);
|
tok=strtok_r(netrcbuffer, " \t\n", &tok_buf);
|
||||||
while(!done && tok) {
|
while(!done && tok) {
|
||||||
|
|
||||||
if (login[0] && password[0]) {
|
if(login[0] && password[0]) {
|
||||||
done=TRUE;
|
done=TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ int Curl_parsenetrc(char *host,
|
|||||||
case HOSTVALID:
|
case HOSTVALID:
|
||||||
/* we are now parsing sub-keywords concerning "our" host */
|
/* we are now parsing sub-keywords concerning "our" host */
|
||||||
if(state_login) {
|
if(state_login) {
|
||||||
if (specific_login) {
|
if(specific_login) {
|
||||||
state_our_login = strequal(login, tok);
|
state_our_login = strequal(login, tok);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -191,7 +191,7 @@ int Curl_parsenetrc(char *host,
|
|||||||
state_login=0;
|
state_login=0;
|
||||||
}
|
}
|
||||||
else if(state_password) {
|
else if(state_password) {
|
||||||
if (state_our_login || !specific_login) {
|
if(state_our_login || !specific_login) {
|
||||||
strncpy(password, tok, PASSWORDSIZE-1);
|
strncpy(password, tok, PASSWORDSIZE-1);
|
||||||
#ifdef _NETRC_DEBUG
|
#ifdef _NETRC_DEBUG
|
||||||
fprintf(stderr, "PASSWORD: %s\n", password);
|
fprintf(stderr, "PASSWORD: %s\n", password);
|
||||||
@@ -212,7 +212,7 @@ int Curl_parsenetrc(char *host,
|
|||||||
} /* switch (state) */
|
} /* switch (state) */
|
||||||
|
|
||||||
tok = strtok_r(NULL, " \t\n", &tok_buf);
|
tok = strtok_r(NULL, " \t\n", &tok_buf);
|
||||||
} /* while (tok) */
|
} /* while(tok) */
|
||||||
} /* while fgets() */
|
} /* while fgets() */
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|||||||
68
lib/nss.c
68
lib/nss.c
@@ -283,7 +283,7 @@ nss_load_cert(const char *filename, PRBool cacert)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* A nickname from the NSS internal database */
|
/* A nickname from the NSS internal database */
|
||||||
if (cacert)
|
if(cacert)
|
||||||
return 0; /* You can't specify an NSS CA nickname this way */
|
return 0; /* You can't specify an NSS CA nickname this way */
|
||||||
nickname = strdup(filename);
|
nickname = strdup(filename);
|
||||||
goto done;
|
goto done;
|
||||||
@@ -296,7 +296,7 @@ nss_load_cert(const char *filename, PRBool cacert)
|
|||||||
* for storing certificates. With each new user certificate we increment
|
* for storing certificates. With each new user certificate we increment
|
||||||
* the slot count. We only support 1 user certificate right now.
|
* the slot count. We only support 1 user certificate right now.
|
||||||
*/
|
*/
|
||||||
if (cacert)
|
if(cacert)
|
||||||
slotID = 0;
|
slotID = 0;
|
||||||
else
|
else
|
||||||
slotID = 1;
|
slotID = 1;
|
||||||
@@ -308,7 +308,7 @@ nss_load_cert(const char *filename, PRBool cacert)
|
|||||||
|
|
||||||
slot = PK11_FindSlotByName(slotname);
|
slot = PK11_FindSlotByName(slotname);
|
||||||
|
|
||||||
if (!slot) {
|
if(!slot) {
|
||||||
free(slotname);
|
free(slotname);
|
||||||
free(nickname);
|
free(nickname);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -318,7 +318,7 @@ nss_load_cert(const char *filename, PRBool cacert)
|
|||||||
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
|
PK11_SETATTRS(attrs, CKA_TOKEN, &cktrue, sizeof(CK_BBOOL) ); attrs++;
|
||||||
PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename,
|
PK11_SETATTRS(attrs, CKA_LABEL, (unsigned char *)filename,
|
||||||
strlen(filename)+1); attrs++;
|
strlen(filename)+1); attrs++;
|
||||||
if (cacert) {
|
if(cacert) {
|
||||||
PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) ); attrs++;
|
PK11_SETATTRS(attrs, CKA_TRUST, &cktrue, sizeof(CK_BBOOL) ); attrs++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -348,11 +348,11 @@ done:
|
|||||||
/* Double-check that the certificate or nickname requested exists in
|
/* Double-check that the certificate or nickname requested exists in
|
||||||
* either the token or the NSS certificate database.
|
* either the token or the NSS certificate database.
|
||||||
*/
|
*/
|
||||||
if (!cacert) {
|
if(!cacert) {
|
||||||
cert = PK11_FindCertFromNickname((char *)nickname, NULL);
|
cert = PK11_FindCertFromNickname((char *)nickname, NULL);
|
||||||
|
|
||||||
/* An invalid nickname was passed in */
|
/* An invalid nickname was passed in */
|
||||||
if (cert == NULL) {
|
if(cert == NULL) {
|
||||||
free(nickname);
|
free(nickname);
|
||||||
PR_SetError(SEC_ERROR_UNKNOWN_CERT, 0);
|
PR_SetError(SEC_ERROR_UNKNOWN_CERT, 0);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -533,7 +533,7 @@ static SECStatus nss_Init_Tokens(struct connectdata * conn)
|
|||||||
|
|
||||||
ret = PK11_Authenticate(slot, PR_TRUE, parg);
|
ret = PK11_Authenticate(slot, PR_TRUE, parg);
|
||||||
if(SECSuccess != ret) {
|
if(SECSuccess != ret) {
|
||||||
if (PR_GetError() == SEC_ERROR_BAD_PASSWORD)
|
if(PR_GetError() == SEC_ERROR_BAD_PASSWORD)
|
||||||
infof(conn->data, "The password for token '%s' is incorrect\n",
|
infof(conn->data, "The password for token '%s' is incorrect\n",
|
||||||
PK11_GetTokenName(slot));
|
PK11_GetTokenName(slot));
|
||||||
status = SECFailure;
|
status = SECFailure;
|
||||||
@@ -556,7 +556,7 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
|
|||||||
CERTCertificate *cert = NULL;
|
CERTCertificate *cert = NULL;
|
||||||
char *subject, *issuer;
|
char *subject, *issuer;
|
||||||
|
|
||||||
if (conn->data->set.ssl.certverifyresult!=0)
|
if(conn->data->set.ssl.certverifyresult!=0)
|
||||||
return success;
|
return success;
|
||||||
|
|
||||||
conn->data->set.ssl.certverifyresult=err;
|
conn->data->set.ssl.certverifyresult=err;
|
||||||
@@ -568,34 +568,34 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
|
|||||||
switch(err) {
|
switch(err) {
|
||||||
case SEC_ERROR_CA_CERT_INVALID:
|
case SEC_ERROR_CA_CERT_INVALID:
|
||||||
infof(conn->data, "Issuer certificate is invalid: '%s'\n", issuer);
|
infof(conn->data, "Issuer certificate is invalid: '%s'\n", issuer);
|
||||||
if (conn->data->set.ssl.verifypeer)
|
if(conn->data->set.ssl.verifypeer)
|
||||||
success = SECFailure;
|
success = SECFailure;
|
||||||
break;
|
break;
|
||||||
case SEC_ERROR_UNTRUSTED_ISSUER:
|
case SEC_ERROR_UNTRUSTED_ISSUER:
|
||||||
if (conn->data->set.ssl.verifypeer)
|
if(conn->data->set.ssl.verifypeer)
|
||||||
success = SECFailure;
|
success = SECFailure;
|
||||||
infof(conn->data, "Certificate is signed by an untrusted issuer: '%s'\n",
|
infof(conn->data, "Certificate is signed by an untrusted issuer: '%s'\n",
|
||||||
issuer);
|
issuer);
|
||||||
break;
|
break;
|
||||||
case SSL_ERROR_BAD_CERT_DOMAIN:
|
case SSL_ERROR_BAD_CERT_DOMAIN:
|
||||||
if (conn->data->set.ssl.verifypeer)
|
if(conn->data->set.ssl.verifypeer)
|
||||||
success = SECFailure;
|
success = SECFailure;
|
||||||
infof(conn->data, "common name: %s (does not match '%s')\n",
|
infof(conn->data, "common name: %s (does not match '%s')\n",
|
||||||
subject, conn->host.dispname);
|
subject, conn->host.dispname);
|
||||||
break;
|
break;
|
||||||
case SEC_ERROR_EXPIRED_CERTIFICATE:
|
case SEC_ERROR_EXPIRED_CERTIFICATE:
|
||||||
if (conn->data->set.ssl.verifypeer)
|
if(conn->data->set.ssl.verifypeer)
|
||||||
success = SECFailure;
|
success = SECFailure;
|
||||||
infof(conn->data, "Remote Certificate has expired.\n");
|
infof(conn->data, "Remote Certificate has expired.\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (conn->data->set.ssl.verifypeer)
|
if(conn->data->set.ssl.verifypeer)
|
||||||
success = SECFailure;
|
success = SECFailure;
|
||||||
infof(conn->data, "Bad certificate received. Subject = '%s', "
|
infof(conn->data, "Bad certificate received. Subject = '%s', "
|
||||||
"Issuer = '%s'\n", subject, issuer);
|
"Issuer = '%s'\n", subject, issuer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (success == SECSuccess)
|
if(success == SECSuccess)
|
||||||
infof(conn->data, "SSL certificate verify ok.\n");
|
infof(conn->data, "SSL certificate verify ok.\n");
|
||||||
PR_Free(subject);
|
PR_Free(subject);
|
||||||
PR_Free(issuer);
|
PR_Free(issuer);
|
||||||
@@ -623,10 +623,10 @@ static void display_conn_info(struct connectdata *conn, PRFileDesc *sock)
|
|||||||
char timeString[256];
|
char timeString[256];
|
||||||
PRTime notBefore, notAfter;
|
PRTime notBefore, notAfter;
|
||||||
|
|
||||||
if (SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
|
if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
|
||||||
SECSuccess && channel.length == sizeof channel &&
|
SECSuccess && channel.length == sizeof channel &&
|
||||||
channel.cipherSuite) {
|
channel.cipherSuite) {
|
||||||
if (SSL_GetCipherSuiteInfo(channel.cipherSuite,
|
if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
|
||||||
&suite, sizeof suite) == SECSuccess) {
|
&suite, sizeof suite) == SECSuccess) {
|
||||||
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
|
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
|
||||||
}
|
}
|
||||||
@@ -678,7 +678,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
|
|||||||
|
|
||||||
proto_win = SSL_RevealPinArg(sock);
|
proto_win = SSL_RevealPinArg(sock);
|
||||||
|
|
||||||
if (!nickname)
|
if(!nickname)
|
||||||
return secStatus;
|
return secStatus;
|
||||||
|
|
||||||
cert = PK11_FindCertFromNickname(nickname, proto_win);
|
cert = PK11_FindCertFromNickname(nickname, proto_win);
|
||||||
@@ -708,7 +708,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
|
|||||||
*pRetKey = privKey;
|
*pRetKey = privKey;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (cert)
|
if(cert)
|
||||||
CERT_DestroyCertificate(cert);
|
CERT_DestroyCertificate(cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,11 +814,11 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
|
|
||||||
certDir = getenv("SSL_DIR"); /* Look in $SSL_DIR */
|
certDir = getenv("SSL_DIR"); /* Look in $SSL_DIR */
|
||||||
|
|
||||||
if (!certDir) {
|
if(!certDir) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat(SSL_DIR, &st) == 0)
|
if(stat(SSL_DIR, &st) == 0)
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if(S_ISDIR(st.st_mode)) {
|
||||||
certDir = (char *)SSL_DIR;
|
certDir = (char *)SSL_DIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -845,8 +845,8 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
|
|
||||||
mod = SECMOD_LoadUserModule(configstring, NULL, PR_FALSE);
|
mod = SECMOD_LoadUserModule(configstring, NULL, PR_FALSE);
|
||||||
free(configstring);
|
free(configstring);
|
||||||
if (!mod || !mod->loaded) {
|
if(!mod || !mod->loaded) {
|
||||||
if (mod) {
|
if(mod) {
|
||||||
SECMOD_DestroyModule(mod);
|
SECMOD_DestroyModule(mod);
|
||||||
mod = NULL;
|
mod = NULL;
|
||||||
}
|
}
|
||||||
@@ -912,31 +912,31 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
if(!data->set.ssl.verifypeer)
|
if(!data->set.ssl.verifypeer)
|
||||||
/* skip the verifying of the peer */
|
/* skip the verifying of the peer */
|
||||||
;
|
;
|
||||||
else if (data->set.ssl.CAfile) {
|
else if(data->set.ssl.CAfile) {
|
||||||
int rc = nss_load_cert(data->set.ssl.CAfile, PR_TRUE);
|
int rc = nss_load_cert(data->set.ssl.CAfile, PR_TRUE);
|
||||||
if (!rc) {
|
if(!rc) {
|
||||||
curlerr = CURLE_SSL_CACERT_BADFILE;
|
curlerr = CURLE_SSL_CACERT_BADFILE;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data->set.ssl.CApath) {
|
else if(data->set.ssl.CApath) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
PRDir *dir;
|
PRDir *dir;
|
||||||
PRDirEntry *entry;
|
PRDirEntry *entry;
|
||||||
|
|
||||||
if (stat(data->set.ssl.CApath, &st) == -1) {
|
if(stat(data->set.ssl.CApath, &st) == -1) {
|
||||||
curlerr = CURLE_SSL_CACERT_BADFILE;
|
curlerr = CURLE_SSL_CACERT_BADFILE;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if(S_ISDIR(st.st_mode)) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
dir = PR_OpenDir(data->set.ssl.CApath);
|
dir = PR_OpenDir(data->set.ssl.CApath);
|
||||||
do {
|
do {
|
||||||
entry = PR_ReadDir(dir, PR_SKIP_BOTH | PR_SKIP_HIDDEN);
|
entry = PR_ReadDir(dir, PR_SKIP_BOTH | PR_SKIP_HIDDEN);
|
||||||
|
|
||||||
if (entry) {
|
if(entry) {
|
||||||
char fullpath[PATH_MAX];
|
char fullpath[PATH_MAX];
|
||||||
|
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", data->set.ssl.CApath,
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", data->set.ssl.CApath,
|
||||||
@@ -946,7 +946,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
}
|
}
|
||||||
/* This is purposefully tolerant of errors so non-PEM files
|
/* This is purposefully tolerant of errors so non-PEM files
|
||||||
* can be in the same directory */
|
* can be in the same directory */
|
||||||
} while (entry != NULL);
|
} while(entry != NULL);
|
||||||
PR_CloseDir(dir);
|
PR_CloseDir(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -963,7 +963,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
nickname = (char *)malloc(PATH_MAX);
|
nickname = (char *)malloc(PATH_MAX);
|
||||||
if(is_file(data->set.str[STRING_CERT])) {
|
if(is_file(data->set.str[STRING_CERT])) {
|
||||||
n = strrchr(data->set.str[STRING_CERT], '/');
|
n = strrchr(data->set.str[STRING_CERT], '/');
|
||||||
if (n) {
|
if(n) {
|
||||||
n++; /* skip last slash */
|
n++; /* skip last slash */
|
||||||
snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", 1, n);
|
snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", 1, n);
|
||||||
}
|
}
|
||||||
@@ -975,7 +975,7 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
free(nickname);
|
free(nickname);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!cert_stuff(conn, data->set.str[STRING_CERT],
|
if(!cert_stuff(conn, data->set.str[STRING_CERT],
|
||||||
data->set.str[STRING_KEY])) {
|
data->set.str[STRING_KEY])) {
|
||||||
/* failf() is already done in cert_stuff() */
|
/* failf() is already done in cert_stuff() */
|
||||||
free(nickname);
|
free(nickname);
|
||||||
@@ -1011,10 +1011,10 @@ CURLcode Curl_nss_connect(struct connectdata * conn, int sockindex)
|
|||||||
SSL_SetURL(connssl->handle, conn->host.name);
|
SSL_SetURL(connssl->handle, conn->host.name);
|
||||||
|
|
||||||
/* Force the handshake now */
|
/* Force the handshake now */
|
||||||
if (SSL_ForceHandshakeWithTimeout(connssl->handle,
|
if(SSL_ForceHandshakeWithTimeout(connssl->handle,
|
||||||
PR_SecondsToInterval(HANDSHAKE_TIMEOUT))
|
PR_SecondsToInterval(HANDSHAKE_TIMEOUT))
|
||||||
!= SECSuccess) {
|
!= SECSuccess) {
|
||||||
if (conn->data->set.ssl.certverifyresult!=0)
|
if(conn->data->set.ssl.certverifyresult!=0)
|
||||||
curlerr = CURLE_SSL_CACERT;
|
curlerr = CURLE_SSL_CACERT;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|||||||
44
lib/nwlib.c
44
lib/nwlib.c
@@ -105,7 +105,7 @@ int _NonAppStart( void *NLMHandle,
|
|||||||
"<library-name> memory allocations",
|
"<library-name> memory allocations",
|
||||||
AllocSignature);
|
AllocSignature);
|
||||||
|
|
||||||
if (!gAllocTag) {
|
if(!gAllocTag) {
|
||||||
OutputToScreen(errorScreen, "Unable to allocate resource tag for "
|
OutputToScreen(errorScreen, "Unable to allocate resource tag for "
|
||||||
"library memory allocations.\n");
|
"library memory allocations.\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -113,7 +113,7 @@ int _NonAppStart( void *NLMHandle,
|
|||||||
|
|
||||||
gLibId = register_library(DisposeLibraryData);
|
gLibId = register_library(DisposeLibraryData);
|
||||||
|
|
||||||
if (gLibId < -1) {
|
if(gLibId < -1) {
|
||||||
OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
|
OutputToScreen(errorScreen, "Unable to register library with kernel.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ int _NonAppStart( void *NLMHandle,
|
|||||||
|
|
||||||
gLibLock = NXMutexAlloc(0, 0, &liblock);
|
gLibLock = NXMutexAlloc(0, 0, &liblock);
|
||||||
|
|
||||||
if (!gLibLock) {
|
if(!gLibLock) {
|
||||||
OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
|
OutputToScreen(errorScreen, "Unable to allocate library data lock.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
*/
|
*/
|
||||||
app_data = (libdata_t *) get_app_data(id);
|
app_data = (libdata_t *) get_app_data(id);
|
||||||
|
|
||||||
if (!app_data) {
|
if(!app_data) {
|
||||||
/*
|
/*
|
||||||
** This application hasn't called us before; set up application AND per-thread
|
** This application hasn't called us before; set up application AND per-thread
|
||||||
** data. Of course, just in case a thread from this same application is calling
|
** data. Of course, just in case a thread from this same application is calling
|
||||||
@@ -186,17 +186,17 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
*/
|
*/
|
||||||
NXLock(gLibLock);
|
NXLock(gLibLock);
|
||||||
|
|
||||||
if (!(app_data = (libdata_t *) get_app_data(id))) {
|
if(!(app_data = (libdata_t *) get_app_data(id))) {
|
||||||
app_data = (libdata_t *) malloc(sizeof(libdata_t));
|
app_data = (libdata_t *) malloc(sizeof(libdata_t));
|
||||||
|
|
||||||
if (app_data) {
|
if(app_data) {
|
||||||
memset(app_data, 0, sizeof(libdata_t));
|
memset(app_data, 0, sizeof(libdata_t));
|
||||||
|
|
||||||
app_data->tenbytes = malloc(10);
|
app_data->tenbytes = malloc(10);
|
||||||
app_data->lock = NXMutexAlloc(0, 0, &liblock);
|
app_data->lock = NXMutexAlloc(0, 0, &liblock);
|
||||||
|
|
||||||
if (!app_data->tenbytes || !app_data->lock) {
|
if(!app_data->tenbytes || !app_data->lock) {
|
||||||
if (app_data->lock)
|
if(app_data->lock)
|
||||||
NXMutexFree(app_data->lock);
|
NXMutexFree(app_data->lock);
|
||||||
|
|
||||||
free(app_data);
|
free(app_data);
|
||||||
@@ -204,7 +204,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app_data) {
|
if(app_data) {
|
||||||
/*
|
/*
|
||||||
** Here we burn in the application data that we were trying to get by calling
|
** Here we burn in the application data that we were trying to get by calling
|
||||||
** get_app_data(). Next time we call the first function, we'll get this data
|
** get_app_data(). Next time we call the first function, we'll get this data
|
||||||
@@ -214,7 +214,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
*/
|
*/
|
||||||
err = set_app_data(gLibId, app_data);
|
err = set_app_data(gLibId, app_data);
|
||||||
|
|
||||||
if (err) {
|
if(err) {
|
||||||
free(app_data);
|
free(app_data);
|
||||||
app_data = (libdata_t *) NULL;
|
app_data = (libdata_t *) NULL;
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
@@ -223,7 +223,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
/* create key for thread-specific data... */
|
/* create key for thread-specific data... */
|
||||||
err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
|
err = NXKeyCreate(DisposeThreadData, (void *) NULL, &key);
|
||||||
|
|
||||||
if (err) /* (no more keys left?) */
|
if(err) /* (no more keys left?) */
|
||||||
key = -1;
|
key = -1;
|
||||||
|
|
||||||
app_data->perthreadkey = key;
|
app_data->perthreadkey = key;
|
||||||
@@ -235,10 +235,10 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
NXUnlock(gLibLock);
|
NXUnlock(gLibLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app_data) {
|
if(app_data) {
|
||||||
key = app_data->perthreadkey;
|
key = app_data->perthreadkey;
|
||||||
|
|
||||||
if (key != -1 /* couldn't create a key? no thread data */
|
if(key != -1 /* couldn't create a key? no thread data */
|
||||||
&& !(err = NXKeyGetValue(key, (void **) &thread_data))
|
&& !(err = NXKeyGetValue(key, (void **) &thread_data))
|
||||||
&& !thread_data) {
|
&& !thread_data) {
|
||||||
/*
|
/*
|
||||||
@@ -250,17 +250,17 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
*/
|
*/
|
||||||
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
|
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
|
||||||
|
|
||||||
if (thread_data) {
|
if(thread_data) {
|
||||||
thread_data->_errno = 0;
|
thread_data->_errno = 0;
|
||||||
thread_data->twentybytes = malloc(20);
|
thread_data->twentybytes = malloc(20);
|
||||||
|
|
||||||
if (!thread_data->twentybytes) {
|
if(!thread_data->twentybytes) {
|
||||||
free(thread_data);
|
free(thread_data);
|
||||||
thread_data = (libthreaddata_t *) NULL;
|
thread_data = (libthreaddata_t *) NULL;
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = NXKeySetValue(key, thread_data))) {
|
if((err = NXKeySetValue(key, thread_data))) {
|
||||||
free(thread_data->twentybytes);
|
free(thread_data->twentybytes);
|
||||||
free(thread_data);
|
free(thread_data);
|
||||||
thread_data = (libthreaddata_t *) NULL;
|
thread_data = (libthreaddata_t *) NULL;
|
||||||
@@ -269,10 +269,10 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appData)
|
if(appData)
|
||||||
*appData = app_data;
|
*appData = app_data;
|
||||||
|
|
||||||
if (threadData)
|
if(threadData)
|
||||||
*threadData = thread_data;
|
*threadData = thread_data;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
@@ -280,10 +280,10 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
|
|
||||||
int DisposeLibraryData( void *data )
|
int DisposeLibraryData( void *data )
|
||||||
{
|
{
|
||||||
if (data) {
|
if(data) {
|
||||||
void *tenbytes = ((libdata_t *) data)->tenbytes;
|
void *tenbytes = ((libdata_t *) data)->tenbytes;
|
||||||
|
|
||||||
if (tenbytes)
|
if(tenbytes)
|
||||||
free(tenbytes);
|
free(tenbytes);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
@@ -294,10 +294,10 @@ int DisposeLibraryData( void *data )
|
|||||||
|
|
||||||
void DisposeThreadData( void *data )
|
void DisposeThreadData( void *data )
|
||||||
{
|
{
|
||||||
if (data) {
|
if(data) {
|
||||||
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
|
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
|
||||||
|
|
||||||
if (twentybytes)
|
if(twentybytes)
|
||||||
free(twentybytes);
|
free(twentybytes);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
|
|||||||
@@ -57,17 +57,17 @@ int netware_init ( void )
|
|||||||
/* import UseAccurateCaseForPaths dynamically for NW3.x compatibility */
|
/* import UseAccurateCaseForPaths dynamically for NW3.x compatibility */
|
||||||
void (*pUseAccurateCaseForPaths)(int) = (void(*)(int))
|
void (*pUseAccurateCaseForPaths)(int) = (void(*)(int))
|
||||||
ImportSymbol(myHandle, "UseAccurateCaseForPaths");
|
ImportSymbol(myHandle, "UseAccurateCaseForPaths");
|
||||||
if (pUnAugmentAsterisk)
|
if(pUnAugmentAsterisk)
|
||||||
pUnAugmentAsterisk(1);
|
pUnAugmentAsterisk(1);
|
||||||
if (pUseAccurateCaseForPaths)
|
if(pUseAccurateCaseForPaths)
|
||||||
pUseAccurateCaseForPaths(1);
|
pUseAccurateCaseForPaths(1);
|
||||||
UnimportSymbol(myHandle, "UnAugmentAsterisk");
|
UnimportSymbol(myHandle, "UnAugmentAsterisk");
|
||||||
UnimportSymbol(myHandle, "UseAccurateCaseForPaths");
|
UnimportSymbol(myHandle, "UseAccurateCaseForPaths");
|
||||||
/* set long name space */
|
/* set long name space */
|
||||||
if ((SetCurrentNameSpace(4) == 255)) {
|
if((SetCurrentNameSpace(4) == 255)) {
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
if ((SetTargetNameSpace(4) == 255)) {
|
if((SetTargetNameSpace(4) == 255)) {
|
||||||
rc = rc + 2;
|
rc = rc + 2;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -154,7 +154,7 @@ static const struct tzinfo tz[]= {
|
|||||||
0 monday - 6 sunday
|
0 monday - 6 sunday
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int checkday(char *check, size_t len)
|
static int checkday(const char *check, size_t len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char * const *what;
|
const char * const *what;
|
||||||
@@ -173,7 +173,7 @@ static int checkday(char *check, size_t len)
|
|||||||
return found?i:-1;
|
return found?i:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int checkmonth(char *check)
|
static int checkmonth(const char *check)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char * const *what;
|
const char * const *what;
|
||||||
@@ -193,7 +193,7 @@ static int checkmonth(char *check)
|
|||||||
/* return the time zone offset between GMT and the input one, in number
|
/* return the time zone offset between GMT and the input one, in number
|
||||||
of seconds or -1 if the timezone wasn't found/legal */
|
of seconds or -1 if the timezone wasn't found/legal */
|
||||||
|
|
||||||
static int checktz(char *check)
|
static int checktz(const char *check)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const struct tzinfo *what;
|
const struct tzinfo *what;
|
||||||
@@ -325,7 +325,7 @@ static time_t Curl_parsedate(const char *date)
|
|||||||
yearnum = val;
|
yearnum = val;
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
if(yearnum < 1900) {
|
if(yearnum < 1900) {
|
||||||
if (yearnum > 70)
|
if(yearnum > 70)
|
||||||
yearnum += 1900;
|
yearnum += 1900;
|
||||||
else
|
else
|
||||||
yearnum += 2000;
|
yearnum += 2000;
|
||||||
|
|||||||
42
lib/qssl.c
42
lib/qssl.c
@@ -80,10 +80,10 @@ static CURLcode Curl_qsossl_init_session(struct SessionHandle * data)
|
|||||||
|
|
||||||
certname = data->set.str[STRING_CERT];
|
certname = data->set.str[STRING_CERT];
|
||||||
|
|
||||||
if (!certname) {
|
if(!certname) {
|
||||||
certname = data->set.str[STRING_SSL_CAFILE];
|
certname = data->set.str[STRING_SSL_CAFILE];
|
||||||
|
|
||||||
if (!certname)
|
if(!certname)
|
||||||
return CURLE_OK; /* Use previous setup. */
|
return CURLE_OK; /* Use previous setup. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ static CURLcode Curl_qsossl_init_session(struct SessionHandle * data)
|
|||||||
initappstr.sessionType = SSL_REGISTERED_AS_CLIENT;
|
initappstr.sessionType = SSL_REGISTERED_AS_CLIENT;
|
||||||
rc = SSL_Init_Application(&initappstr);
|
rc = SSL_Init_Application(&initappstr);
|
||||||
|
|
||||||
if (rc == SSL_ERROR_NOT_REGISTERED) {
|
if(rc == SSL_ERROR_NOT_REGISTERED) {
|
||||||
initstr.keyringFileName = certname;
|
initstr.keyringFileName = certname;
|
||||||
initstr.keyringPassword = data->set.str[STRING_KEY];
|
initstr.keyringPassword = data->set.str[STRING_KEY];
|
||||||
initstr.cipherSuiteList = NULL; /* Use default. */
|
initstr.cipherSuiteList = NULL; /* Use default. */
|
||||||
@@ -141,7 +141,7 @@ static CURLcode Curl_qsossl_create(struct connectdata * conn, int sockindex)
|
|||||||
|
|
||||||
h = SSL_Create(conn->sock[sockindex], SSL_ENCRYPT);
|
h = SSL_Create(conn->sock[sockindex], SSL_ENCRYPT);
|
||||||
|
|
||||||
if (!h) {
|
if(!h) {
|
||||||
failf(conn->data, "SSL_Create() I/O error: %s\n", strerror(errno));
|
failf(conn->data, "SSL_Create() I/O error: %s\n", strerror(errno));
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
}
|
}
|
||||||
@@ -169,17 +169,17 @@ static CURLcode Curl_qsossl_handshake(struct connectdata * conn, int sockindex)
|
|||||||
|
|
||||||
h->exitPgm = NULL;
|
h->exitPgm = NULL;
|
||||||
|
|
||||||
if (!data->set.ssl.verifyhost)
|
if(!data->set.ssl.verifyhost)
|
||||||
h->exitPgm = Curl_qsossl_trap_cert;
|
h->exitPgm = Curl_qsossl_trap_cert;
|
||||||
|
|
||||||
if (data->set.connecttimeout) {
|
if(data->set.connecttimeout) {
|
||||||
timeout_ms = data->set.connecttimeout;
|
timeout_ms = data->set.connecttimeout;
|
||||||
|
|
||||||
if (data->set.timeout)
|
if(data->set.timeout)
|
||||||
if (timeout_ms > data->set.timeout)
|
if(timeout_ms > data->set.timeout)
|
||||||
timeout_ms = data->set.timeout;
|
timeout_ms = data->set.timeout;
|
||||||
}
|
}
|
||||||
else if (data->set.timeout)
|
else if(data->set.timeout)
|
||||||
timeout_ms = data->set.timeout;
|
timeout_ms = data->set.timeout;
|
||||||
else
|
else
|
||||||
timeout_ms = DEFAULT_CONNECT_TIMEOUT;
|
timeout_ms = DEFAULT_CONNECT_TIMEOUT;
|
||||||
@@ -253,10 +253,10 @@ CURLcode Curl_qsossl_connect(struct connectdata * conn, int sockindex)
|
|||||||
|
|
||||||
rc = Curl_qsossl_init_session(data);
|
rc = Curl_qsossl_init_session(data);
|
||||||
|
|
||||||
if (rc == CURLE_OK) {
|
if(rc == CURLE_OK) {
|
||||||
rc = Curl_qsossl_create(conn, sockindex);
|
rc = Curl_qsossl_create(conn, sockindex);
|
||||||
|
|
||||||
if (rc == CURLE_OK)
|
if(rc == CURLE_OK)
|
||||||
rc = Curl_qsossl_handshake(conn, sockindex);
|
rc = Curl_qsossl_handshake(conn, sockindex);
|
||||||
else {
|
else {
|
||||||
SSL_Destroy(connssl->handle);
|
SSL_Destroy(connssl->handle);
|
||||||
@@ -281,7 +281,7 @@ static int Curl_qsossl_close_one(struct ssl_connect_data * conn,
|
|||||||
rc = SSL_Destroy(conn->handle);
|
rc = SSL_Destroy(conn->handle);
|
||||||
|
|
||||||
if(rc) {
|
if(rc) {
|
||||||
if (rc == SSL_ERROR_IO) {
|
if(rc == SSL_ERROR_IO) {
|
||||||
failf(data, "SSL_Destroy() I/O error: %s\n", strerror(errno));
|
failf(data, "SSL_Destroy() I/O error: %s\n", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -326,13 +326,13 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
|
|||||||
int rc;
|
int rc;
|
||||||
char buf[120];
|
char buf[120];
|
||||||
|
|
||||||
if (!connssl->handle)
|
if(!connssl->handle)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
|
if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (Curl_qsossl_close_one(connssl, data))
|
if(Curl_qsossl_close_one(connssl, data))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
@@ -341,14 +341,14 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
|
|||||||
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
CURL_SOCKET_BAD, SSL_SHUTDOWN_TIMEOUT);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (what < 0) {
|
if(what < 0) {
|
||||||
/* anything that gets here is fatally bad */
|
/* anything that gets here is fatally bad */
|
||||||
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
|
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!what) { /* timeout */
|
if(!what) { /* timeout */
|
||||||
failf(data, "SSL shutdown timeout");
|
failf(data, "SSL shutdown timeout");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -358,12 +358,12 @@ int Curl_qsossl_shutdown(struct connectdata * conn, int sockindex)
|
|||||||
|
|
||||||
nread = read(conn->sock[sockindex], buf, sizeof(buf));
|
nread = read(conn->sock[sockindex], buf, sizeof(buf));
|
||||||
|
|
||||||
if (nread < 0) {
|
if(nread < 0) {
|
||||||
failf(data, "read: %s\n", strerror(errno));
|
failf(data, "read: %s\n", strerror(errno));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nread <= 0)
|
if(nread <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
what = Curl_socket_ready(conn->sock[sockindex], CURL_SOCKET_BAD, 0);
|
what = Curl_socket_ready(conn->sock[sockindex], CURL_SOCKET_BAD, 0);
|
||||||
@@ -470,13 +470,13 @@ int Curl_qsossl_check_cxn(struct connectdata * cxn)
|
|||||||
|
|
||||||
/* The only thing that can be tested here is at the socket level. */
|
/* The only thing that can be tested here is at the socket level. */
|
||||||
|
|
||||||
if (!cxn->ssl[FIRSTSOCKET].handle)
|
if(!cxn->ssl[FIRSTSOCKET].handle)
|
||||||
return 0; /* connection has been closed */
|
return 0; /* connection has been closed */
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
errlen = sizeof err;
|
errlen = sizeof err;
|
||||||
|
|
||||||
if (getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
|
if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
|
||||||
(unsigned char *) &err, &errlen) ||
|
(unsigned char *) &err, &errlen) ||
|
||||||
errlen != sizeof err || err)
|
errlen != sizeof err || err)
|
||||||
return 0; /* connection has been closed */
|
return 0; /* connection has been closed */
|
||||||
|
|||||||
135
lib/security.c
135
lib/security.c
@@ -9,6 +9,9 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1998, 1999 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1998, 1999 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
|
*
|
||||||
|
* Copyright (C) 2001 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -67,13 +70,13 @@
|
|||||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
enum protection_level level;
|
enum protection_level level;
|
||||||
const char *name;
|
const char *name;
|
||||||
} level_names[] = {
|
} level_names[] = {
|
||||||
{ prot_clear, "clear" },
|
{ prot_clear, "clear" },
|
||||||
{ prot_safe, "safe" },
|
{ prot_safe, "safe" },
|
||||||
{ prot_confidential, "confidential" },
|
{ prot_confidential, "confidential" },
|
||||||
{ prot_private, "private" }
|
{ prot_private, "private" }
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum protection_level
|
static enum protection_level
|
||||||
@@ -88,12 +91,12 @@ name_to_level(const char *name)
|
|||||||
|
|
||||||
static const struct Curl_sec_client_mech * const mechs[] = {
|
static const struct Curl_sec_client_mech * const mechs[] = {
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
&Curl_krb5_client_mech,
|
&Curl_krb5_client_mech,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_KRB4
|
#ifdef HAVE_KRB4
|
||||||
&Curl_krb4_client_mech,
|
&Curl_krb4_client_mech,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -116,11 +119,11 @@ block_read(int fd, void *buf, size_t len)
|
|||||||
int b;
|
int b;
|
||||||
while(len) {
|
while(len) {
|
||||||
b = read(fd, p, len);
|
b = read(fd, p, len);
|
||||||
if (b == 0)
|
if(b == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else if (b < 0 && (errno == EINTR || errno == EAGAIN))
|
else if(b < 0 && (errno == EINTR || errno == EAGAIN))
|
||||||
continue;
|
continue;
|
||||||
else if (b < 0)
|
else if(b < 0)
|
||||||
return -1;
|
return -1;
|
||||||
len -= b;
|
len -= b;
|
||||||
p += b;
|
p += b;
|
||||||
@@ -135,7 +138,7 @@ block_write(int fd, const void *buf, size_t len)
|
|||||||
int b;
|
int b;
|
||||||
while(len) {
|
while(len) {
|
||||||
b = write(fd, p, len);
|
b = write(fd, p, len);
|
||||||
if (b < 0 && (errno == EINTR || errno == EAGAIN))
|
if(b < 0 && (errno == EINTR || errno == EAGAIN))
|
||||||
continue;
|
continue;
|
||||||
else if(b < 0)
|
else if(b < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -153,16 +156,16 @@ sec_get_data(struct connectdata *conn,
|
|||||||
int b;
|
int b;
|
||||||
|
|
||||||
b = block_read(fd, &len, sizeof(len));
|
b = block_read(fd, &len, sizeof(len));
|
||||||
if (b == 0)
|
if(b == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else if (b < 0)
|
else if(b < 0)
|
||||||
return -1;
|
return -1;
|
||||||
len = ntohl(len);
|
len = ntohl(len);
|
||||||
buf->data = realloc(buf->data, len);
|
buf->data = realloc(buf->data, len);
|
||||||
b = buf->data ? block_read(fd, buf->data, len) : -1;
|
b = buf->data ? block_read(fd, buf->data, len) : -1;
|
||||||
if (b == 0)
|
if(b == 0)
|
||||||
return 0;
|
return 0;
|
||||||
else if (b < 0)
|
else if(b < 0)
|
||||||
return -1;
|
return -1;
|
||||||
buf->size = (conn->mech->decode)(conn->app_data, buf->data, len,
|
buf->size = (conn->mech->decode)(conn->app_data, buf->data, len,
|
||||||
conn->data_prot, conn);
|
conn->data_prot, conn);
|
||||||
@@ -173,64 +176,64 @@ sec_get_data(struct connectdata *conn,
|
|||||||
static size_t
|
static size_t
|
||||||
buffer_read(struct krb4buffer *buf, void *data, size_t len)
|
buffer_read(struct krb4buffer *buf, void *data, size_t len)
|
||||||
{
|
{
|
||||||
len = min(len, buf->size - buf->index);
|
len = min(len, buf->size - buf->index);
|
||||||
memcpy(data, (char*)buf->data + buf->index, len);
|
memcpy(data, (char*)buf->data + buf->index, len);
|
||||||
buf->index += len;
|
buf->index += len;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
buffer_write(struct krb4buffer *buf, void *data, size_t len)
|
buffer_write(struct krb4buffer *buf, void *data, size_t len)
|
||||||
{
|
{
|
||||||
if(buf->index + len > buf->size) {
|
if(buf->index + len > buf->size) {
|
||||||
void *tmp;
|
void *tmp;
|
||||||
if(buf->data == NULL)
|
if(buf->data == NULL)
|
||||||
tmp = malloc(1024);
|
tmp = malloc(1024);
|
||||||
else
|
else
|
||||||
tmp = realloc(buf->data, buf->index + len);
|
tmp = realloc(buf->data, buf->index + len);
|
||||||
if(tmp == NULL)
|
if(tmp == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
buf->data = tmp;
|
buf->data = tmp;
|
||||||
buf->size = buf->index + len;
|
buf->size = buf->index + len;
|
||||||
}
|
}
|
||||||
memcpy((char*)buf->data + buf->index, data, len);
|
memcpy((char*)buf->data + buf->index, data, len);
|
||||||
buf->index += len;
|
buf->index += len;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Curl_sec_read(struct connectdata *conn, int fd, void *buffer, int length)
|
Curl_sec_read(struct connectdata *conn, int fd, void *buffer, int length)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
int rx = 0;
|
int rx = 0;
|
||||||
|
|
||||||
if(conn->sec_complete == 0 || conn->data_prot == 0)
|
if(conn->sec_complete == 0 || conn->data_prot == 0)
|
||||||
return read(fd, buffer, length);
|
return read(fd, buffer, length);
|
||||||
|
|
||||||
if(conn->in_buffer.eof_flag){
|
if(conn->in_buffer.eof_flag){
|
||||||
conn->in_buffer.eof_flag = 0;
|
conn->in_buffer.eof_flag = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = buffer_read(&conn->in_buffer, buffer, length);
|
||||||
|
length -= len;
|
||||||
|
rx += len;
|
||||||
|
buffer = (char*)buffer + len;
|
||||||
|
|
||||||
|
while(length) {
|
||||||
|
if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
|
||||||
|
return -1;
|
||||||
|
if(conn->in_buffer.size == 0) {
|
||||||
|
if(rx)
|
||||||
|
conn->in_buffer.eof_flag = 1;
|
||||||
|
return rx;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = buffer_read(&conn->in_buffer, buffer, length);
|
len = buffer_read(&conn->in_buffer, buffer, length);
|
||||||
length -= len;
|
length -= len;
|
||||||
rx += len;
|
rx += len;
|
||||||
buffer = (char*)buffer + len;
|
buffer = (char*)buffer + len;
|
||||||
|
}
|
||||||
while(length) {
|
return rx;
|
||||||
if(sec_get_data(conn, fd, &conn->in_buffer) < 0)
|
|
||||||
return -1;
|
|
||||||
if(conn->in_buffer.size == 0) {
|
|
||||||
if(rx)
|
|
||||||
conn->in_buffer.eof_flag = 1;
|
|
||||||
return rx;
|
|
||||||
}
|
|
||||||
len = buffer_read(&conn->in_buffer, buffer, length);
|
|
||||||
length -= len;
|
|
||||||
rx += len;
|
|
||||||
buffer = (char*)buffer + len;
|
|
||||||
}
|
|
||||||
return rx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -255,15 +258,17 @@ sec_send(struct connectdata *conn, int fd, char *from, int length)
|
|||||||
bytes = Curl_base64_encode(conn->data, (char *)buf, bytes, &cmdbuf);
|
bytes = Curl_base64_encode(conn->data, (char *)buf, bytes, &cmdbuf);
|
||||||
if(bytes > 0) {
|
if(bytes > 0) {
|
||||||
if(protlevel == prot_private)
|
if(protlevel == prot_private)
|
||||||
block_write(fd, "ENC ", 4);
|
block_write(fd, "ENC ", 4);
|
||||||
else
|
else
|
||||||
block_write(fd, "MIC ", 4);
|
block_write(fd, "MIC ", 4);
|
||||||
block_write(fd, cmdbuf, bytes);
|
block_write(fd, cmdbuf, bytes);
|
||||||
block_write(fd, "\r\n", 2);
|
block_write(fd, "\r\n", 2);
|
||||||
Curl_infof(conn->data, "%s %s\n", protlevel == prot_private ? "ENC" : "MIC", cmdbuf);
|
Curl_infof(conn->data, "%s %s\n",
|
||||||
|
protlevel == prot_private ? "ENC" : "MIC", cmdbuf);
|
||||||
free(cmdbuf);
|
free(cmdbuf);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
bytes = htonl(bytes);
|
bytes = htonl(bytes);
|
||||||
block_write(fd, &bytes, sizeof(bytes));
|
block_write(fd, &bytes, sizeof(bytes));
|
||||||
block_write(fd, buf, ntohl(bytes));
|
block_write(fd, buf, ntohl(bytes));
|
||||||
@@ -278,7 +283,7 @@ Curl_sec_fflush_fd(struct connectdata *conn, int fd)
|
|||||||
if(conn->data_prot != prot_clear) {
|
if(conn->data_prot != prot_clear) {
|
||||||
if(conn->out_buffer.index > 0){
|
if(conn->out_buffer.index > 0){
|
||||||
Curl_sec_write(conn, fd,
|
Curl_sec_write(conn, fd,
|
||||||
conn->out_buffer.data, conn->out_buffer.index);
|
conn->out_buffer.data, conn->out_buffer.index);
|
||||||
conn->out_buffer.index = 0;
|
conn->out_buffer.index = 0;
|
||||||
}
|
}
|
||||||
sec_send(conn, fd, NULL, 0);
|
sec_send(conn, fd, NULL, 0);
|
||||||
@@ -457,7 +462,7 @@ Curl_sec_login(struct connectdata *conn)
|
|||||||
void *tmp;
|
void *tmp;
|
||||||
|
|
||||||
tmp = realloc(conn->app_data, (*m)->size);
|
tmp = realloc(conn->app_data, (*m)->size);
|
||||||
if (tmp == NULL) {
|
if(tmp == NULL) {
|
||||||
failf (data, "realloc %u failed", (*m)->size);
|
failf (data, "realloc %u failed", (*m)->size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -518,7 +523,7 @@ Curl_sec_login(struct connectdata *conn)
|
|||||||
void
|
void
|
||||||
Curl_sec_end(struct connectdata *conn)
|
Curl_sec_end(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
if (conn->mech != NULL) {
|
if(conn->mech != NULL) {
|
||||||
if(conn->mech->end)
|
if(conn->mech->end)
|
||||||
(conn->mech->end)(conn->app_data);
|
(conn->mech->end)(conn->app_data);
|
||||||
memset(conn->app_data, 0, conn->mech->size);
|
memset(conn->app_data, 0, conn->mech->size);
|
||||||
|
|||||||
150
lib/select.c
150
lib/select.c
@@ -52,7 +52,7 @@
|
|||||||
/* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1] */
|
/* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1] */
|
||||||
|
|
||||||
#if defined(USE_WINSOCK) || defined(TPF)
|
#if defined(USE_WINSOCK) || defined(TPF)
|
||||||
#define VERIFY_SOCK(x) do { } while (0)
|
#define VERIFY_SOCK(x) do { } while(0)
|
||||||
#else
|
#else
|
||||||
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
|
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
|
||||||
#define VERIFY_SOCK(x) do { \
|
#define VERIFY_SOCK(x) do { \
|
||||||
@@ -105,9 +105,9 @@ static int wait_ms(int timeout_ms)
|
|||||||
#endif
|
#endif
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (!timeout_ms)
|
if(!timeout_ms)
|
||||||
return 0;
|
return 0;
|
||||||
if (timeout_ms < 0) {
|
if(timeout_ms < 0) {
|
||||||
SET_SOCKERRNO(EINVAL);
|
SET_SOCKERRNO(EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -126,17 +126,17 @@ static int wait_ms(int timeout_ms)
|
|||||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||||
r = select(0, NULL, NULL, NULL, &pending_tv);
|
r = select(0, NULL, NULL, NULL, &pending_tv);
|
||||||
#endif /* HAVE_POLL_FINE */
|
#endif /* HAVE_POLL_FINE */
|
||||||
if (r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
if ((error == EINVAL) || error_is_EINTR)
|
if((error == EINVAL) || error_is_EINTR)
|
||||||
break;
|
break;
|
||||||
pending_ms = timeout_ms - elapsed_ms;
|
pending_ms = timeout_ms - elapsed_ms;
|
||||||
if (pending_ms <= 0)
|
if(pending_ms <= 0)
|
||||||
break;
|
break;
|
||||||
} while (r == -1);
|
} while(r == -1);
|
||||||
#endif /* USE_WINSOCK */
|
#endif /* USE_WINSOCK */
|
||||||
if (r)
|
if(r)
|
||||||
r = -1;
|
r = -1;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
|||||||
when function is called with a zero timeout or a negative timeout
|
when function is called with a zero timeout or a negative timeout
|
||||||
value indicating a blocking call should be performed. */
|
value indicating a blocking call should be performed. */
|
||||||
|
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_ms = timeout_ms;
|
pending_ms = timeout_ms;
|
||||||
initial_tv = curlx_tvnow();
|
initial_tv = curlx_tvnow();
|
||||||
}
|
}
|
||||||
@@ -197,13 +197,13 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
|||||||
#ifdef HAVE_POLL_FINE
|
#ifdef HAVE_POLL_FINE
|
||||||
|
|
||||||
num = 0;
|
num = 0;
|
||||||
if (readfd != CURL_SOCKET_BAD) {
|
if(readfd != CURL_SOCKET_BAD) {
|
||||||
pfd[num].fd = readfd;
|
pfd[num].fd = readfd;
|
||||||
pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
|
pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
|
||||||
pfd[num].revents = 0;
|
pfd[num].revents = 0;
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
if (writefd != CURL_SOCKET_BAD) {
|
if(writefd != CURL_SOCKET_BAD) {
|
||||||
pfd[num].fd = writefd;
|
pfd[num].fd = writefd;
|
||||||
pfd[num].events = POLLWRNORM|POLLOUT;
|
pfd[num].events = POLLWRNORM|POLLOUT;
|
||||||
pfd[num].revents = 0;
|
pfd[num].revents = 0;
|
||||||
@@ -211,41 +211,41 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (timeout_ms < 0)
|
if(timeout_ms < 0)
|
||||||
pending_ms = -1;
|
pending_ms = -1;
|
||||||
else if (!timeout_ms)
|
else if(!timeout_ms)
|
||||||
pending_ms = 0;
|
pending_ms = 0;
|
||||||
r = poll(pfd, num, pending_ms);
|
r = poll(pfd, num, pending_ms);
|
||||||
if (r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
if ((error == EINVAL) || error_is_EINTR)
|
if((error == EINVAL) || error_is_EINTR)
|
||||||
break;
|
break;
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_ms = timeout_ms - elapsed_ms;
|
pending_ms = timeout_ms - elapsed_ms;
|
||||||
if (pending_ms <= 0)
|
if(pending_ms <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (r == -1);
|
} while(r == -1);
|
||||||
|
|
||||||
if (r < 0)
|
if(r < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (r == 0)
|
if(r == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
num = 0;
|
num = 0;
|
||||||
if (readfd != CURL_SOCKET_BAD) {
|
if(readfd != CURL_SOCKET_BAD) {
|
||||||
if (pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
|
if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
|
||||||
ret |= CURL_CSELECT_IN;
|
ret |= CURL_CSELECT_IN;
|
||||||
if (pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
|
if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
|
||||||
ret |= CURL_CSELECT_ERR;
|
ret |= CURL_CSELECT_ERR;
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
if (writefd != CURL_SOCKET_BAD) {
|
if(writefd != CURL_SOCKET_BAD) {
|
||||||
if (pfd[num].revents & (POLLWRNORM|POLLOUT))
|
if(pfd[num].revents & (POLLWRNORM|POLLOUT))
|
||||||
ret |= CURL_CSELECT_OUT;
|
ret |= CURL_CSELECT_OUT;
|
||||||
if (pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
|
if(pfd[num].revents & (POLLERR|POLLHUP|POLLNVAL))
|
||||||
ret |= CURL_CSELECT_ERR;
|
ret |= CURL_CSELECT_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
|||||||
maxfd = (curl_socket_t)-1;
|
maxfd = (curl_socket_t)-1;
|
||||||
|
|
||||||
FD_ZERO(&fds_read);
|
FD_ZERO(&fds_read);
|
||||||
if (readfd != CURL_SOCKET_BAD) {
|
if(readfd != CURL_SOCKET_BAD) {
|
||||||
VERIFY_SOCK(readfd);
|
VERIFY_SOCK(readfd);
|
||||||
FD_SET(readfd, &fds_read);
|
FD_SET(readfd, &fds_read);
|
||||||
FD_SET(readfd, &fds_err);
|
FD_SET(readfd, &fds_err);
|
||||||
@@ -265,54 +265,54 @@ int Curl_socket_ready(curl_socket_t readfd, curl_socket_t writefd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
FD_ZERO(&fds_write);
|
FD_ZERO(&fds_write);
|
||||||
if (writefd != CURL_SOCKET_BAD) {
|
if(writefd != CURL_SOCKET_BAD) {
|
||||||
VERIFY_SOCK(writefd);
|
VERIFY_SOCK(writefd);
|
||||||
FD_SET(writefd, &fds_write);
|
FD_SET(writefd, &fds_write);
|
||||||
FD_SET(writefd, &fds_err);
|
FD_SET(writefd, &fds_err);
|
||||||
if (writefd > maxfd)
|
if(writefd > maxfd)
|
||||||
maxfd = writefd;
|
maxfd = writefd;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_tv.tv_sec = pending_ms / 1000;
|
pending_tv.tv_sec = pending_ms / 1000;
|
||||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||||
}
|
}
|
||||||
else if (!timeout_ms) {
|
else if(!timeout_ms) {
|
||||||
pending_tv.tv_sec = 0;
|
pending_tv.tv_sec = 0;
|
||||||
pending_tv.tv_usec = 0;
|
pending_tv.tv_usec = 0;
|
||||||
}
|
}
|
||||||
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
||||||
if (r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
if ((error == EINVAL) || (error == EBADF) || error_is_EINTR)
|
if((error == EINVAL) || (error == EBADF) || error_is_EINTR)
|
||||||
break;
|
break;
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_ms = timeout_ms - elapsed_ms;
|
pending_ms = timeout_ms - elapsed_ms;
|
||||||
if (pending_ms <= 0)
|
if(pending_ms <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (r == -1);
|
} while(r == -1);
|
||||||
|
|
||||||
if (r < 0)
|
if(r < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (r == 0)
|
if(r == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (readfd != CURL_SOCKET_BAD) {
|
if(readfd != CURL_SOCKET_BAD) {
|
||||||
if (FD_ISSET(readfd, &fds_read))
|
if(FD_ISSET(readfd, &fds_read))
|
||||||
ret |= CURL_CSELECT_IN;
|
ret |= CURL_CSELECT_IN;
|
||||||
if (FD_ISSET(readfd, &fds_err))
|
if(FD_ISSET(readfd, &fds_err))
|
||||||
ret |= CURL_CSELECT_ERR;
|
ret |= CURL_CSELECT_ERR;
|
||||||
}
|
}
|
||||||
if (writefd != CURL_SOCKET_BAD) {
|
if(writefd != CURL_SOCKET_BAD) {
|
||||||
if (FD_ISSET(writefd, &fds_write))
|
if(FD_ISSET(writefd, &fds_write))
|
||||||
ret |= CURL_CSELECT_OUT;
|
ret |= CURL_CSELECT_OUT;
|
||||||
if (FD_ISSET(writefd, &fds_err))
|
if(FD_ISSET(writefd, &fds_err))
|
||||||
ret |= CURL_CSELECT_ERR;
|
ret |= CURL_CSELECT_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,15 +355,15 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
int error;
|
int error;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (ufds) {
|
if(ufds) {
|
||||||
for (i = 0; i < nfds; i++) {
|
for (i = 0; i < nfds; i++) {
|
||||||
if (ufds[i].fd != CURL_SOCKET_BAD) {
|
if(ufds[i].fd != CURL_SOCKET_BAD) {
|
||||||
fds_none = FALSE;
|
fds_none = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fds_none) {
|
if(fds_none) {
|
||||||
r = wait_ms(timeout_ms);
|
r = wait_ms(timeout_ms);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
when function is called with a zero timeout or a negative timeout
|
when function is called with a zero timeout or a negative timeout
|
||||||
value indicating a blocking call should be performed. */
|
value indicating a blocking call should be performed. */
|
||||||
|
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_ms = timeout_ms;
|
pending_ms = timeout_ms;
|
||||||
initial_tv = curlx_tvnow();
|
initial_tv = curlx_tvnow();
|
||||||
}
|
}
|
||||||
@@ -381,22 +381,22 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
#ifdef HAVE_POLL_FINE
|
#ifdef HAVE_POLL_FINE
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (timeout_ms < 0)
|
if(timeout_ms < 0)
|
||||||
pending_ms = -1;
|
pending_ms = -1;
|
||||||
else if (!timeout_ms)
|
else if(!timeout_ms)
|
||||||
pending_ms = 0;
|
pending_ms = 0;
|
||||||
r = poll(ufds, nfds, pending_ms);
|
r = poll(ufds, nfds, pending_ms);
|
||||||
if (r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
if ((error == EINVAL) || error_is_EINTR)
|
if((error == EINVAL) || error_is_EINTR)
|
||||||
break;
|
break;
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_ms = timeout_ms - elapsed_ms;
|
pending_ms = timeout_ms - elapsed_ms;
|
||||||
if (pending_ms <= 0)
|
if(pending_ms <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (r == -1);
|
} while(r == -1);
|
||||||
|
|
||||||
#else /* HAVE_POLL_FINE */
|
#else /* HAVE_POLL_FINE */
|
||||||
|
|
||||||
@@ -407,18 +407,18 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
|
|
||||||
for (i = 0; i < nfds; i++) {
|
for (i = 0; i < nfds; i++) {
|
||||||
ufds[i].revents = 0;
|
ufds[i].revents = 0;
|
||||||
if (ufds[i].fd == CURL_SOCKET_BAD)
|
if(ufds[i].fd == CURL_SOCKET_BAD)
|
||||||
continue;
|
continue;
|
||||||
VERIFY_SOCK(ufds[i].fd);
|
VERIFY_SOCK(ufds[i].fd);
|
||||||
if (ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
|
if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
|
||||||
POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
|
POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
|
||||||
if (ufds[i].fd > maxfd)
|
if(ufds[i].fd > maxfd)
|
||||||
maxfd = ufds[i].fd;
|
maxfd = ufds[i].fd;
|
||||||
if (ufds[i].events & (POLLRDNORM|POLLIN))
|
if(ufds[i].events & (POLLRDNORM|POLLIN))
|
||||||
FD_SET(ufds[i].fd, &fds_read);
|
FD_SET(ufds[i].fd, &fds_read);
|
||||||
if (ufds[i].events & (POLLWRNORM|POLLOUT))
|
if(ufds[i].events & (POLLWRNORM|POLLOUT))
|
||||||
FD_SET(ufds[i].fd, &fds_write);
|
FD_SET(ufds[i].fd, &fds_write);
|
||||||
if (ufds[i].events & (POLLRDBAND|POLLPRI))
|
if(ufds[i].events & (POLLRDBAND|POLLPRI))
|
||||||
FD_SET(ufds[i].fd, &fds_err);
|
FD_SET(ufds[i].fd, &fds_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,44 +426,44 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||||||
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_tv.tv_sec = pending_ms / 1000;
|
pending_tv.tv_sec = pending_ms / 1000;
|
||||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||||
}
|
}
|
||||||
else if (!timeout_ms) {
|
else if(!timeout_ms) {
|
||||||
pending_tv.tv_sec = 0;
|
pending_tv.tv_sec = 0;
|
||||||
pending_tv.tv_usec = 0;
|
pending_tv.tv_usec = 0;
|
||||||
}
|
}
|
||||||
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
r = select((int)maxfd + 1, &fds_read, &fds_write, &fds_err, ptimeout);
|
||||||
if (r != -1)
|
if(r != -1)
|
||||||
break;
|
break;
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
if ((error == EINVAL) || (error == EBADF) || error_is_EINTR)
|
if((error == EINVAL) || (error == EBADF) || error_is_EINTR)
|
||||||
break;
|
break;
|
||||||
if (timeout_ms > 0) {
|
if(timeout_ms > 0) {
|
||||||
pending_ms = timeout_ms - elapsed_ms;
|
pending_ms = timeout_ms - elapsed_ms;
|
||||||
if (pending_ms <= 0)
|
if(pending_ms <= 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (r == -1);
|
} while(r == -1);
|
||||||
|
|
||||||
if (r < 0)
|
if(r < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (r == 0)
|
if(r == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
for (i = 0; i < nfds; i++) {
|
for (i = 0; i < nfds; i++) {
|
||||||
ufds[i].revents = 0;
|
ufds[i].revents = 0;
|
||||||
if (ufds[i].fd == CURL_SOCKET_BAD)
|
if(ufds[i].fd == CURL_SOCKET_BAD)
|
||||||
continue;
|
continue;
|
||||||
if (FD_ISSET(ufds[i].fd, &fds_read))
|
if(FD_ISSET(ufds[i].fd, &fds_read))
|
||||||
ufds[i].revents |= POLLIN;
|
ufds[i].revents |= POLLIN;
|
||||||
if (FD_ISSET(ufds[i].fd, &fds_write))
|
if(FD_ISSET(ufds[i].fd, &fds_write))
|
||||||
ufds[i].revents |= POLLOUT;
|
ufds[i].revents |= POLLOUT;
|
||||||
if (FD_ISSET(ufds[i].fd, &fds_err))
|
if(FD_ISSET(ufds[i].fd, &fds_err))
|
||||||
ufds[i].revents |= POLLPRI;
|
ufds[i].revents |= POLLPRI;
|
||||||
if (ufds[i].revents != 0)
|
if(ufds[i].revents != 0)
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,13 +40,16 @@
|
|||||||
#undef HAVE_POLL_FINE
|
#undef HAVE_POLL_FINE
|
||||||
#define HAVE_POLL_FINE 1
|
#define HAVE_POLL_FINE 1
|
||||||
#define poll(x,y,z) WSAPoll((x),(y),(z))
|
#define poll(x,y,z) WSAPoll((x),(y),(z))
|
||||||
|
#if defined(_MSC_VER) && defined(POLLRDNORM)
|
||||||
|
#define HAVE_STRUCT_POLLFD 1
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Definition of pollfd struct and constants for platforms lacking them.
|
* Definition of pollfd struct and constants for platforms lacking them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HAVE_SYS_POLL_H
|
#if !defined(HAVE_STRUCT_POLLFD) && !defined(HAVE_SYS_POLL_H)
|
||||||
|
|
||||||
#define POLLIN 0x01
|
#define POLLIN 0x01
|
||||||
#define POLLPRI 0x02
|
#define POLLPRI 0x02
|
||||||
|
|||||||
56
lib/sendf.c
56
lib/sendf.c
@@ -67,12 +67,12 @@ static struct curl_slist *slist_get_last(struct curl_slist *list)
|
|||||||
struct curl_slist *item;
|
struct curl_slist *item;
|
||||||
|
|
||||||
/* if caller passed us a NULL, return now */
|
/* if caller passed us a NULL, return now */
|
||||||
if (!list)
|
if(!list)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* loop through to find the last item */
|
/* loop through to find the last item */
|
||||||
item = list;
|
item = list;
|
||||||
while (item->next) {
|
while(item->next) {
|
||||||
item = item->next;
|
item = item->next;
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -92,7 +92,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
|
|||||||
struct curl_slist *new_item;
|
struct curl_slist *new_item;
|
||||||
|
|
||||||
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
|
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
|
||||||
if (new_item) {
|
if(new_item) {
|
||||||
char *dupdata = strdup(data);
|
char *dupdata = strdup(data);
|
||||||
if(dupdata) {
|
if(dupdata) {
|
||||||
new_item->next = NULL;
|
new_item->next = NULL;
|
||||||
@@ -106,7 +106,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
|
|||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (list) {
|
if(list) {
|
||||||
last = slist_get_last(list);
|
last = slist_get_last(list);
|
||||||
last->next = new_item;
|
last->next = new_item;
|
||||||
return list;
|
return list;
|
||||||
@@ -122,19 +122,19 @@ void curl_slist_free_all(struct curl_slist *list)
|
|||||||
struct curl_slist *next;
|
struct curl_slist *next;
|
||||||
struct curl_slist *item;
|
struct curl_slist *item;
|
||||||
|
|
||||||
if (!list)
|
if(!list)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
item = list;
|
item = list;
|
||||||
do {
|
do {
|
||||||
next = item->next;
|
next = item->next;
|
||||||
|
|
||||||
if (item->data) {
|
if(item->data) {
|
||||||
free(item->data);
|
free(item->data);
|
||||||
}
|
}
|
||||||
free(item);
|
free(item);
|
||||||
item = next;
|
item = next;
|
||||||
} while (next);
|
} while(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CURL_DO_LINEEND_CONV
|
#ifdef CURL_DO_LINEEND_CONV
|
||||||
@@ -150,14 +150,14 @@ static size_t convert_lineends(struct SessionHandle *data,
|
|||||||
char *inPtr, *outPtr;
|
char *inPtr, *outPtr;
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if ((startPtr == NULL) || (size < 1)) {
|
if((startPtr == NULL) || (size < 1)) {
|
||||||
return(size);
|
return(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->state.prev_block_had_trailing_cr == TRUE) {
|
if(data->state.prev_block_had_trailing_cr == TRUE) {
|
||||||
/* The previous block of incoming data
|
/* The previous block of incoming data
|
||||||
had a trailing CR, which was turned into a LF. */
|
had a trailing CR, which was turned into a LF. */
|
||||||
if (*startPtr == '\n') {
|
if(*startPtr == '\n') {
|
||||||
/* This block of incoming data starts with the
|
/* This block of incoming data starts with the
|
||||||
previous block's LF so get rid of it */
|
previous block's LF so get rid of it */
|
||||||
memcpy(startPtr, startPtr+1, size-1);
|
memcpy(startPtr, startPtr+1, size-1);
|
||||||
@@ -170,11 +170,11 @@ static size_t convert_lineends(struct SessionHandle *data,
|
|||||||
|
|
||||||
/* find 1st CR, if any */
|
/* find 1st CR, if any */
|
||||||
inPtr = outPtr = memchr(startPtr, '\r', size);
|
inPtr = outPtr = memchr(startPtr, '\r', size);
|
||||||
if (inPtr) {
|
if(inPtr) {
|
||||||
/* at least one CR, now look for CRLF */
|
/* at least one CR, now look for CRLF */
|
||||||
while (inPtr < (startPtr+size-1)) {
|
while(inPtr < (startPtr+size-1)) {
|
||||||
/* note that it's size-1, so we'll never look past the last byte */
|
/* note that it's size-1, so we'll never look past the last byte */
|
||||||
if (memcmp(inPtr, "\r\n", 2) == 0) {
|
if(memcmp(inPtr, "\r\n", 2) == 0) {
|
||||||
/* CRLF found, bump past the CR and copy the NL */
|
/* CRLF found, bump past the CR and copy the NL */
|
||||||
inPtr++;
|
inPtr++;
|
||||||
*outPtr = *inPtr;
|
*outPtr = *inPtr;
|
||||||
@@ -182,7 +182,7 @@ static size_t convert_lineends(struct SessionHandle *data,
|
|||||||
data->state.crlf_conversions++;
|
data->state.crlf_conversions++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (*inPtr == '\r') {
|
if(*inPtr == '\r') {
|
||||||
/* lone CR, move LF instead */
|
/* lone CR, move LF instead */
|
||||||
*outPtr = '\n';
|
*outPtr = '\n';
|
||||||
}
|
}
|
||||||
@@ -195,9 +195,9 @@ static size_t convert_lineends(struct SessionHandle *data,
|
|||||||
inPtr++;
|
inPtr++;
|
||||||
} /* end of while loop */
|
} /* end of while loop */
|
||||||
|
|
||||||
if (inPtr < startPtr+size) {
|
if(inPtr < startPtr+size) {
|
||||||
/* handle last byte */
|
/* handle last byte */
|
||||||
if (*inPtr == '\r') {
|
if(*inPtr == '\r') {
|
||||||
/* deal with a CR at the end of the buffer */
|
/* deal with a CR at the end of the buffer */
|
||||||
*outPtr = '\n'; /* copy a NL instead */
|
*outPtr = '\n'; /* copy a NL instead */
|
||||||
/* note that a CRLF might be split across two blocks */
|
/* note that a CRLF might be split across two blocks */
|
||||||
@@ -210,7 +210,7 @@ static size_t convert_lineends(struct SessionHandle *data,
|
|||||||
outPtr++;
|
outPtr++;
|
||||||
inPtr++;
|
inPtr++;
|
||||||
}
|
}
|
||||||
if (outPtr < startPtr+size) {
|
if(outPtr < startPtr+size) {
|
||||||
/* tidy up by null terminating the now shorter data */
|
/* tidy up by null terminating the now shorter data */
|
||||||
*outPtr = '\0';
|
*outPtr = '\0';
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
|
|||||||
write_len = strlen(s);
|
write_len = strlen(s);
|
||||||
sptr = s;
|
sptr = s;
|
||||||
|
|
||||||
while (1) {
|
while(1) {
|
||||||
/* Write the buffer to the socket */
|
/* Write the buffer to the socket */
|
||||||
res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
|
res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
|
||||||
|
|
||||||
@@ -355,13 +355,13 @@ CURLcode Curl_write(struct connectdata *conn,
|
|||||||
CURLcode retcode;
|
CURLcode retcode;
|
||||||
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
|
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
|
||||||
|
|
||||||
if (conn->ssl[num].use)
|
if(conn->ssl[num].use)
|
||||||
/* only TRUE if SSL enabled */
|
/* only TRUE if SSL enabled */
|
||||||
bytes_written = Curl_ssl_send(conn, num, mem, len);
|
bytes_written = Curl_ssl_send(conn, num, mem, len);
|
||||||
#ifdef USE_LIBSSH2
|
#ifdef USE_LIBSSH2
|
||||||
else if (conn->protocol & PROT_SCP)
|
else if(conn->protocol & PROT_SCP)
|
||||||
bytes_written = Curl_scp_send(conn, num, mem, len);
|
bytes_written = Curl_scp_send(conn, num, mem, len);
|
||||||
else if (conn->protocol & PROT_SFTP)
|
else if(conn->protocol & PROT_SFTP)
|
||||||
bytes_written = Curl_sftp_send(conn, num, mem, len);
|
bytes_written = Curl_sftp_send(conn, num, mem, len);
|
||||||
#endif /* !USE_LIBSSH2 */
|
#endif /* !USE_LIBSSH2 */
|
||||||
else if(conn->sec_complete)
|
else if(conn->sec_complete)
|
||||||
@@ -389,7 +389,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
|
|||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
size_t wrote;
|
size_t wrote;
|
||||||
|
|
||||||
if (data->state.cancelled) {
|
if(data->state.cancelled) {
|
||||||
/* We just suck everything into a black hole */
|
/* We just suck everything into a black hole */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
/* If the previous block of data ended with CR and this block of data is
|
/* If the previous block of data ended with CR and this block of data is
|
||||||
just a NL, then the length might be zero */
|
just a NL, then the length might be zero */
|
||||||
if (len) {
|
if(len) {
|
||||||
wrote = data->set.fwrite_func(ptr, 1, len, data->set.out);
|
wrote = data->set.fwrite_func(ptr, 1, len, data->set.out);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -485,7 +485,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
|
|||||||
size_t bytestocopy = MIN(conn->buf_len - conn->read_pos, sizerequested);
|
size_t bytestocopy = MIN(conn->buf_len - conn->read_pos, sizerequested);
|
||||||
|
|
||||||
/* Copy from our master buffer first if we have some unread data there*/
|
/* Copy from our master buffer first if we have some unread data there*/
|
||||||
if (bytestocopy > 0) {
|
if(bytestocopy > 0) {
|
||||||
memcpy(buf, conn->master_buffer + conn->read_pos, bytestocopy);
|
memcpy(buf, conn->master_buffer + conn->read_pos, bytestocopy);
|
||||||
conn->read_pos += bytestocopy;
|
conn->read_pos += bytestocopy;
|
||||||
conn->bits.stream_was_rewound = FALSE;
|
conn->bits.stream_was_rewound = FALSE;
|
||||||
@@ -512,10 +512,10 @@ int Curl_read(struct connectdata *conn, /* connection data */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_LIBSSH2
|
#ifdef USE_LIBSSH2
|
||||||
else if (conn->protocol & (PROT_SCP|PROT_SFTP)) {
|
else if(conn->protocol & (PROT_SCP|PROT_SFTP)) {
|
||||||
if(conn->protocol & PROT_SCP)
|
if(conn->protocol & PROT_SCP)
|
||||||
nread = Curl_scp_recv(conn, num, buffertofill, bytesfromsocket);
|
nread = Curl_scp_recv(conn, num, buffertofill, bytesfromsocket);
|
||||||
else if (conn->protocol & PROT_SFTP)
|
else if(conn->protocol & PROT_SFTP)
|
||||||
nread = Curl_sftp_recv(conn, num, buffertofill, bytesfromsocket);
|
nread = Curl_sftp_recv(conn, num, buffertofill, bytesfromsocket);
|
||||||
#ifdef LIBSSH2CHANNEL_EAGAIN
|
#ifdef LIBSSH2CHANNEL_EAGAIN
|
||||||
if((nread == LIBSSH2CHANNEL_EAGAIN) || (nread == 0))
|
if((nread == LIBSSH2CHANNEL_EAGAIN) || (nread == 0))
|
||||||
@@ -545,7 +545,7 @@ int Curl_read(struct connectdata *conn, /* connection data */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nread >= 0) {
|
if(nread >= 0) {
|
||||||
if(pipelining) {
|
if(pipelining) {
|
||||||
memcpy(buf, conn->master_buffer, nread);
|
memcpy(buf, conn->master_buffer, nread);
|
||||||
conn->buf_len = nread;
|
conn->buf_len = nread;
|
||||||
@@ -573,7 +573,7 @@ static int showit(struct SessionHandle *data, curl_infotype type,
|
|||||||
case CURLINFO_HEADER_OUT:
|
case CURLINFO_HEADER_OUT:
|
||||||
/* assume output headers are ASCII */
|
/* assume output headers are ASCII */
|
||||||
/* copy the data into my buffer so the original is unchanged */
|
/* copy the data into my buffer so the original is unchanged */
|
||||||
if (size > BUFSIZE) {
|
if(size > BUFSIZE) {
|
||||||
size = BUFSIZE; /* truncate if necessary */
|
size = BUFSIZE; /* truncate if necessary */
|
||||||
buf[BUFSIZE] = '\0';
|
buf[BUFSIZE] = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
10
lib/setup.h
10
lib/setup.h
@@ -32,13 +32,11 @@
|
|||||||
#define CURL_DISABLE_FILE
|
#define CURL_DISABLE_FILE
|
||||||
#endif /* HTTP_ONLY */
|
#endif /* HTTP_ONLY */
|
||||||
|
|
||||||
#if !defined(WIN32) && defined(__WIN32__)
|
/*
|
||||||
/* Borland fix */
|
* Define WIN32 when build target is Win32 API
|
||||||
#define WIN32
|
*/
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(WIN32) && defined(_WIN32)
|
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||||
/* VS2005 on x64 fix */
|
|
||||||
#define WIN32
|
#define WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
22
lib/share.c
22
lib/share.c
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -38,7 +38,7 @@ curl_share_init(void)
|
|||||||
{
|
{
|
||||||
struct Curl_share *share =
|
struct Curl_share *share =
|
||||||
(struct Curl_share *)malloc(sizeof(struct Curl_share));
|
(struct Curl_share *)malloc(sizeof(struct Curl_share));
|
||||||
if (share) {
|
if(share) {
|
||||||
memset (share, 0, sizeof(struct Curl_share));
|
memset (share, 0, sizeof(struct Curl_share));
|
||||||
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
|
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||||||
curl_unlock_function unlockfunc;
|
curl_unlock_function unlockfunc;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
if (share->dirty)
|
if(share->dirty)
|
||||||
/* don't allow setting options while one or more handles are already
|
/* don't allow setting options while one or more handles are already
|
||||||
using this share */
|
using this share */
|
||||||
return CURLSHE_IN_USE;
|
return CURLSHE_IN_USE;
|
||||||
@@ -70,7 +70,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||||||
share->specifier |= (1<<type);
|
share->specifier |= (1<<type);
|
||||||
switch( type ) {
|
switch( type ) {
|
||||||
case CURL_LOCK_DATA_DNS:
|
case CURL_LOCK_DATA_DNS:
|
||||||
if (!share->hostcache) {
|
if(!share->hostcache) {
|
||||||
share->hostcache = Curl_mk_dnscache();
|
share->hostcache = Curl_mk_dnscache();
|
||||||
if(!share->hostcache)
|
if(!share->hostcache)
|
||||||
return CURLSHE_NOMEM;
|
return CURLSHE_NOMEM;
|
||||||
@@ -79,7 +79,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||||||
|
|
||||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
||||||
case CURL_LOCK_DATA_COOKIE:
|
case CURL_LOCK_DATA_COOKIE:
|
||||||
if (!share->cookies) {
|
if(!share->cookies) {
|
||||||
share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE );
|
share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE );
|
||||||
if(!share->cookies)
|
if(!share->cookies)
|
||||||
return CURLSHE_NOMEM;
|
return CURLSHE_NOMEM;
|
||||||
@@ -102,7 +102,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case CURL_LOCK_DATA_DNS:
|
case CURL_LOCK_DATA_DNS:
|
||||||
if (share->hostcache) {
|
if(share->hostcache) {
|
||||||
Curl_hash_destroy(share->hostcache);
|
Curl_hash_destroy(share->hostcache);
|
||||||
share->hostcache = NULL;
|
share->hostcache = NULL;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||||||
|
|
||||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
||||||
case CURL_LOCK_DATA_COOKIE:
|
case CURL_LOCK_DATA_COOKIE:
|
||||||
if (share->cookies) {
|
if(share->cookies) {
|
||||||
Curl_cookie_cleanup(share->cookies);
|
Curl_cookie_cleanup(share->cookies);
|
||||||
share->cookies = NULL;
|
share->cookies = NULL;
|
||||||
}
|
}
|
||||||
@@ -155,14 +155,14 @@ curl_share_cleanup(CURLSH *sh)
|
|||||||
{
|
{
|
||||||
struct Curl_share *share = (struct Curl_share *)sh;
|
struct Curl_share *share = (struct Curl_share *)sh;
|
||||||
|
|
||||||
if (share == NULL)
|
if(share == NULL)
|
||||||
return CURLSHE_INVALID;
|
return CURLSHE_INVALID;
|
||||||
|
|
||||||
if(share->lockfunc)
|
if(share->lockfunc)
|
||||||
share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE,
|
share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE,
|
||||||
share->clientdata);
|
share->clientdata);
|
||||||
|
|
||||||
if (share->dirty) {
|
if(share->dirty) {
|
||||||
if(share->unlockfunc)
|
if(share->unlockfunc)
|
||||||
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
||||||
return CURLSHE_IN_USE;
|
return CURLSHE_IN_USE;
|
||||||
@@ -190,7 +190,7 @@ Curl_share_lock(struct SessionHandle *data, curl_lock_data type,
|
|||||||
{
|
{
|
||||||
struct Curl_share *share = data->share;
|
struct Curl_share *share = data->share;
|
||||||
|
|
||||||
if (share == NULL)
|
if(share == NULL)
|
||||||
return CURLSHE_INVALID;
|
return CURLSHE_INVALID;
|
||||||
|
|
||||||
if(share->specifier & (1<<type)) {
|
if(share->specifier & (1<<type)) {
|
||||||
@@ -207,7 +207,7 @@ Curl_share_unlock(struct SessionHandle *data, curl_lock_data type)
|
|||||||
{
|
{
|
||||||
struct Curl_share *share = data->share;
|
struct Curl_share *share = data->share;
|
||||||
|
|
||||||
if (share == NULL)
|
if(share == NULL)
|
||||||
return CURLSHE_INVALID;
|
return CURLSHE_INVALID;
|
||||||
|
|
||||||
if(share->specifier & (1<<type)) {
|
if(share->specifier & (1<<type)) {
|
||||||
|
|||||||
46
lib/socks.c
46
lib/socks.c
@@ -136,7 +136,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
|||||||
|
|
||||||
/* get timeout */
|
/* get timeout */
|
||||||
if(data->set.timeout && data->set.connecttimeout) {
|
if(data->set.timeout && data->set.connecttimeout) {
|
||||||
if (data->set.timeout < data->set.connecttimeout)
|
if(data->set.timeout < data->set.connecttimeout)
|
||||||
timeout = data->set.timeout;
|
timeout = data->set.timeout;
|
||||||
else
|
else
|
||||||
timeout = data->set.connecttimeout;
|
timeout = data->set.connecttimeout;
|
||||||
@@ -186,7 +186,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
|||||||
*/
|
*/
|
||||||
if(dns)
|
if(dns)
|
||||||
hp=dns->addr;
|
hp=dns->addr;
|
||||||
if (hp) {
|
if(hp) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
unsigned short ip[4];
|
unsigned short ip[4];
|
||||||
Curl_printable_address(hp, buf, sizeof(buf));
|
Curl_printable_address(hp, buf, sizeof(buf));
|
||||||
@@ -216,7 +216,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
|||||||
* This is currently not supporting "Identification Protocol (RFC1413)".
|
* This is currently not supporting "Identification Protocol (RFC1413)".
|
||||||
*/
|
*/
|
||||||
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
|
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
|
||||||
if (proxy_name)
|
if(proxy_name)
|
||||||
strlcat((char*)socksreq + 8, proxy_name, sizeof(socksreq) - 8);
|
strlcat((char*)socksreq + 8, proxy_name, sizeof(socksreq) - 8);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -230,7 +230,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
|||||||
|
|
||||||
/* Send request */
|
/* Send request */
|
||||||
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
|
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
|
||||||
if ((code != CURLE_OK) || (written != packetsize)) {
|
if((code != CURLE_OK) || (written != packetsize)) {
|
||||||
failf(data, "Failed to send SOCKS4 connect request.");
|
failf(data, "Failed to send SOCKS4 connect request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
|||||||
/* Receive response */
|
/* Receive response */
|
||||||
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
|
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
|
||||||
&actualread, timeout);
|
&actualread, timeout);
|
||||||
if ((result != CURLE_OK) || (actualread != packetsize)) {
|
if((result != CURLE_OK) || (actualread != packetsize)) {
|
||||||
failf(data, "Failed to receive SOCKS4 connect request ack.");
|
failf(data, "Failed to receive SOCKS4 connect request ack.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* wrong version ? */
|
/* wrong version ? */
|
||||||
if (socksreq[0] != 0) {
|
if(socksreq[0] != 0) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"SOCKS4 reply has wrong version, version should be 4.");
|
"SOCKS4 reply has wrong version, version should be 4.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
@@ -362,7 +362,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
|
|
||||||
/* get timeout */
|
/* get timeout */
|
||||||
if(data->set.timeout && data->set.connecttimeout) {
|
if(data->set.timeout && data->set.connecttimeout) {
|
||||||
if (data->set.timeout < data->set.connecttimeout)
|
if(data->set.timeout < data->set.connecttimeout)
|
||||||
timeout = data->set.timeout;
|
timeout = data->set.timeout;
|
||||||
else
|
else
|
||||||
timeout = data->set.connecttimeout;
|
timeout = data->set.connecttimeout;
|
||||||
@@ -402,7 +402,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
|
|
||||||
code = Curl_write(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
|
code = Curl_write(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
|
||||||
&written);
|
&written);
|
||||||
if ((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
|
if((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
|
||||||
failf(data, "Unable to send initial SOCKS5 request.");
|
failf(data, "Unable to send initial SOCKS5 request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
@@ -428,20 +428,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
Curl_nonblock(sock, FALSE);
|
Curl_nonblock(sock, FALSE);
|
||||||
|
|
||||||
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread, timeout);
|
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread, timeout);
|
||||||
if ((result != CURLE_OK) || (actualread != 2)) {
|
if((result != CURLE_OK) || (actualread != 2)) {
|
||||||
failf(data, "Unable to receive initial SOCKS5 response.");
|
failf(data, "Unable to receive initial SOCKS5 response.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socksreq[0] != 5) {
|
if(socksreq[0] != 5) {
|
||||||
failf(data, "Received invalid version in initial SOCKS5 response.");
|
failf(data, "Received invalid version in initial SOCKS5 response.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
if (socksreq[1] == 0) {
|
if(socksreq[1] == 0) {
|
||||||
/* Nothing to do, no authentication needed */
|
/* Nothing to do, no authentication needed */
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else if (socksreq[1] == 2) {
|
else if(socksreq[1] == 2) {
|
||||||
/* Needs user name and password */
|
/* Needs user name and password */
|
||||||
size_t userlen, pwlen;
|
size_t userlen, pwlen;
|
||||||
int len;
|
int len;
|
||||||
@@ -471,20 +471,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
len += pwlen;
|
len += pwlen;
|
||||||
|
|
||||||
code = Curl_write(conn, sock, (char *)socksreq, len, &written);
|
code = Curl_write(conn, sock, (char *)socksreq, len, &written);
|
||||||
if ((code != CURLE_OK) || (len != written)) {
|
if((code != CURLE_OK) || (len != written)) {
|
||||||
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
|
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread,
|
result=blockread_all(conn, sock, (char *)socksreq, 2, &actualread,
|
||||||
timeout);
|
timeout);
|
||||||
if ((result != CURLE_OK) || (actualread != 2)) {
|
if((result != CURLE_OK) || (actualread != 2)) {
|
||||||
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
|
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore the first (VER) byte */
|
/* ignore the first (VER) byte */
|
||||||
if (socksreq[1] != 0) { /* status */
|
if(socksreq[1] != 0) { /* status */
|
||||||
failf(data, "User was rejected by the SOCKS5 server (%d %d).",
|
failf(data, "User was rejected by the SOCKS5 server (%d %d).",
|
||||||
socksreq[0], socksreq[1]);
|
socksreq[0], socksreq[1]);
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
@@ -494,13 +494,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* error */
|
/* error */
|
||||||
if (socksreq[1] == 1) {
|
if(socksreq[1] == 1) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"SOCKS5 GSSAPI per-message authentication is not supported.");
|
"SOCKS5 GSSAPI per-message authentication is not supported.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
else if (socksreq[1] == 255) {
|
else if(socksreq[1] == 255) {
|
||||||
if (!proxy_name || !*proxy_name) {
|
if(!proxy_name || !*proxy_name) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"No authentication method was acceptable. (It is quite likely"
|
"No authentication method was acceptable. (It is quite likely"
|
||||||
" that the SOCKS5 server wanted a username/password, since none"
|
" that the SOCKS5 server wanted a username/password, since none"
|
||||||
@@ -542,7 +542,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
*/
|
*/
|
||||||
if(dns)
|
if(dns)
|
||||||
hp=dns->addr;
|
hp=dns->addr;
|
||||||
if (hp) {
|
if(hp) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
unsigned short ip[4];
|
unsigned short ip[4];
|
||||||
Curl_printable_address(hp, buf, sizeof(buf));
|
Curl_printable_address(hp, buf, sizeof(buf));
|
||||||
@@ -572,24 +572,24 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
|||||||
const int packetsize = 10;
|
const int packetsize = 10;
|
||||||
|
|
||||||
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
|
code = Curl_write(conn, sock, (char *)socksreq, packetsize, &written);
|
||||||
if ((code != CURLE_OK) || (written != packetsize)) {
|
if((code != CURLE_OK) || (written != packetsize)) {
|
||||||
failf(data, "Failed to send SOCKS5 connect request.");
|
failf(data, "Failed to send SOCKS5 connect request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
|
result = blockread_all(conn, sock, (char *)socksreq, packetsize,
|
||||||
&actualread, timeout);
|
&actualread, timeout);
|
||||||
if ((result != CURLE_OK) || (actualread != packetsize)) {
|
if((result != CURLE_OK) || (actualread != packetsize)) {
|
||||||
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socksreq[0] != 5) { /* version */
|
if(socksreq[0] != 5) { /* version */
|
||||||
failf(data,
|
failf(data,
|
||||||
"SOCKS5 reply has wrong version, version should be 5.");
|
"SOCKS5 reply has wrong version, version should be 5.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
if (socksreq[1] != 0) { /* Anything besides 0 is an error */
|
if(socksreq[1] != 0) { /* Anything besides 0 is an error */
|
||||||
failf(data,
|
failf(data,
|
||||||
"Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)",
|
"Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)",
|
||||||
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
|
||||||
|
|||||||
50
lib/splay.c
50
lib/splay.c
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1997 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1997 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -42,37 +42,37 @@ struct Curl_tree *Curl_splay(int i, struct Curl_tree *t)
|
|||||||
struct Curl_tree N, *l, *r, *y;
|
struct Curl_tree N, *l, *r, *y;
|
||||||
int comp;
|
int comp;
|
||||||
|
|
||||||
if (t == NULL)
|
if(t == NULL)
|
||||||
return t;
|
return t;
|
||||||
N.smaller = N.larger = NULL;
|
N.smaller = N.larger = NULL;
|
||||||
l = r = &N;
|
l = r = &N;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
comp = compare(i, t->key);
|
comp = compare(i, t->key);
|
||||||
if (comp < 0) {
|
if(comp < 0) {
|
||||||
if (t->smaller == NULL)
|
if(t->smaller == NULL)
|
||||||
break;
|
break;
|
||||||
if (compare(i, t->smaller->key) < 0) {
|
if(compare(i, t->smaller->key) < 0) {
|
||||||
y = t->smaller; /* rotate smaller */
|
y = t->smaller; /* rotate smaller */
|
||||||
t->smaller = y->larger;
|
t->smaller = y->larger;
|
||||||
y->larger = t;
|
y->larger = t;
|
||||||
t = y;
|
t = y;
|
||||||
if (t->smaller == NULL)
|
if(t->smaller == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r->smaller = t; /* link smaller */
|
r->smaller = t; /* link smaller */
|
||||||
r = t;
|
r = t;
|
||||||
t = t->smaller;
|
t = t->smaller;
|
||||||
}
|
}
|
||||||
else if (comp > 0) {
|
else if(comp > 0) {
|
||||||
if (t->larger == NULL)
|
if(t->larger == NULL)
|
||||||
break;
|
break;
|
||||||
if (compare(i, t->larger->key) > 0) {
|
if(compare(i, t->larger->key) > 0) {
|
||||||
y = t->larger; /* rotate larger */
|
y = t->larger; /* rotate larger */
|
||||||
t->larger = y->smaller;
|
t->larger = y->smaller;
|
||||||
y->smaller = t;
|
y->smaller = t;
|
||||||
t = y;
|
t = y;
|
||||||
if (t->larger == NULL)
|
if(t->larger == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
l->larger = t; /* link larger */
|
l->larger = t; /* link larger */
|
||||||
@@ -97,12 +97,12 @@ struct Curl_tree *Curl_splayinsert(int i,
|
|||||||
struct Curl_tree *t,
|
struct Curl_tree *t,
|
||||||
struct Curl_tree *node)
|
struct Curl_tree *node)
|
||||||
{
|
{
|
||||||
if (node == NULL)
|
if(node == NULL)
|
||||||
return t;
|
return t;
|
||||||
|
|
||||||
if (t != NULL) {
|
if(t != NULL) {
|
||||||
t = Curl_splay(i,t);
|
t = Curl_splay(i,t);
|
||||||
if (compare(i, t->key)==0) {
|
if(compare(i, t->key)==0) {
|
||||||
/* There already exists a node in the tree with the very same key. Build
|
/* There already exists a node in the tree with the very same key. Build
|
||||||
a linked list of nodes. We make the new 'node' struct the new master
|
a linked list of nodes. We make the new 'node' struct the new master
|
||||||
node and make the previous node the first one in the 'same' list. */
|
node and make the previous node the first one in the 'same' list. */
|
||||||
@@ -123,10 +123,10 @@ struct Curl_tree *Curl_splayinsert(int i,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t == NULL) {
|
if(t == NULL) {
|
||||||
node->smaller = node->larger = NULL;
|
node->smaller = node->larger = NULL;
|
||||||
}
|
}
|
||||||
else if (compare(i, t->key) < 0) {
|
else if(compare(i, t->key) < 0) {
|
||||||
node->smaller = t->smaller;
|
node->smaller = t->smaller;
|
||||||
node->larger = t;
|
node->larger = t;
|
||||||
t->smaller = NULL;
|
t->smaller = NULL;
|
||||||
@@ -156,11 +156,11 @@ struct Curl_tree *Curl_splayremove(int i, struct Curl_tree *t,
|
|||||||
|
|
||||||
*removed = NULL; /* default to no removed */
|
*removed = NULL; /* default to no removed */
|
||||||
|
|
||||||
if (t==NULL)
|
if(t==NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
t = Curl_splay(i,t);
|
t = Curl_splay(i,t);
|
||||||
if (compare(i, t->key) == 0) { /* found it */
|
if(compare(i, t->key) == 0) { /* found it */
|
||||||
|
|
||||||
/* FIRST! Check if there is a list with identical sizes */
|
/* FIRST! Check if there is a list with identical sizes */
|
||||||
if((x = t->same)) {
|
if((x = t->same)) {
|
||||||
@@ -176,7 +176,7 @@ struct Curl_tree *Curl_splayremove(int i, struct Curl_tree *t,
|
|||||||
return x; /* new root */
|
return x; /* new root */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->smaller == NULL) {
|
if(t->smaller == NULL) {
|
||||||
x = t->larger;
|
x = t->larger;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -199,7 +199,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
|
|||||||
{
|
{
|
||||||
struct Curl_tree *x;
|
struct Curl_tree *x;
|
||||||
|
|
||||||
if (!t) {
|
if(!t) {
|
||||||
*removed = NULL; /* none removed since there was no root */
|
*removed = NULL; /* none removed since there was no root */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare(i, t->key) >= 0) { /* found it */
|
if(compare(i, t->key) >= 0) { /* found it */
|
||||||
/* FIRST! Check if there is a list with identical sizes */
|
/* FIRST! Check if there is a list with identical sizes */
|
||||||
x = t->same;
|
x = t->same;
|
||||||
if(x) {
|
if(x) {
|
||||||
@@ -232,7 +232,7 @@ struct Curl_tree *Curl_splaygetbest(int i, struct Curl_tree *t,
|
|||||||
return x; /* new root */
|
return x; /* new root */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->smaller == NULL) {
|
if(t->smaller == NULL) {
|
||||||
x = t->larger;
|
x = t->larger;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -265,14 +265,14 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
|
|||||||
{
|
{
|
||||||
struct Curl_tree *x;
|
struct Curl_tree *x;
|
||||||
|
|
||||||
if (!t || !removenode)
|
if(!t || !removenode)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if(KEY_NOTUSED == removenode->key) {
|
if(KEY_NOTUSED == removenode->key) {
|
||||||
/* Key set to NOTUSED means it is a subnode within a 'same' linked list
|
/* Key set to NOTUSED means it is a subnode within a 'same' linked list
|
||||||
and thus we can unlink it easily. The 'smaller' link of a subnode
|
and thus we can unlink it easily. The 'smaller' link of a subnode
|
||||||
links to the parent node. */
|
links to the parent node. */
|
||||||
if (removenode->smaller == NULL)
|
if(removenode->smaller == NULL)
|
||||||
return 3;
|
return 3;
|
||||||
|
|
||||||
removenode->smaller->same = removenode->same;
|
removenode->smaller->same = removenode->same;
|
||||||
@@ -312,7 +312,7 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Remove the root node */
|
/* Remove the root node */
|
||||||
if (t->smaller == NULL)
|
if(t->smaller == NULL)
|
||||||
x = t->larger;
|
x = t->larger;
|
||||||
else {
|
else {
|
||||||
x = Curl_splay(removenode->key, t->smaller);
|
x = Curl_splay(removenode->key, t->smaller);
|
||||||
@@ -332,7 +332,7 @@ void Curl_splayprint(struct Curl_tree * t, int d, char output)
|
|||||||
struct Curl_tree *node;
|
struct Curl_tree *node;
|
||||||
int i;
|
int i;
|
||||||
int count;
|
int count;
|
||||||
if (t == NULL)
|
if(t == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Curl_splayprint(t->larger, d+1, output);
|
Curl_splayprint(t->larger, d+1, output);
|
||||||
|
|||||||
@@ -243,15 +243,18 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
|
|||||||
#else
|
#else
|
||||||
#ifdef USE_NSS
|
#ifdef USE_NSS
|
||||||
*done = TRUE; /* fallback to BLOCKING */
|
*done = TRUE; /* fallback to BLOCKING */
|
||||||
|
conn->ssl[sockindex].use = TRUE;
|
||||||
return Curl_nss_connect(conn, sockindex);
|
return Curl_nss_connect(conn, sockindex);
|
||||||
#else
|
#else
|
||||||
#ifdef USE_QSOSSL
|
#ifdef USE_QSOSSL
|
||||||
*done = TRUE; /* fallback to BLOCKING */
|
*done = TRUE; /* fallback to BLOCKING */
|
||||||
|
conn->ssl[sockindex].use = TRUE;
|
||||||
return Curl_qsossl_connect(conn, sockindex);
|
return Curl_qsossl_connect(conn, sockindex);
|
||||||
#else
|
#else
|
||||||
/* not implemented!
|
/* not implemented!
|
||||||
fallback to BLOCKING call. */
|
fallback to BLOCKING call. */
|
||||||
*done = TRUE;
|
*done = TRUE;
|
||||||
|
conn->ssl[sockindex].use = TRUE;
|
||||||
return Curl_ssl_connect(conn, sockindex);
|
return Curl_ssl_connect(conn, sockindex);
|
||||||
#endif /* USE_QSOSSL */
|
#endif /* USE_QSOSSL */
|
||||||
#endif /* USE_NSS */
|
#endif /* USE_NSS */
|
||||||
@@ -383,7 +386,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
|
|||||||
store->name = clone_host; /* clone host name */
|
store->name = clone_host; /* clone host name */
|
||||||
store->remote_port = conn->remote_port; /* port number */
|
store->remote_port = conn->remote_port; /* port number */
|
||||||
|
|
||||||
if (!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config))
|
if(!Curl_clone_ssl_config(&conn->ssl_config, &store->ssl_config))
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|||||||
128
lib/ssluse.c
128
lib/ssluse.c
@@ -238,7 +238,7 @@ static int ossl_seed(struct SessionHandle *data)
|
|||||||
RAND_add(area, len, (len >> 1));
|
RAND_add(area, len, (len >> 1));
|
||||||
|
|
||||||
free(area); /* now remove the random junk */
|
free(area); /* now remove the random junk */
|
||||||
} while (!RAND_status());
|
} while(!RAND_status());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ int cert_stuff(struct connectdata *conn,
|
|||||||
EVP_PKEY *pri;
|
EVP_PKEY *pri;
|
||||||
|
|
||||||
f = fopen(cert_file,"rb");
|
f = fopen(cert_file,"rb");
|
||||||
if (!f) {
|
if(!f) {
|
||||||
failf(data, "could not open PKCS12 file '%s'", cert_file);
|
failf(data, "could not open PKCS12 file '%s'", cert_file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -375,7 +375,7 @@ int cert_stuff(struct connectdata *conn,
|
|||||||
|
|
||||||
PKCS12_PBE_add();
|
PKCS12_PBE_add();
|
||||||
|
|
||||||
if (!PKCS12_parse(p12, data->set.str[STRING_KEY_PASSWD], &pri, &x509,
|
if(!PKCS12_parse(p12, data->set.str[STRING_KEY_PASSWD], &pri, &x509,
|
||||||
NULL)) {
|
NULL)) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"could not parse PKCS12 file, check password, OpenSSL error %s",
|
"could not parse PKCS12 file, check password, OpenSSL error %s",
|
||||||
@@ -483,7 +483,7 @@ int cert_stuff(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssl=SSL_new(ctx);
|
ssl=SSL_new(ctx);
|
||||||
if (NULL == ssl) {
|
if(NULL == ssl) {
|
||||||
failf(data,"unable to create an SSL structure\n");
|
failf(data,"unable to create an SSL structure\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -564,7 +564,7 @@ int Curl_ossl_init(void)
|
|||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
|
|
||||||
/* Setup all the global SSL stuff */
|
/* Setup all the global SSL stuff */
|
||||||
if (!SSLeay_add_ssl_algorithms())
|
if(!SSLeay_add_ssl_algorithms())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -609,10 +609,10 @@ int Curl_ossl_check_cxn(struct connectdata *conn)
|
|||||||
char buf;
|
char buf;
|
||||||
|
|
||||||
rc = SSL_peek(conn->ssl[FIRSTSOCKET].handle, (void*)&buf, 1);
|
rc = SSL_peek(conn->ssl[FIRSTSOCKET].handle, (void*)&buf, 1);
|
||||||
if (rc > 0)
|
if(rc > 0)
|
||||||
return 1; /* connection still in place */
|
return 1; /* connection still in place */
|
||||||
|
|
||||||
if (rc == 0)
|
if(rc == 0)
|
||||||
return 0; /* connection has been closed */
|
return 0; /* connection has been closed */
|
||||||
|
|
||||||
return -1; /* connection status unknown */
|
return -1; /* connection status unknown */
|
||||||
@@ -625,17 +625,17 @@ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine)
|
|||||||
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
|
#if defined(USE_SSLEAY) && defined(HAVE_OPENSSL_ENGINE_H)
|
||||||
ENGINE *e = ENGINE_by_id(engine);
|
ENGINE *e = ENGINE_by_id(engine);
|
||||||
|
|
||||||
if (!e) {
|
if(!e) {
|
||||||
failf(data, "SSL Engine '%s' not found", engine);
|
failf(data, "SSL Engine '%s' not found", engine);
|
||||||
return (CURLE_SSL_ENGINE_NOTFOUND);
|
return (CURLE_SSL_ENGINE_NOTFOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->state.engine) {
|
if(data->state.engine) {
|
||||||
ENGINE_finish(data->state.engine);
|
ENGINE_finish(data->state.engine);
|
||||||
ENGINE_free(data->state.engine);
|
ENGINE_free(data->state.engine);
|
||||||
data->state.engine = NULL;
|
data->state.engine = NULL;
|
||||||
}
|
}
|
||||||
if (!ENGINE_init(e)) {
|
if(!ENGINE_init(e)) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
ENGINE_free(e);
|
ENGINE_free(e);
|
||||||
@@ -657,8 +657,8 @@ CURLcode Curl_ossl_set_engine(struct SessionHandle *data, const char *engine)
|
|||||||
CURLcode Curl_ossl_set_engine_default(struct SessionHandle *data)
|
CURLcode Curl_ossl_set_engine_default(struct SessionHandle *data)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENSSL_ENGINE_H
|
#ifdef HAVE_OPENSSL_ENGINE_H
|
||||||
if (data->state.engine) {
|
if(data->state.engine) {
|
||||||
if (ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
|
if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
|
||||||
infof(data,"set default crypto engine '%s'\n", ENGINE_get_id(data->state.engine));
|
infof(data,"set default crypto engine '%s'\n", ENGINE_get_id(data->state.engine));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -683,11 +683,11 @@ struct curl_slist *Curl_ossl_engines_list(struct SessionHandle *data)
|
|||||||
|
|
||||||
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
|
for (e = ENGINE_get_first(); e; e = ENGINE_get_next(e)) {
|
||||||
list = curl_slist_append(list, ENGINE_get_id(e));
|
list = curl_slist_append(list, ENGINE_get_id(e));
|
||||||
if (list == NULL) {
|
if(list == NULL) {
|
||||||
curl_slist_free_all(beg);
|
curl_slist_free_all(beg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (beg == NULL) {
|
else if(beg == NULL) {
|
||||||
beg = list;
|
beg = list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -919,26 +919,26 @@ static int Curl_ASN1_UTCTIME_output(struct connectdata *conn,
|
|||||||
|
|
||||||
static int hostmatch(const char *hostname, const char *pattern)
|
static int hostmatch(const char *hostname, const char *pattern)
|
||||||
{
|
{
|
||||||
while (1) {
|
while(1) {
|
||||||
char c = *pattern++;
|
char c = *pattern++;
|
||||||
|
|
||||||
if (c == '\0')
|
if(c == '\0')
|
||||||
return (*hostname ? HOST_NOMATCH : HOST_MATCH);
|
return (*hostname ? HOST_NOMATCH : HOST_MATCH);
|
||||||
|
|
||||||
if (c == '*') {
|
if(c == '*') {
|
||||||
c = *pattern;
|
c = *pattern;
|
||||||
if (c == '\0') /* "*\0" matches anything remaining */
|
if(c == '\0') /* "*\0" matches anything remaining */
|
||||||
return HOST_MATCH;
|
return HOST_MATCH;
|
||||||
|
|
||||||
while (*hostname) {
|
while(*hostname) {
|
||||||
/* The only recursive function in libcurl! */
|
/* The only recursive function in libcurl! */
|
||||||
if (hostmatch(hostname++,pattern) == HOST_MATCH)
|
if(hostmatch(hostname++,pattern) == HOST_MATCH)
|
||||||
return HOST_MATCH;
|
return HOST_MATCH;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toupper(c) != toupper(*hostname++))
|
if(toupper(c) != toupper(*hostname++))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return HOST_NOMATCH;
|
return HOST_NOMATCH;
|
||||||
@@ -947,14 +947,14 @@ static int hostmatch(const char *hostname, const char *pattern)
|
|||||||
static int
|
static int
|
||||||
cert_hostcheck(const char *match_pattern, const char *hostname)
|
cert_hostcheck(const char *match_pattern, const char *hostname)
|
||||||
{
|
{
|
||||||
if (!match_pattern || !*match_pattern ||
|
if(!match_pattern || !*match_pattern ||
|
||||||
!hostname || !*hostname) /* sanity check */
|
!hostname || !*hostname) /* sanity check */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if(curl_strequal(hostname,match_pattern)) /* trivial case */
|
if(curl_strequal(hostname,match_pattern)) /* trivial case */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (hostmatch(hostname,match_pattern) == HOST_MATCH)
|
if(hostmatch(hostname,match_pattern) == HOST_MATCH)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1042,7 @@ static CURLcode verifyhost(struct connectdata *conn,
|
|||||||
"I checked the 0.9.6 and 0.9.8 sources before my patch and
|
"I checked the 0.9.6 and 0.9.8 sources before my patch and
|
||||||
it always 0-terminates an IA5String."
|
it always 0-terminates an IA5String."
|
||||||
*/
|
*/
|
||||||
if (cert_hostcheck(altptr, conn->host.name))
|
if(cert_hostcheck(altptr, conn->host.name))
|
||||||
matched = TRUE;
|
matched = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1073,15 +1073,15 @@ static CURLcode verifyhost(struct connectdata *conn,
|
|||||||
unsigned char *peer_CN = nulstr;
|
unsigned char *peer_CN = nulstr;
|
||||||
|
|
||||||
X509_NAME *name = X509_get_subject_name(server_cert) ;
|
X509_NAME *name = X509_get_subject_name(server_cert) ;
|
||||||
if (name)
|
if(name)
|
||||||
while ((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0)
|
while((j=X509_NAME_get_index_by_NID(name,NID_commonName,i))>=0)
|
||||||
i=j;
|
i=j;
|
||||||
|
|
||||||
/* we have the name entry and we will now convert this to a string
|
/* we have the name entry and we will now convert this to a string
|
||||||
that we can use for comparison. Doing this we support BMPstring,
|
that we can use for comparison. Doing this we support BMPstring,
|
||||||
UTF8 etc. */
|
UTF8 etc. */
|
||||||
|
|
||||||
if (i>=0) {
|
if(i>=0) {
|
||||||
ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i));
|
ASN1_STRING *tmp = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,i));
|
||||||
|
|
||||||
/* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input
|
/* In OpenSSL 0.9.7d and earlier, ASN1_STRING_to_UTF8 fails if the input
|
||||||
@@ -1089,11 +1089,11 @@ static CURLcode verifyhost(struct connectdata *conn,
|
|||||||
string manually to avoid the problem. This code can be made
|
string manually to avoid the problem. This code can be made
|
||||||
conditional in the future when OpenSSL has been fixed. Work-around
|
conditional in the future when OpenSSL has been fixed. Work-around
|
||||||
brought by Alexis S. L. Carvalho. */
|
brought by Alexis S. L. Carvalho. */
|
||||||
if (tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
|
if(tmp && ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
|
||||||
j = ASN1_STRING_length(tmp);
|
j = ASN1_STRING_length(tmp);
|
||||||
if (j >= 0) {
|
if(j >= 0) {
|
||||||
peer_CN = OPENSSL_malloc(j+1);
|
peer_CN = OPENSSL_malloc(j+1);
|
||||||
if (peer_CN) {
|
if(peer_CN) {
|
||||||
memcpy(peer_CN, ASN1_STRING_data(tmp), j);
|
memcpy(peer_CN, ASN1_STRING_data(tmp), j);
|
||||||
peer_CN[j] = '\0';
|
peer_CN[j] = '\0';
|
||||||
}
|
}
|
||||||
@@ -1103,7 +1103,7 @@ static CURLcode verifyhost(struct connectdata *conn,
|
|||||||
j = ASN1_STRING_to_UTF8(&peer_CN, tmp);
|
j = ASN1_STRING_to_UTF8(&peer_CN, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer_CN == nulstr)
|
if(peer_CN == nulstr)
|
||||||
peer_CN = NULL;
|
peer_CN = NULL;
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
else {
|
else {
|
||||||
@@ -1111,14 +1111,14 @@ static CURLcode verifyhost(struct connectdata *conn,
|
|||||||
size_t rc;
|
size_t rc;
|
||||||
rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
|
rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
|
||||||
/* Curl_convert_from_utf8 calls failf if unsuccessful */
|
/* Curl_convert_from_utf8 calls failf if unsuccessful */
|
||||||
if (rc != CURLE_OK) {
|
if(rc != CURLE_OK) {
|
||||||
OPENSSL_free(peer_CN);
|
OPENSSL_free(peer_CN);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
if (!peer_CN) {
|
if(!peer_CN) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"SSL: unable to obtain common name from peer certificate");
|
"SSL: unable to obtain common name from peer certificate");
|
||||||
return CURLE_PEER_FAILED_VERIFICATION;
|
return CURLE_PEER_FAILED_VERIFICATION;
|
||||||
@@ -1149,7 +1149,7 @@ static CURLcode verifyhost(struct connectdata *conn,
|
|||||||
|
|
||||||
static const char *ssl_msg_type(int ssl_ver, int msg)
|
static const char *ssl_msg_type(int ssl_ver, int msg)
|
||||||
{
|
{
|
||||||
if (ssl_ver == SSL2_VERSION_MAJOR) {
|
if(ssl_ver == SSL2_VERSION_MAJOR) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case SSL2_MT_ERROR:
|
case SSL2_MT_ERROR:
|
||||||
return "Error";
|
return "Error";
|
||||||
@@ -1171,7 +1171,7 @@ static const char *ssl_msg_type(int ssl_ver, int msg)
|
|||||||
return "Client CERT";
|
return "Client CERT";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ssl_ver == SSL3_VERSION_MAJOR) {
|
else if(ssl_ver == SSL3_VERSION_MAJOR) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case SSL3_MT_HELLO_REQUEST:
|
case SSL3_MT_HELLO_REQUEST:
|
||||||
return "Hello request";
|
return "Hello request";
|
||||||
@@ -1221,7 +1221,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
|
|||||||
char ssl_buf[1024];
|
char ssl_buf[1024];
|
||||||
int ver, msg_type, txt_len;
|
int ver, msg_type, txt_len;
|
||||||
|
|
||||||
if (!conn || !conn->data || !conn->data->set.fdebug ||
|
if(!conn || !conn->data || !conn->data->set.fdebug ||
|
||||||
(direction != 0 && direction != 1))
|
(direction != 0 && direction != 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1234,7 +1234,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
|
|||||||
* always pass-up content-type as 0. But the interesting message-type
|
* always pass-up content-type as 0. But the interesting message-type
|
||||||
* is at 'buf[0]'.
|
* is at 'buf[0]'.
|
||||||
*/
|
*/
|
||||||
if (ssl_ver == SSL3_VERSION_MAJOR && content_type != 0)
|
if(ssl_ver == SSL3_VERSION_MAJOR && content_type != 0)
|
||||||
tls_rt_name = tls_rt_type(content_type);
|
tls_rt_name = tls_rt_type(content_type);
|
||||||
else
|
else
|
||||||
tls_rt_name = "";
|
tls_rt_name = "";
|
||||||
@@ -1290,7 +1290,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connssl->ctx)
|
if(connssl->ctx)
|
||||||
SSL_CTX_free(connssl->ctx);
|
SSL_CTX_free(connssl->ctx);
|
||||||
connssl->ctx = SSL_CTX_new(req_method);
|
connssl->ctx = SSL_CTX_new(req_method);
|
||||||
|
|
||||||
@@ -1300,14 +1300,14 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SSL_CTRL_SET_MSG_CALLBACK
|
#ifdef SSL_CTRL_SET_MSG_CALLBACK
|
||||||
if (data->set.fdebug && data->set.verbose) {
|
if(data->set.fdebug && data->set.verbose) {
|
||||||
/* the SSL trace callback is only used for verbose logging so we only
|
/* the SSL trace callback is only used for verbose logging so we only
|
||||||
inform about failures of setting it */
|
inform about failures of setting it */
|
||||||
if (!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
|
if(!SSL_CTX_callback_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK,
|
||||||
(void (*)(void))ssl_tls_trace)) {
|
(void (*)(void))ssl_tls_trace)) {
|
||||||
infof(data, "SSL: couldn't set callback!\n");
|
infof(data, "SSL: couldn't set callback!\n");
|
||||||
}
|
}
|
||||||
else if (!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
|
else if(!SSL_CTX_ctrl(connssl->ctx, SSL_CTRL_SET_MSG_CALLBACK_ARG, 0,
|
||||||
conn)) {
|
conn)) {
|
||||||
infof(data, "SSL: couldn't set callback argument!\n");
|
infof(data, "SSL: couldn't set callback argument!\n");
|
||||||
}
|
}
|
||||||
@@ -1330,7 +1330,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
* non-blocking. It doesn't seem to care, but just return with
|
* non-blocking. It doesn't seem to care, but just return with
|
||||||
* SSL_ERROR_WANT_x.
|
* SSL_ERROR_WANT_x.
|
||||||
*/
|
*/
|
||||||
if (data->state.used_interface == Curl_if_multi)
|
if(data->state.used_interface == Curl_if_multi)
|
||||||
SSL_CTX_ctrl(connssl->ctx, BIO_C_SET_NBIO, 1, NULL);
|
SSL_CTX_ctrl(connssl->ctx, BIO_C_SET_NBIO, 1, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1354,13 +1354,13 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->set.str[STRING_SSL_CAFILE] || data->set.str[STRING_SSL_CAPATH]) {
|
if(data->set.str[STRING_SSL_CAFILE] || data->set.str[STRING_SSL_CAPATH]) {
|
||||||
/* tell SSL where to find CA certificates that are used to verify
|
/* tell SSL where to find CA certificates that are used to verify
|
||||||
the servers certificate. */
|
the servers certificate. */
|
||||||
if (!SSL_CTX_load_verify_locations(connssl->ctx,
|
if(!SSL_CTX_load_verify_locations(connssl->ctx,
|
||||||
data->set.str[STRING_SSL_CAFILE],
|
data->set.str[STRING_SSL_CAFILE],
|
||||||
data->set.str[STRING_SSL_CAPATH])) {
|
data->set.str[STRING_SSL_CAPATH])) {
|
||||||
if (data->set.ssl.verifypeer) {
|
if(data->set.ssl.verifypeer) {
|
||||||
/* Fail if we insist on successfully verifying the server. */
|
/* Fail if we insist on successfully verifying the server. */
|
||||||
failf(data,"error setting certificate verify locations:\n"
|
failf(data,"error setting certificate verify locations:\n"
|
||||||
" CAfile: %s\n CApath: %s\n",
|
" CAfile: %s\n CApath: %s\n",
|
||||||
@@ -1408,10 +1408,10 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Lets make an SSL structure */
|
/* Lets make an SSL structure */
|
||||||
if (connssl->handle)
|
if(connssl->handle)
|
||||||
SSL_free(connssl->handle);
|
SSL_free(connssl->handle);
|
||||||
connssl->handle = SSL_new(connssl->ctx);
|
connssl->handle = SSL_new(connssl->ctx);
|
||||||
if (!connssl->handle) {
|
if(!connssl->handle) {
|
||||||
failf(data, "SSL: couldn't create a context (handle)!");
|
failf(data, "SSL: couldn't create a context (handle)!");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
@@ -1422,7 +1422,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
/* Check if there's a cached ID we can/should use here! */
|
/* Check if there's a cached ID we can/should use here! */
|
||||||
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL)) {
|
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL)) {
|
||||||
/* we got a session id, use it! */
|
/* we got a session id, use it! */
|
||||||
if (!SSL_set_session(connssl->handle, ssl_sessionid)) {
|
if(!SSL_set_session(connssl->handle, ssl_sessionid)) {
|
||||||
failf(data, "SSL: SSL_set_session failed: %s",
|
failf(data, "SSL: SSL_set_session failed: %s",
|
||||||
ERR_error_string(ERR_get_error(),NULL));
|
ERR_error_string(ERR_get_error(),NULL));
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
@@ -1432,7 +1432,7 @@ Curl_ossl_connect_step1(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* pass the raw socket into the SSL layers */
|
/* pass the raw socket into the SSL layers */
|
||||||
if (!SSL_set_fd(connssl->handle, sockfd)) {
|
if(!SSL_set_fd(connssl->handle, sockfd)) {
|
||||||
failf(data, "SSL: SSL_set_fd failed: %s",
|
failf(data, "SSL: SSL_set_fd failed: %s",
|
||||||
ERR_error_string(ERR_get_error(),NULL));
|
ERR_error_string(ERR_get_error(),NULL));
|
||||||
return CURLE_SSL_CONNECT_ERROR;
|
return CURLE_SSL_CONNECT_ERROR;
|
||||||
@@ -1545,7 +1545,7 @@ Curl_ossl_connect_step2(struct connectdata *conn,
|
|||||||
* (RST connection etc.), OpenSSL gives no explanation whatsoever and
|
* (RST connection etc.), OpenSSL gives no explanation whatsoever and
|
||||||
* the SO_ERROR is also lost.
|
* the SO_ERROR is also lost.
|
||||||
*/
|
*/
|
||||||
if (CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) {
|
if(CURLE_SSL_CONNECT_ERROR == rc && errdetail == 0) {
|
||||||
failf(data, "Unknown SSL protocol error in connection to %s:%d ",
|
failf(data, "Unknown SSL protocol error in connection to %s:%d ",
|
||||||
conn->host.name, conn->port);
|
conn->host.name, conn->port);
|
||||||
return rc;
|
return rc;
|
||||||
@@ -1704,19 +1704,19 @@ Curl_ossl_connect_common(struct connectdata *conn,
|
|||||||
curl_socket_t sockfd = conn->sock[sockindex];
|
curl_socket_t sockfd = conn->sock[sockindex];
|
||||||
long timeout_ms;
|
long timeout_ms;
|
||||||
|
|
||||||
if (ssl_connect_1==connssl->connecting_state) {
|
if(ssl_connect_1==connssl->connecting_state) {
|
||||||
retcode = Curl_ossl_connect_step1(conn, sockindex);
|
retcode = Curl_ossl_connect_step1(conn, sockindex);
|
||||||
if (retcode)
|
if(retcode)
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout_ms = 0;
|
timeout_ms = 0;
|
||||||
while (ssl_connect_2 == connssl->connecting_state ||
|
while(ssl_connect_2 == connssl->connecting_state ||
|
||||||
ssl_connect_2_reading == connssl->connecting_state ||
|
ssl_connect_2_reading == connssl->connecting_state ||
|
||||||
ssl_connect_2_writing == connssl->connecting_state) {
|
ssl_connect_2_writing == connssl->connecting_state) {
|
||||||
|
|
||||||
/* if ssl is expecting something, check if it's available. */
|
/* if ssl is expecting something, check if it's available. */
|
||||||
if (connssl->connecting_state == ssl_connect_2_reading
|
if(connssl->connecting_state == ssl_connect_2_reading
|
||||||
|| connssl->connecting_state == ssl_connect_2_writing) {
|
|| connssl->connecting_state == ssl_connect_2_writing) {
|
||||||
|
|
||||||
int writefd = ssl_connect_2_writing==
|
int writefd = ssl_connect_2_writing==
|
||||||
@@ -1730,7 +1730,7 @@ Curl_ossl_connect_common(struct connectdata *conn,
|
|||||||
/* readable or writable, go loop in the outer loop */
|
/* readable or writable, go loop in the outer loop */
|
||||||
break;
|
break;
|
||||||
else if(0 == what) {
|
else if(0 == what) {
|
||||||
if (nonblocking) {
|
if(nonblocking) {
|
||||||
*done = FALSE;
|
*done = FALSE;
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@@ -1750,19 +1750,19 @@ Curl_ossl_connect_common(struct connectdata *conn,
|
|||||||
|
|
||||||
/* get the timeout from step2 to avoid computing it twice. */
|
/* get the timeout from step2 to avoid computing it twice. */
|
||||||
retcode = Curl_ossl_connect_step2(conn, sockindex, &timeout_ms);
|
retcode = Curl_ossl_connect_step2(conn, sockindex, &timeout_ms);
|
||||||
if (retcode)
|
if(retcode)
|
||||||
return retcode;
|
return retcode;
|
||||||
|
|
||||||
} /* repeat step2 until all transactions are done. */
|
} /* repeat step2 until all transactions are done. */
|
||||||
|
|
||||||
|
|
||||||
if (ssl_connect_3==connssl->connecting_state) {
|
if(ssl_connect_3==connssl->connecting_state) {
|
||||||
retcode = Curl_ossl_connect_step3(conn, sockindex);
|
retcode = Curl_ossl_connect_step3(conn, sockindex);
|
||||||
if (retcode)
|
if(retcode)
|
||||||
return retcode;
|
return retcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssl_connect_done==connssl->connecting_state) {
|
if(ssl_connect_done==connssl->connecting_state) {
|
||||||
*done = TRUE;
|
*done = TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1791,7 +1791,7 @@ Curl_ossl_connect(struct connectdata *conn,
|
|||||||
bool done = FALSE;
|
bool done = FALSE;
|
||||||
|
|
||||||
retcode = Curl_ossl_connect_common(conn, sockindex, FALSE, &done);
|
retcode = Curl_ossl_connect_common(conn, sockindex, FALSE, &done);
|
||||||
if (retcode)
|
if(retcode)
|
||||||
return retcode;
|
return retcode;
|
||||||
|
|
||||||
DEBUGASSERT(done);
|
DEBUGASSERT(done);
|
||||||
@@ -1892,7 +1892,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
|
|||||||
return snprintf(buffer, size, "yassl/%s", YASSL_VERSION);
|
return snprintf(buffer, size, "yassl/%s", YASSL_VERSION);
|
||||||
#else /* YASSL_VERSION */
|
#else /* YASSL_VERSION */
|
||||||
|
|
||||||
#if (SSLEAY_VERSION_NUMBER >= 0x905000)
|
#if(SSLEAY_VERSION_NUMBER >= 0x905000)
|
||||||
{
|
{
|
||||||
char sub[2];
|
char sub[2];
|
||||||
unsigned long ssleay_value;
|
unsigned long ssleay_value;
|
||||||
@@ -1919,7 +1919,7 @@ size_t Curl_ossl_version(char *buffer, size_t size)
|
|||||||
|
|
||||||
#else /* SSLEAY_VERSION_NUMBER is less than 0.9.5 */
|
#else /* SSLEAY_VERSION_NUMBER is less than 0.9.5 */
|
||||||
|
|
||||||
#if (SSLEAY_VERSION_NUMBER >= 0x900000)
|
#if(SSLEAY_VERSION_NUMBER >= 0x900000)
|
||||||
return snprintf(buffer, size, "OpenSSL/%lx.%lx.%lx",
|
return snprintf(buffer, size, "OpenSSL/%lx.%lx.%lx",
|
||||||
(SSLEAY_VERSION_NUMBER>>28)&0xff,
|
(SSLEAY_VERSION_NUMBER>>28)&0xff,
|
||||||
(SSLEAY_VERSION_NUMBER>>20)&0xff,
|
(SSLEAY_VERSION_NUMBER>>20)&0xff,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -30,12 +30,12 @@ char *curlx_strdup(const char *str)
|
|||||||
int len;
|
int len;
|
||||||
char *newstr;
|
char *newstr;
|
||||||
|
|
||||||
if (!str)
|
if(!str)
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
newstr = (char *) malloc((len+1)*sizeof(char));
|
newstr = (char *) malloc((len+1)*sizeof(char));
|
||||||
if (!newstr)
|
if(!newstr)
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
|
|
||||||
memcpy(newstr,str,(len+1)*sizeof(char));
|
memcpy(newstr,str,(len+1)*sizeof(char));
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ int curl_strequal(const char *first, const char *second)
|
|||||||
#elif defined(HAVE_STRICMP)
|
#elif defined(HAVE_STRICMP)
|
||||||
return !(stricmp)(first, second);
|
return !(stricmp)(first, second);
|
||||||
#else
|
#else
|
||||||
while (*first && *second) {
|
while(*first && *second) {
|
||||||
if (toupper(*first) != toupper(*second)) {
|
if(toupper(*first) != toupper(*second)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
first++;
|
first++;
|
||||||
@@ -72,8 +72,8 @@ int curl_strnequal(const char *first, const char *second, size_t max)
|
|||||||
#elif defined(HAVE_STRICMP)
|
#elif defined(HAVE_STRICMP)
|
||||||
return !strnicmp(first, second, max);
|
return !strnicmp(first, second, max);
|
||||||
#else
|
#else
|
||||||
while (*first && *second && max) {
|
while(*first && *second && max) {
|
||||||
if (toupper(*first) != toupper(*second)) {
|
if(toupper(*first) != toupper(*second)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
max--;
|
max--;
|
||||||
@@ -132,15 +132,15 @@ size_t Curl_strlcat(char *dst, const char *src, size_t siz)
|
|||||||
size_t dlen;
|
size_t dlen;
|
||||||
|
|
||||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||||
while (n-- != 0 && *d != '\0')
|
while(n-- != 0 && *d != '\0')
|
||||||
d++;
|
d++;
|
||||||
dlen = d - dst;
|
dlen = d - dst;
|
||||||
n = siz - dlen;
|
n = siz - dlen;
|
||||||
|
|
||||||
if (n == 0)
|
if(n == 0)
|
||||||
return(dlen + strlen(s));
|
return(dlen + strlen(s));
|
||||||
while (*s != '\0') {
|
while(*s != '\0') {
|
||||||
if (n != 1) {
|
if(n != 1) {
|
||||||
*d++ = *s;
|
*d++ = *s;
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ curl_easy_strerror(CURLcode error)
|
|||||||
*/
|
*/
|
||||||
return "Unknown error";
|
return "Unknown error";
|
||||||
#else
|
#else
|
||||||
if (error == CURLE_OK)
|
if(error == CURLE_OK)
|
||||||
return "No error";
|
return "No error";
|
||||||
else
|
else
|
||||||
return "Error";
|
return "Error";
|
||||||
@@ -336,7 +336,7 @@ curl_multi_strerror(CURLMcode error)
|
|||||||
|
|
||||||
return "Unknown error";
|
return "Unknown error";
|
||||||
#else
|
#else
|
||||||
if (error == CURLM_OK)
|
if(error == CURLM_OK)
|
||||||
return "No error";
|
return "No error";
|
||||||
else
|
else
|
||||||
return "Error";
|
return "Error";
|
||||||
@@ -369,7 +369,7 @@ curl_share_strerror(CURLSHcode error)
|
|||||||
|
|
||||||
return "CURLSHcode unknown";
|
return "CURLSHcode unknown";
|
||||||
#else
|
#else
|
||||||
if (error == CURLSHE_OK)
|
if(error == CURLSHE_OK)
|
||||||
return "No error";
|
return "No error";
|
||||||
else
|
else
|
||||||
return "Error";
|
return "Error";
|
||||||
@@ -555,7 +555,7 @@ get_winsock_error (int err, char *buf, size_t len)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (err == CURLE_OK)
|
if(err == CURLE_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
p = "error";
|
p = "error";
|
||||||
@@ -604,10 +604,10 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
|
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
|
||||||
if (err >= 0 && err < sys_nerr)
|
if(err >= 0 && err < sys_nerr)
|
||||||
strncpy(buf, strerror(err), max);
|
strncpy(buf, strerror(err), max);
|
||||||
else {
|
else {
|
||||||
if (!get_winsock_error(err, buf, max) &&
|
if(!get_winsock_error(err, buf, max) &&
|
||||||
!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
|
!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
|
||||||
LANG_NEUTRAL, buf, (DWORD)max, NULL))
|
LANG_NEUTRAL, buf, (DWORD)max, NULL))
|
||||||
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
|
snprintf(buf, max, "Unknown error %d (%#x)", err, err);
|
||||||
@@ -646,9 +646,9 @@ const char *Curl_strerror(struct connectdata *conn, int err)
|
|||||||
buf[max] = '\0'; /* make sure the string is zero terminated */
|
buf[max] = '\0'; /* make sure the string is zero terminated */
|
||||||
|
|
||||||
/* strip trailing '\r\n' or '\n'. */
|
/* strip trailing '\r\n' or '\n'. */
|
||||||
if ((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
|
if((p = strrchr(buf,'\n')) != NULL && (p - buf) >= 2)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if ((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
|
if((p = strrchr(buf,'\r')) != NULL && (p - buf) >= 1)
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@@ -716,12 +716,12 @@ const char *Curl_idn_strerror (struct connectdata *conn, int err)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((Idna_rc)err == IDNA_SUCCESS)
|
if((Idna_rc)err == IDNA_SUCCESS)
|
||||||
str = "No error";
|
str = "No error";
|
||||||
else
|
else
|
||||||
str = "Error";
|
str = "Error";
|
||||||
#endif
|
#endif
|
||||||
if (str)
|
if(str)
|
||||||
strncpy(buf, str, max);
|
strncpy(buf, str, max);
|
||||||
buf[max] = '\0';
|
buf[max] = '\0';
|
||||||
return (buf);
|
return (buf);
|
||||||
|
|||||||
12
lib/strtok.c
12
lib/strtok.c
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -32,15 +32,15 @@
|
|||||||
char *
|
char *
|
||||||
Curl_strtok_r(char *ptr, const char *sep, char **end)
|
Curl_strtok_r(char *ptr, const char *sep, char **end)
|
||||||
{
|
{
|
||||||
if (!ptr)
|
if(!ptr)
|
||||||
/* we got NULL input so then we get our last position instead */
|
/* we got NULL input so then we get our last position instead */
|
||||||
ptr = *end;
|
ptr = *end;
|
||||||
|
|
||||||
/* pass all letters that are including in the separator string */
|
/* pass all letters that are including in the separator string */
|
||||||
while (*ptr && strchr(sep, *ptr))
|
while(*ptr && strchr(sep, *ptr))
|
||||||
++ptr;
|
++ptr;
|
||||||
|
|
||||||
if (*ptr) {
|
if(*ptr) {
|
||||||
/* so this is where the next piece of string starts */
|
/* so this is where the next piece of string starts */
|
||||||
char *start = ptr;
|
char *start = ptr;
|
||||||
|
|
||||||
@@ -49,10 +49,10 @@ Curl_strtok_r(char *ptr, const char *sep, char **end)
|
|||||||
|
|
||||||
/* scan through the string to find where it ends, it ends on a
|
/* scan through the string to find where it ends, it ends on a
|
||||||
null byte or a character that exists in the separator string */
|
null byte or a character that exists in the separator string */
|
||||||
while (**end && !strchr(sep, **end))
|
while(**end && !strchr(sep, **end))
|
||||||
++*end;
|
++*end;
|
||||||
|
|
||||||
if (**end) {
|
if(**end) {
|
||||||
/* the end is not a null byte */
|
/* the end is not a null byte */
|
||||||
**end = '\0'; /* zero terminate it! */
|
**end = '\0'; /* zero terminate it! */
|
||||||
++*end; /* advance the last pointer to beyond the null byte */
|
++*end; /* advance the last pointer to beyond the null byte */
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/* Range tests can be used for alphanum decoding if characters are consecutive,
|
/* Range tests can be used for alphanum decoding if characters are consecutive,
|
||||||
like in ASCII. Else an array is scanned. Determine this condition now. */
|
like in ASCII. Else an array is scanned. Determine this condition now. */
|
||||||
|
|
||||||
#if ('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25
|
#if('9' - '0') != 9 || ('Z' - 'A') != 25 || ('z' - 'a') != 25
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define NO_RANGE_TEST
|
#define NO_RANGE_TEST
|
||||||
@@ -67,35 +67,35 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
|
|||||||
|
|
||||||
/* Skip leading whitespace. */
|
/* Skip leading whitespace. */
|
||||||
end = (char *)nptr;
|
end = (char *)nptr;
|
||||||
while (ISSPACE(end[0])) {
|
while(ISSPACE(end[0])) {
|
||||||
end++;
|
end++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the sign, if any. */
|
/* Handle the sign, if any. */
|
||||||
if (end[0] == '-') {
|
if(end[0] == '-') {
|
||||||
is_negative = 1;
|
is_negative = 1;
|
||||||
end++;
|
end++;
|
||||||
}
|
}
|
||||||
else if (end[0] == '+') {
|
else if(end[0] == '+') {
|
||||||
end++;
|
end++;
|
||||||
}
|
}
|
||||||
else if (end[0] == '\0') {
|
else if(end[0] == '\0') {
|
||||||
/* We had nothing but perhaps some whitespace -- there was no number. */
|
/* We had nothing but perhaps some whitespace -- there was no number. */
|
||||||
if (endptr) {
|
if(endptr) {
|
||||||
*endptr = end;
|
*endptr = end;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle special beginnings, if present and allowed. */
|
/* Handle special beginnings, if present and allowed. */
|
||||||
if (end[0] == '0' && end[1] == 'x') {
|
if(end[0] == '0' && end[1] == 'x') {
|
||||||
if (base == 16 || base == 0) {
|
if(base == 16 || base == 0) {
|
||||||
end += 2;
|
end += 2;
|
||||||
base = 16;
|
base = 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (end[0] == '0') {
|
else if(end[0] == '0') {
|
||||||
if (base == 8 || base == 0) {
|
if(base == 8 || base == 0) {
|
||||||
end++;
|
end++;
|
||||||
base = 8;
|
base = 8;
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
|
|||||||
/* Matching strtol, if the base is 0 and it doesn't look like
|
/* Matching strtol, if the base is 0 and it doesn't look like
|
||||||
* the number is octal or hex, we assume it's base 10.
|
* the number is octal or hex, we assume it's base 10.
|
||||||
*/
|
*/
|
||||||
if (base == 0) {
|
if(base == 0) {
|
||||||
base = 10;
|
base = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
|
|||||||
i != -1;
|
i != -1;
|
||||||
end++, i = get_char(end[0], base)) {
|
end++, i = get_char(end[0], base)) {
|
||||||
newval = base * value + i;
|
newval = base * value + i;
|
||||||
if (newval < value) {
|
if(newval < value) {
|
||||||
/* We've overflowed. */
|
/* We've overflowed. */
|
||||||
overflow = 1;
|
overflow = 1;
|
||||||
break;
|
break;
|
||||||
@@ -124,14 +124,14 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
|
|||||||
value = newval;
|
value = newval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!overflow) {
|
if(!overflow) {
|
||||||
if (is_negative) {
|
if(is_negative) {
|
||||||
/* Fix the sign. */
|
/* Fix the sign. */
|
||||||
value *= -1;
|
value *= -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_negative)
|
if(is_negative)
|
||||||
value = CURL_LLONG_MIN;
|
value = CURL_LLONG_MIN;
|
||||||
else
|
else
|
||||||
value = CURL_LLONG_MAX;
|
value = CURL_LLONG_MAX;
|
||||||
@@ -139,7 +139,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
|
|||||||
SET_ERRNO(ERANGE);
|
SET_ERRNO(ERANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endptr)
|
if(endptr)
|
||||||
*endptr = end;
|
*endptr = end;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@@ -159,13 +159,13 @@ static int get_char(char c, int base)
|
|||||||
{
|
{
|
||||||
#ifndef NO_RANGE_TEST
|
#ifndef NO_RANGE_TEST
|
||||||
int value = -1;
|
int value = -1;
|
||||||
if (c <= '9' && c >= '0') {
|
if(c <= '9' && c >= '0') {
|
||||||
value = c - '0';
|
value = c - '0';
|
||||||
}
|
}
|
||||||
else if (c <= 'Z' && c >= 'A') {
|
else if(c <= 'Z' && c >= 'A') {
|
||||||
value = c - 'A' + 10;
|
value = c - 'A' + 10;
|
||||||
}
|
}
|
||||||
else if (c <= 'z' && c >= 'a') {
|
else if(c <= 'z' && c >= 'a') {
|
||||||
value = c - 'a' + 10;
|
value = c - 'a' + 10;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -174,16 +174,16 @@ static int get_char(char c, int base)
|
|||||||
|
|
||||||
cp = memchr(valchars, c, 10 + 26 + 26);
|
cp = memchr(valchars, c, 10 + 26 + 26);
|
||||||
|
|
||||||
if (!cp)
|
if(!cp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
value = cp - valchars;
|
value = cp - valchars;
|
||||||
|
|
||||||
if (value >= 10 + 26)
|
if(value >= 10 + 26)
|
||||||
value -= 26; /* Lowercase. */
|
value -= 26; /* Lowercase. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (value >= base) {
|
if(value >= base) {
|
||||||
value = -1;
|
value = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
|
/* For MSVC7 we can use _strtoi64() which seems to be a strtoll() clone */
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||||
|
_CRTIMP __int64 __cdecl _strtoi64(const char *, char **, int); /* in <crt/stdlib.h> */
|
||||||
#define curlx_strtoofft _strtoi64
|
#define curlx_strtoofft _strtoi64
|
||||||
#else /* MSVC7 or later */
|
#else /* MSVC7 or later */
|
||||||
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
|
curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
|
||||||
|
|||||||
137
lib/telnet.c
137
lib/telnet.c
@@ -86,7 +86,7 @@
|
|||||||
#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer;
|
#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer;
|
||||||
#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); }
|
#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); }
|
||||||
#define CURL_SB_ACCUM(x,c) \
|
#define CURL_SB_ACCUM(x,c) \
|
||||||
if (x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
|
if(x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
|
||||||
*x->subpointer++ = (c); \
|
*x->subpointer++ = (c); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
|
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
|
||||||
|
|
||||||
#ifdef CURL_DISABLE_VERBOSE_STRINGS
|
#ifdef CURL_DISABLE_VERBOSE_STRINGS
|
||||||
#define printoption(a,b,c,d) do { } while (0)
|
#define printoption(a,b,c,d) do { } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
@@ -106,7 +106,7 @@ static CURLcode check_wsock2 ( struct SessionHandle *data );
|
|||||||
|
|
||||||
static
|
static
|
||||||
void telrcv(struct connectdata *,
|
void telrcv(struct connectdata *,
|
||||||
unsigned char *inbuf, /* Data received from socket */
|
const unsigned char *inbuf, /* Data received from socket */
|
||||||
ssize_t count); /* Number of bytes received */
|
ssize_t count); /* Number of bytes received */
|
||||||
|
|
||||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||||
@@ -213,7 +213,7 @@ check_wsock2 ( struct SessionHandle *data )
|
|||||||
|
|
||||||
/* We must've called this once already, so this call */
|
/* We must've called this once already, so this call */
|
||||||
/* should always succeed. But, just in case... */
|
/* should always succeed. But, just in case... */
|
||||||
if (err != 0) {
|
if(err != 0) {
|
||||||
failf(data,"WSAStartup failed (%d)",err);
|
failf(data,"WSAStartup failed (%d)",err);
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ check_wsock2 ( struct SessionHandle *data )
|
|||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
|
||||||
/* Check that our version is supported */
|
/* Check that our version is supported */
|
||||||
if (LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
|
if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
|
||||||
HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
|
HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
|
||||||
/* Our version isn't supported */
|
/* Our version isn't supported */
|
||||||
failf(data,"insufficient winsock version to support "
|
failf(data,"insufficient winsock version to support "
|
||||||
@@ -283,11 +283,11 @@ static void printoption(struct SessionHandle *data,
|
|||||||
const char *fmt;
|
const char *fmt;
|
||||||
const char *opt;
|
const char *opt;
|
||||||
|
|
||||||
if (data->set.verbose)
|
if(data->set.verbose)
|
||||||
{
|
{
|
||||||
if (cmd == CURL_IAC)
|
if(cmd == CURL_IAC)
|
||||||
{
|
{
|
||||||
if (CURL_TELCMD_OK(option))
|
if(CURL_TELCMD_OK(option))
|
||||||
infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option));
|
infof(data, "%s IAC %s\n", direction, CURL_TELCMD(option));
|
||||||
else
|
else
|
||||||
infof(data, "%s IAC %d\n", direction, option);
|
infof(data, "%s IAC %d\n", direction, option);
|
||||||
@@ -296,11 +296,11 @@ static void printoption(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
|
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
|
||||||
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
|
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
|
||||||
if (fmt)
|
if(fmt)
|
||||||
{
|
{
|
||||||
if (CURL_TELOPT_OK(option))
|
if(CURL_TELOPT_OK(option))
|
||||||
opt = CURL_TELOPT(option);
|
opt = CURL_TELOPT(option);
|
||||||
else if (option == CURL_TELOPT_EXOPL)
|
else if(option == CURL_TELOPT_EXOPL)
|
||||||
opt = "EXOPL";
|
opt = "EXOPL";
|
||||||
else
|
else
|
||||||
opt = NULL;
|
opt = NULL;
|
||||||
@@ -705,30 +705,30 @@ static void printsub(struct SessionHandle *data,
|
|||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
|
||||||
if (data->set.verbose)
|
if(data->set.verbose)
|
||||||
{
|
{
|
||||||
if (direction)
|
if(direction)
|
||||||
{
|
{
|
||||||
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
|
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
|
||||||
if (length >= 3)
|
if(length >= 3)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
i = pointer[length-2];
|
i = pointer[length-2];
|
||||||
j = pointer[length-1];
|
j = pointer[length-1];
|
||||||
|
|
||||||
if (i != CURL_IAC || j != CURL_SE)
|
if(i != CURL_IAC || j != CURL_SE)
|
||||||
{
|
{
|
||||||
infof(data, "(terminated by ");
|
infof(data, "(terminated by ");
|
||||||
if (CURL_TELOPT_OK(i))
|
if(CURL_TELOPT_OK(i))
|
||||||
infof(data, "%s ", CURL_TELOPT(i));
|
infof(data, "%s ", CURL_TELOPT(i));
|
||||||
else if (CURL_TELCMD_OK(i))
|
else if(CURL_TELCMD_OK(i))
|
||||||
infof(data, "%s ", CURL_TELCMD(i));
|
infof(data, "%s ", CURL_TELCMD(i));
|
||||||
else
|
else
|
||||||
infof(data, "%d ", i);
|
infof(data, "%d ", i);
|
||||||
if (CURL_TELOPT_OK(j))
|
if(CURL_TELOPT_OK(j))
|
||||||
infof(data, "%s", CURL_TELOPT(j));
|
infof(data, "%s", CURL_TELOPT(j));
|
||||||
else if (CURL_TELCMD_OK(j))
|
else if(CURL_TELCMD_OK(j))
|
||||||
infof(data, "%s", CURL_TELCMD(j));
|
infof(data, "%s", CURL_TELCMD(j));
|
||||||
else
|
else
|
||||||
infof(data, "%d", j);
|
infof(data, "%d", j);
|
||||||
@@ -737,13 +737,13 @@ static void printsub(struct SessionHandle *data,
|
|||||||
}
|
}
|
||||||
length -= 2;
|
length -= 2;
|
||||||
}
|
}
|
||||||
if (length < 1)
|
if(length < 1)
|
||||||
{
|
{
|
||||||
infof(data, "(Empty suboption?)");
|
infof(data, "(Empty suboption?)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CURL_TELOPT_OK(pointer[0])) {
|
if(CURL_TELOPT_OK(pointer[0])) {
|
||||||
switch(pointer[0]) {
|
switch(pointer[0]) {
|
||||||
case CURL_TELOPT_TTYPE:
|
case CURL_TELOPT_TTYPE:
|
||||||
case CURL_TELOPT_XDISPLOC:
|
case CURL_TELOPT_XDISPLOC:
|
||||||
@@ -803,7 +803,7 @@ static void printsub(struct SessionHandle *data,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction)
|
if(direction)
|
||||||
{
|
{
|
||||||
infof(data, "\n");
|
infof(data, "\n");
|
||||||
}
|
}
|
||||||
@@ -949,107 +949,122 @@ static void suboption(struct connectdata *conn)
|
|||||||
|
|
||||||
static
|
static
|
||||||
void telrcv(struct connectdata *conn,
|
void telrcv(struct connectdata *conn,
|
||||||
unsigned char *inbuf, /* Data received from socket */
|
const unsigned char *inbuf, /* Data received from socket */
|
||||||
ssize_t count) /* Number of bytes received */
|
ssize_t count) /* Number of bytes received */
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
int in = 0;
|
int in = 0;
|
||||||
|
int startwrite=-1;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet;
|
struct TELNET *tn = (struct TELNET *)data->reqdata.proto.telnet;
|
||||||
|
|
||||||
|
#define startskipping() \
|
||||||
|
if(startwrite >= 0) \
|
||||||
|
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&inbuf[startwrite], in-startwrite); \
|
||||||
|
startwrite = -1
|
||||||
|
|
||||||
|
#define writebyte() \
|
||||||
|
if(startwrite < 0) \
|
||||||
|
startwrite = in
|
||||||
|
|
||||||
|
#define bufferflush() startskipping()
|
||||||
|
|
||||||
while(count--)
|
while(count--)
|
||||||
{
|
{
|
||||||
c = inbuf[in++];
|
c = inbuf[in];
|
||||||
|
|
||||||
|
/*infof(data,"In rcv state %d char %d\n", tn->telrcv_state, c);*/
|
||||||
switch (tn->telrcv_state)
|
switch (tn->telrcv_state)
|
||||||
{
|
{
|
||||||
case CURL_TS_CR:
|
case CURL_TS_CR:
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
if (c == '\0')
|
if(c == '\0')
|
||||||
{
|
{
|
||||||
|
startskipping();
|
||||||
break; /* Ignore \0 after CR */
|
break; /* Ignore \0 after CR */
|
||||||
}
|
}
|
||||||
|
writebyte();
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);
|
break;
|
||||||
continue;
|
|
||||||
|
|
||||||
case CURL_TS_DATA:
|
case CURL_TS_DATA:
|
||||||
if (c == CURL_IAC)
|
if(c == CURL_IAC)
|
||||||
{
|
{
|
||||||
tn->telrcv_state = CURL_TS_IAC;
|
tn->telrcv_state = CURL_TS_IAC;
|
||||||
|
startskipping();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(c == '\r')
|
else if(c == '\r')
|
||||||
{
|
{
|
||||||
tn->telrcv_state = CURL_TS_CR;
|
tn->telrcv_state = CURL_TS_CR;
|
||||||
}
|
}
|
||||||
|
writebyte();
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);
|
break;
|
||||||
continue;
|
|
||||||
|
|
||||||
case CURL_TS_IAC:
|
case CURL_TS_IAC:
|
||||||
process_iac:
|
process_iac:
|
||||||
|
DEBUGASSERT(startwrite < 0);
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case CURL_WILL:
|
case CURL_WILL:
|
||||||
tn->telrcv_state = CURL_TS_WILL;
|
tn->telrcv_state = CURL_TS_WILL;
|
||||||
continue;
|
break;
|
||||||
case CURL_WONT:
|
case CURL_WONT:
|
||||||
tn->telrcv_state = CURL_TS_WONT;
|
tn->telrcv_state = CURL_TS_WONT;
|
||||||
continue;
|
break;
|
||||||
case CURL_DO:
|
case CURL_DO:
|
||||||
tn->telrcv_state = CURL_TS_DO;
|
tn->telrcv_state = CURL_TS_DO;
|
||||||
continue;
|
break;
|
||||||
case CURL_DONT:
|
case CURL_DONT:
|
||||||
tn->telrcv_state = CURL_TS_DONT;
|
tn->telrcv_state = CURL_TS_DONT;
|
||||||
continue;
|
break;
|
||||||
case CURL_SB:
|
case CURL_SB:
|
||||||
CURL_SB_CLEAR(tn);
|
CURL_SB_CLEAR(tn);
|
||||||
tn->telrcv_state = CURL_TS_SB;
|
tn->telrcv_state = CURL_TS_SB;
|
||||||
continue;
|
break;
|
||||||
case CURL_IAC:
|
case CURL_IAC:
|
||||||
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)&c, 1);
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
|
writebyte();
|
||||||
break;
|
break;
|
||||||
case CURL_DM:
|
case CURL_DM:
|
||||||
case CURL_NOP:
|
case CURL_NOP:
|
||||||
case CURL_GA:
|
case CURL_GA:
|
||||||
default:
|
default:
|
||||||
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
printoption(data, "RCVD", CURL_IAC, c);
|
printoption(data, "RCVD", CURL_IAC, c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
break;
|
||||||
continue;
|
|
||||||
|
|
||||||
case CURL_TS_WILL:
|
case CURL_TS_WILL:
|
||||||
printoption(data, "RCVD", CURL_WILL, c);
|
printoption(data, "RCVD", CURL_WILL, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_will(conn, c);
|
rec_will(conn, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case CURL_TS_WONT:
|
case CURL_TS_WONT:
|
||||||
printoption(data, "RCVD", CURL_WONT, c);
|
printoption(data, "RCVD", CURL_WONT, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_wont(conn, c);
|
rec_wont(conn, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case CURL_TS_DO:
|
case CURL_TS_DO:
|
||||||
printoption(data, "RCVD", CURL_DO, c);
|
printoption(data, "RCVD", CURL_DO, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_do(conn, c);
|
rec_do(conn, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case CURL_TS_DONT:
|
case CURL_TS_DONT:
|
||||||
printoption(data, "RCVD", CURL_DONT, c);
|
printoption(data, "RCVD", CURL_DONT, c);
|
||||||
tn->please_negotiate = 1;
|
tn->please_negotiate = 1;
|
||||||
rec_dont(conn, c);
|
rec_dont(conn, c);
|
||||||
tn->telrcv_state = CURL_TS_DATA;
|
tn->telrcv_state = CURL_TS_DATA;
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case CURL_TS_SB:
|
case CURL_TS_SB:
|
||||||
if (c == CURL_IAC)
|
if(c == CURL_IAC)
|
||||||
{
|
{
|
||||||
tn->telrcv_state = CURL_TS_SE;
|
tn->telrcv_state = CURL_TS_SE;
|
||||||
}
|
}
|
||||||
@@ -1057,12 +1072,12 @@ void telrcv(struct connectdata *conn,
|
|||||||
{
|
{
|
||||||
CURL_SB_ACCUM(tn,c);
|
CURL_SB_ACCUM(tn,c);
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
case CURL_TS_SE:
|
case CURL_TS_SE:
|
||||||
if (c != CURL_SE)
|
if(c != CURL_SE)
|
||||||
{
|
{
|
||||||
if (c != CURL_IAC)
|
if(c != CURL_IAC)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* This is an error. We only expect to get "IAC IAC" or "IAC SE".
|
* This is an error. We only expect to get "IAC IAC" or "IAC SE".
|
||||||
@@ -1097,7 +1112,9 @@ void telrcv(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++in;
|
||||||
}
|
}
|
||||||
|
bufferflush();
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode Curl_telnet_done(struct connectdata *conn,
|
static CURLcode Curl_telnet_done(struct connectdata *conn,
|
||||||
@@ -1143,7 +1160,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
char *buf = data->state.buffer;
|
char *buf = data->state.buffer;
|
||||||
struct TELNET *tn;
|
struct TELNET *tn;
|
||||||
|
|
||||||
*done = TRUE; /* uncontionally */
|
*done = TRUE; /* unconditionally */
|
||||||
|
|
||||||
code = init_telnet(conn);
|
code = init_telnet(conn);
|
||||||
if(code)
|
if(code)
|
||||||
@@ -1161,20 +1178,20 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
** make sure have it.
|
** make sure have it.
|
||||||
*/
|
*/
|
||||||
code = check_wsock2(data);
|
code = check_wsock2(data);
|
||||||
if (code)
|
if(code)
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
/* OK, so we have WinSock 2.0. We need to dynamically */
|
/* OK, so we have WinSock 2.0. We need to dynamically */
|
||||||
/* load ws2_32.dll and get the function pointers we need. */
|
/* load ws2_32.dll and get the function pointers we need. */
|
||||||
wsock2 = LoadLibrary("WS2_32.DLL");
|
wsock2 = LoadLibrary("WS2_32.DLL");
|
||||||
if (wsock2 == NULL) {
|
if(wsock2 == NULL) {
|
||||||
failf(data,"failed to load WS2_32.DLL (%d)", ERRNO);
|
failf(data,"failed to load WS2_32.DLL (%d)", ERRNO);
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab a pointer to WSACreateEvent */
|
/* Grab a pointer to WSACreateEvent */
|
||||||
create_event_func = GetProcAddress(wsock2,"WSACreateEvent");
|
create_event_func = GetProcAddress(wsock2,"WSACreateEvent");
|
||||||
if (create_event_func == NULL) {
|
if(create_event_func == NULL) {
|
||||||
failf(data,"failed to find WSACreateEvent function (%d)",
|
failf(data,"failed to find WSACreateEvent function (%d)",
|
||||||
ERRNO);
|
ERRNO);
|
||||||
FreeLibrary(wsock2);
|
FreeLibrary(wsock2);
|
||||||
@@ -1183,7 +1200,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
/* And WSACloseEvent */
|
/* And WSACloseEvent */
|
||||||
close_event_func = GetProcAddress(wsock2,"WSACloseEvent");
|
close_event_func = GetProcAddress(wsock2,"WSACloseEvent");
|
||||||
if (close_event_func == NULL) {
|
if(close_event_func == NULL) {
|
||||||
failf(data,"failed to find WSACloseEvent function (%d)",
|
failf(data,"failed to find WSACloseEvent function (%d)",
|
||||||
ERRNO);
|
ERRNO);
|
||||||
FreeLibrary(wsock2);
|
FreeLibrary(wsock2);
|
||||||
@@ -1192,7 +1209,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
/* And WSAEventSelect */
|
/* And WSAEventSelect */
|
||||||
event_select_func = GetProcAddress(wsock2,"WSAEventSelect");
|
event_select_func = GetProcAddress(wsock2,"WSAEventSelect");
|
||||||
if (event_select_func == NULL) {
|
if(event_select_func == NULL) {
|
||||||
failf(data,"failed to find WSAEventSelect function (%d)",
|
failf(data,"failed to find WSAEventSelect function (%d)",
|
||||||
ERRNO);
|
ERRNO);
|
||||||
FreeLibrary(wsock2);
|
FreeLibrary(wsock2);
|
||||||
@@ -1201,7 +1218,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
/* And WSAEnumNetworkEvents */
|
/* And WSAEnumNetworkEvents */
|
||||||
enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents");
|
enum_netevents_func = GetProcAddress(wsock2,"WSAEnumNetworkEvents");
|
||||||
if (enum_netevents_func == NULL) {
|
if(enum_netevents_func == NULL) {
|
||||||
failf(data,"failed to find WSAEnumNetworkEvents function (%d)",
|
failf(data,"failed to find WSAEnumNetworkEvents function (%d)",
|
||||||
ERRNO);
|
ERRNO);
|
||||||
FreeLibrary(wsock2);
|
FreeLibrary(wsock2);
|
||||||
@@ -1215,7 +1232,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
/* First, create a sockets event object */
|
/* First, create a sockets event object */
|
||||||
event_handle = (WSAEVENT)create_event_func();
|
event_handle = (WSAEVENT)create_event_func();
|
||||||
if (event_handle == WSA_INVALID_EVENT) {
|
if(event_handle == WSA_INVALID_EVENT) {
|
||||||
failf(data,"WSACreateEvent failed (%d)", SOCKERRNO);
|
failf(data,"WSACreateEvent failed (%d)", SOCKERRNO);
|
||||||
FreeLibrary(wsock2);
|
FreeLibrary(wsock2);
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
@@ -1343,7 +1360,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We called WSACreateEvent, so call WSACloseEvent */
|
/* We called WSACreateEvent, so call WSACloseEvent */
|
||||||
if (close_event_func(event_handle) == FALSE) {
|
if(close_event_func(event_handle) == FALSE) {
|
||||||
infof(data,"WSACloseEvent failed (%d)", SOCKERRNO);
|
infof(data,"WSACloseEvent failed (%d)", SOCKERRNO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1354,7 +1371,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
enum_netevents_func = NULL;
|
enum_netevents_func = NULL;
|
||||||
|
|
||||||
/* We called LoadLibrary, so call FreeLibrary */
|
/* We called LoadLibrary, so call FreeLibrary */
|
||||||
if (!FreeLibrary(wsock2))
|
if(!FreeLibrary(wsock2))
|
||||||
infof(data,"FreeLibrary(wsock2) failed (%d)", ERRNO);
|
infof(data,"FreeLibrary(wsock2) failed (%d)", ERRNO);
|
||||||
#else
|
#else
|
||||||
pfd[0].fd = sockfd;
|
pfd[0].fd = sockfd;
|
||||||
@@ -1363,7 +1380,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
pfd[1].events = POLLIN;
|
pfd[1].events = POLLIN;
|
||||||
interval_ms = 1 * 1000;
|
interval_ms = 1 * 1000;
|
||||||
|
|
||||||
while (keepon) {
|
while(keepon) {
|
||||||
switch (Curl_poll(pfd, 2, interval_ms)) {
|
switch (Curl_poll(pfd, 2, interval_ms)) {
|
||||||
case -1: /* error, stop reading */
|
case -1: /* error, stop reading */
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
@@ -1396,7 +1413,7 @@ static CURLcode Curl_telnet(struct connectdata *conn, bool *done)
|
|||||||
|
|
||||||
/* if we receive 0 or less here, the server closed the connection and
|
/* if we receive 0 or less here, the server closed the connection and
|
||||||
we bail out from this! */
|
we bail out from this! */
|
||||||
if (nread <= 0) {
|
if(nread <= 0) {
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
40
lib/tftp.c
40
lib/tftp.c
@@ -306,7 +306,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
|||||||
if(data->set.upload) {
|
if(data->set.upload) {
|
||||||
/* If we are uploading, send an WRQ */
|
/* If we are uploading, send an WRQ */
|
||||||
setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
|
setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
|
||||||
state->conn->data->reqdata.upload_fromhere = (char *)&state->spacket.data[4];
|
state->conn->data->reqdata.upload_fromhere =
|
||||||
|
(char *)&state->spacket.data[4];
|
||||||
if(data->set.infilesize != -1)
|
if(data->set.infilesize != -1)
|
||||||
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
Curl_pgrsSetUploadSize(data, data->set.infilesize);
|
||||||
}
|
}
|
||||||
@@ -318,7 +319,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
|||||||
file name so we skip the always-present first letter of the path string. */
|
file name so we skip the always-present first letter of the path string. */
|
||||||
filename = curl_easy_unescape(data, &state->conn->data->reqdata.path[1], 0,
|
filename = curl_easy_unescape(data, &state->conn->data->reqdata.path[1], 0,
|
||||||
NULL);
|
NULL);
|
||||||
if (!filename)
|
if(!filename)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
snprintf((char *)&state->spacket.data[2],
|
snprintf((char *)&state->spacket.data[2],
|
||||||
@@ -377,12 +378,12 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
|
|||||||
|
|
||||||
/* Is this the block we expect? */
|
/* Is this the block we expect? */
|
||||||
rblock = getrpacketblock(&state->rpacket);
|
rblock = getrpacketblock(&state->rpacket);
|
||||||
if ((state->block+1) != rblock) {
|
if((state->block+1) != rblock) {
|
||||||
/* No, log it, up the retry count and fail if over the limit */
|
/* No, log it, up the retry count and fail if over the limit */
|
||||||
infof(data,
|
infof(data,
|
||||||
"Received unexpected DATA packet block %d\n", rblock);
|
"Received unexpected DATA packet block %d\n", rblock);
|
||||||
state->retries++;
|
state->retries++;
|
||||||
if (state->retries>state->retry_max) {
|
if(state->retries>state->retry_max) {
|
||||||
failf(data, "tftp_rx: giving up waiting for block %d\n",
|
failf(data, "tftp_rx: giving up waiting for block %d\n",
|
||||||
state->block+1);
|
state->block+1);
|
||||||
return CURLE_TFTP_ILLEGAL;
|
return CURLE_TFTP_ILLEGAL;
|
||||||
@@ -403,7 +404,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if completed (That is, a less than full packet is received) */
|
/* Check if completed (That is, a less than full packet is received) */
|
||||||
if (state->rbytes < (int)sizeof(state->spacket)){
|
if(state->rbytes < (int)sizeof(state->spacket)){
|
||||||
state->state = TFTP_STATE_FIN;
|
state->state = TFTP_STATE_FIN;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -698,8 +699,7 @@ static CURLcode Curl_tftp_done(struct connectdata *conn, CURLcode status,
|
|||||||
static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
tftp_state_data_t *state =
|
tftp_state_data_t *state;
|
||||||
(tftp_state_data_t *) conn->data->reqdata.proto.tftp;
|
|
||||||
tftp_event_t event;
|
tftp_event_t event;
|
||||||
CURLcode code;
|
CURLcode code;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -716,16 +716,14 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
|||||||
make sure we have a good 'struct TFTP' to play with. For new connections,
|
make sure we have a good 'struct TFTP' to play with. For new connections,
|
||||||
the struct TFTP is allocated and setup in the Curl_tftp_connect() function.
|
the struct TFTP is allocated and setup in the Curl_tftp_connect() function.
|
||||||
*/
|
*/
|
||||||
if(!state) {
|
Curl_reset_reqproto(conn);
|
||||||
|
|
||||||
|
if(!data->reqdata.proto.tftp) {
|
||||||
code = Curl_tftp_connect(conn, done);
|
code = Curl_tftp_connect(conn, done);
|
||||||
if(code)
|
if(code)
|
||||||
return code;
|
return code;
|
||||||
state = (tftp_state_data_t *)conn->data->reqdata.proto.tftp;
|
|
||||||
}
|
}
|
||||||
|
state = (tftp_state_data_t *)data->reqdata.proto.tftp;
|
||||||
code = Curl_readwrite_init(conn);
|
|
||||||
if(code)
|
|
||||||
return code;
|
|
||||||
|
|
||||||
/* Run the TFTP State Machine */
|
/* Run the TFTP State Machine */
|
||||||
for(code=tftp_state_machine(state, TFTP_EVENT_INIT);
|
for(code=tftp_state_machine(state, TFTP_EVENT_INIT);
|
||||||
@@ -742,7 +740,7 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
|||||||
failf(data, "%s\n", Curl_strerror(conn, error));
|
failf(data, "%s\n", Curl_strerror(conn, error));
|
||||||
event = TFTP_EVENT_ERROR;
|
event = TFTP_EVENT_ERROR;
|
||||||
}
|
}
|
||||||
else if (rc==0) {
|
else if(rc==0) {
|
||||||
/* A timeout occured */
|
/* A timeout occured */
|
||||||
event = TFTP_EVENT_TIMEOUT;
|
event = TFTP_EVENT_TIMEOUT;
|
||||||
|
|
||||||
@@ -763,8 +761,8 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity check packet length */
|
/* Sanity check packet length */
|
||||||
if (state->rbytes < 4) {
|
if(state->rbytes < 4) {
|
||||||
failf(conn->data, "Received too short packet\n");
|
failf(data, "Received too short packet\n");
|
||||||
/* Not a timeout, but how best to handle it? */
|
/* Not a timeout, but how best to handle it? */
|
||||||
event = TFTP_EVENT_TIMEOUT;
|
event = TFTP_EVENT_TIMEOUT;
|
||||||
}
|
}
|
||||||
@@ -776,7 +774,7 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
|||||||
switch(event) {
|
switch(event) {
|
||||||
case TFTP_EVENT_DATA:
|
case TFTP_EVENT_DATA:
|
||||||
/* Don't pass to the client empty or retransmitted packets */
|
/* Don't pass to the client empty or retransmitted packets */
|
||||||
if (state->rbytes > 4 &&
|
if(state->rbytes > 4 &&
|
||||||
((state->block+1) == getrpacketblock(&state->rpacket))) {
|
((state->block+1) == getrpacketblock(&state->rpacket))) {
|
||||||
code = Curl_client_write(conn, CLIENTWRITE_BODY,
|
code = Curl_client_write(conn, CLIENTWRITE_BODY,
|
||||||
(char *)&state->rpacket.data[4],
|
(char *)&state->rpacket.data[4],
|
||||||
@@ -789,14 +787,14 @@ static CURLcode Curl_tftp(struct connectdata *conn, bool *done)
|
|||||||
break;
|
break;
|
||||||
case TFTP_EVENT_ERROR:
|
case TFTP_EVENT_ERROR:
|
||||||
state->error = (tftp_error_t)getrpacketblock(&state->rpacket);
|
state->error = (tftp_error_t)getrpacketblock(&state->rpacket);
|
||||||
infof(conn->data, "%s\n", (char *)&state->rpacket.data[4]);
|
infof(data, "%s\n", (char *)&state->rpacket.data[4]);
|
||||||
break;
|
break;
|
||||||
case TFTP_EVENT_ACK:
|
case TFTP_EVENT_ACK:
|
||||||
break;
|
break;
|
||||||
case TFTP_EVENT_RRQ:
|
case TFTP_EVENT_RRQ:
|
||||||
case TFTP_EVENT_WRQ:
|
case TFTP_EVENT_WRQ:
|
||||||
default:
|
default:
|
||||||
failf(conn->data, "%s\n", "Internal error: Unexpected packet");
|
failf(data, "%s\n", "Internal error: Unexpected packet");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -882,10 +880,10 @@ static CURLcode Curl_tftp_setup_connection(struct connectdata * conn)
|
|||||||
* we'll try to get now! */
|
* we'll try to get now! */
|
||||||
type = strstr(data->reqdata.path, ";mode=");
|
type = strstr(data->reqdata.path, ";mode=");
|
||||||
|
|
||||||
if (!type)
|
if(!type)
|
||||||
type = strstr(conn->host.rawalloc, ";mode=");
|
type = strstr(conn->host.rawalloc, ";mode=");
|
||||||
|
|
||||||
if (type) {
|
if(type) {
|
||||||
*type = 0; /* it was in the middle of the hostname */
|
*type = 0; /* it was in the middle of the hostname */
|
||||||
command = (char) toupper((int) type[6]);
|
command = (char) toupper((int) type[6]);
|
||||||
|
|
||||||
|
|||||||
335
lib/transfer.c
335
lib/transfer.c
@@ -128,7 +128,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
|||||||
/* this function returns a size_t, so we typecast to int to prevent warnings
|
/* this function returns a size_t, so we typecast to int to prevent warnings
|
||||||
with picky compilers */
|
with picky compilers */
|
||||||
nread = (int)conn->fread_func(data->reqdata.upload_fromhere, 1,
|
nread = (int)conn->fread_func(data->reqdata.upload_fromhere, 1,
|
||||||
buffersize, conn->fread_in);
|
buffersize, conn->fread_in);
|
||||||
|
|
||||||
if(nread == CURL_READFUNC_ABORT) {
|
if(nread == CURL_READFUNC_ABORT) {
|
||||||
failf(data, "operation aborted by callback\n");
|
failf(data, "operation aborted by callback\n");
|
||||||
@@ -188,12 +188,12 @@ checkhttpprefix(struct SessionHandle *data,
|
|||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
/* convert from the network encoding using a scratch area */
|
/* convert from the network encoding using a scratch area */
|
||||||
char *scratch = calloc(1, strlen(s)+1);
|
char *scratch = calloc(1, strlen(s)+1);
|
||||||
if (NULL == scratch) {
|
if(NULL == scratch) {
|
||||||
failf (data, "Failed to calloc memory for conversion!");
|
failf (data, "Failed to calloc memory for conversion!");
|
||||||
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
|
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
|
||||||
}
|
}
|
||||||
strcpy(scratch, s);
|
strcpy(scratch, s);
|
||||||
if (CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
|
if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
|
||||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||||
free(scratch);
|
free(scratch);
|
||||||
return FALSE; /* can't return CURLE_foobar so return FALSE */
|
return FALSE; /* can't return CURLE_foobar so return FALSE */
|
||||||
@@ -201,15 +201,15 @@ checkhttpprefix(struct SessionHandle *data,
|
|||||||
s = scratch;
|
s = scratch;
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
while (head) {
|
while(head) {
|
||||||
if (checkprefix(head->data, s)) {
|
if(checkprefix(head->data, s)) {
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
head = head->next;
|
head = head->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc != TRUE) && (checkprefix("HTTP/", s))) {
|
if((rc != TRUE) && (checkprefix("HTTP/", s))) {
|
||||||
rc = TRUE;
|
rc = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ static void read_rewind(struct connectdata *conn,
|
|||||||
size_t show;
|
size_t show;
|
||||||
|
|
||||||
show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
|
show = MIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
|
||||||
if (conn->master_buffer) {
|
if(conn->master_buffer) {
|
||||||
memcpy(buf, conn->master_buffer + conn->read_pos, show);
|
memcpy(buf, conn->master_buffer + conn->read_pos, show);
|
||||||
buf[show] = '\0';
|
buf[show] = '\0';
|
||||||
}
|
}
|
||||||
@@ -333,7 +333,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
if((k->keepon & (KEEP_READ|KEEP_READ_HOLD)) == KEEP_READ) {
|
if((k->keepon & (KEEP_READ|KEEP_READ_HOLD)) == KEEP_READ) {
|
||||||
fd_read = conn->sockfd;
|
fd_read = conn->sockfd;
|
||||||
#if defined(USE_LIBSSH2)
|
#if defined(USE_LIBSSH2)
|
||||||
if (conn->protocol & (PROT_SCP|PROT_SFTP))
|
if(conn->protocol & (PROT_SCP|PROT_SFTP))
|
||||||
select_res |= CURL_CSELECT_IN;
|
select_res |= CURL_CSELECT_IN;
|
||||||
#endif /* USE_LIBSSH2 */
|
#endif /* USE_LIBSSH2 */
|
||||||
} else
|
} else
|
||||||
@@ -344,7 +344,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
else
|
else
|
||||||
fd_write = CURL_SOCKET_BAD;
|
fd_write = CURL_SOCKET_BAD;
|
||||||
|
|
||||||
if (!select_res) { /* Call for select()/poll() only, if read/write/error
|
if(!select_res) { /* Call for select()/poll() only, if read/write/error
|
||||||
status is not known. */
|
status is not known. */
|
||||||
select_res = Curl_socket_ready(fd_read, fd_write, 0);
|
select_res = Curl_socket_ready(fd_read, fd_write, 0);
|
||||||
}
|
}
|
||||||
@@ -371,7 +371,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
size_t bytestoread = buffersize;
|
size_t bytestoread = buffersize;
|
||||||
int readrc;
|
int readrc;
|
||||||
|
|
||||||
if (k->size != -1 && !k->header) {
|
if(k->size != -1 && !k->header) {
|
||||||
/* make sure we don't read "too much" if we can help it since we
|
/* make sure we don't read "too much" if we can help it since we
|
||||||
might be pipelining and then someone else might want to read what
|
might be pipelining and then someone else might want to read what
|
||||||
follows! */
|
follows! */
|
||||||
@@ -393,7 +393,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
if(result>0)
|
if(result>0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if ((k->bytecount == 0) && (k->writebytecount == 0)) {
|
if((k->bytecount == 0) && (k->writebytecount == 0)) {
|
||||||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||||
if(k->wait100_after_headers)
|
if(k->wait100_after_headers)
|
||||||
/* set time stamp to compare with when waiting for the 100 */
|
/* set time stamp to compare with when waiting for the 100 */
|
||||||
@@ -405,10 +405,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0));
|
is_empty_data = (bool)((nread == 0) && (k->bodywrites == 0));
|
||||||
|
|
||||||
/* NULL terminate, allowing string ops to be used */
|
/* NULL terminate, allowing string ops to be used */
|
||||||
if (0 < nread || is_empty_data) {
|
if(0 < nread || is_empty_data) {
|
||||||
k->buf[nread] = 0;
|
k->buf[nread] = 0;
|
||||||
}
|
}
|
||||||
else if (0 >= nread) {
|
else if(0 >= nread) {
|
||||||
/* if we receive 0 or less here, the server closed the connection
|
/* if we receive 0 or less here, the server closed the connection
|
||||||
and we bail out from this! */
|
and we bail out from this! */
|
||||||
DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
|
DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
|
||||||
@@ -422,7 +422,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
|
|
||||||
/* Since this is a two-state thing, we check if we are parsing
|
/* Since this is a two-state thing, we check if we are parsing
|
||||||
headers at the moment or not. */
|
headers at the moment or not. */
|
||||||
if (k->header) {
|
if(k->header) {
|
||||||
/* we are in parse-the-header-mode */
|
/* we are in parse-the-header-mode */
|
||||||
bool stop_reading = FALSE;
|
bool stop_reading = FALSE;
|
||||||
|
|
||||||
@@ -439,11 +439,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* data is in network encoding so use 0x0a instead of '\n' */
|
/* data is in network encoding so use 0x0a instead of '\n' */
|
||||||
k->end_ptr = memchr(k->str_start, 0x0a, nread);
|
k->end_ptr = memchr(k->str_start, 0x0a, nread);
|
||||||
|
|
||||||
if (!k->end_ptr) {
|
if(!k->end_ptr) {
|
||||||
/* Not a complete header line within buffer, append the data to
|
/* Not a complete header line within buffer, append the data to
|
||||||
the end of the headerbuff. */
|
the end of the headerbuff. */
|
||||||
|
|
||||||
if (k->hbuflen + nread >= data->state.headersize) {
|
if(k->hbuflen + nread >= data->state.headersize) {
|
||||||
/* We enlarge the header buffer as it is too small */
|
/* We enlarge the header buffer as it is too small */
|
||||||
char *newbuff;
|
char *newbuff;
|
||||||
size_t newsize=CURLMAX((k->hbuflen+nread)*3/2,
|
size_t newsize=CURLMAX((k->hbuflen+nread)*3/2,
|
||||||
@@ -461,7 +461,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
memcpy(k->hbufp, k->str, nread);
|
memcpy(k->hbufp, k->str, nread);
|
||||||
k->hbufp += nread;
|
k->hbufp += nread;
|
||||||
k->hbuflen += nread;
|
k->hbuflen += nread;
|
||||||
if (!k->headerline && (k->hbuflen>5)) {
|
if(!k->headerline && (k->hbuflen>5)) {
|
||||||
/* make a first check that this looks like a HTTP header */
|
/* make a first check that this looks like a HTTP header */
|
||||||
if(!checkhttpprefix(data, data->state.headerbuff)) {
|
if(!checkhttpprefix(data, data->state.headerbuff)) {
|
||||||
/* this is not the beginning of a HTTP first header line */
|
/* this is not the beginning of a HTTP first header line */
|
||||||
@@ -488,7 +488,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
* fit in the allocated header buffer, or else we enlarge
|
* fit in the allocated header buffer, or else we enlarge
|
||||||
* it.
|
* it.
|
||||||
*/
|
*/
|
||||||
if (k->hbuflen + full_length >=
|
if(k->hbuflen + full_length >=
|
||||||
data->state.headersize) {
|
data->state.headersize) {
|
||||||
char *newbuff;
|
char *newbuff;
|
||||||
size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2,
|
size_t newsize=CURLMAX((k->hbuflen+full_length)*3/2,
|
||||||
@@ -537,23 +537,23 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
|
|
||||||
/* headers are in network encoding so
|
/* headers are in network encoding so
|
||||||
use 0x0a and 0x0d instead of '\n' and '\r' */
|
use 0x0a and 0x0d instead of '\n' and '\r' */
|
||||||
if ((0x0a == *k->p) || (0x0d == *k->p)) {
|
if((0x0a == *k->p) || (0x0d == *k->p)) {
|
||||||
size_t headerlen;
|
size_t headerlen;
|
||||||
/* Zero-length header line means end of headers! */
|
/* Zero-length header line means end of headers! */
|
||||||
|
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
if (0x0d == *k->p) {
|
if(0x0d == *k->p) {
|
||||||
*k->p = '\r'; /* replace with CR in host encoding */
|
*k->p = '\r'; /* replace with CR in host encoding */
|
||||||
k->p++; /* pass the CR byte */
|
k->p++; /* pass the CR byte */
|
||||||
}
|
}
|
||||||
if (0x0a == *k->p) {
|
if(0x0a == *k->p) {
|
||||||
*k->p = '\n'; /* replace with LF in host encoding */
|
*k->p = '\n'; /* replace with LF in host encoding */
|
||||||
k->p++; /* pass the LF byte */
|
k->p++; /* pass the LF byte */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ('\r' == *k->p)
|
if('\r' == *k->p)
|
||||||
k->p++; /* pass the \r byte */
|
k->p++; /* pass the \r byte */
|
||||||
if ('\n' == *k->p)
|
if('\n' == *k->p)
|
||||||
k->p++; /* pass the \n byte */
|
k->p++; /* pass the \n byte */
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
k->header = TRUE;
|
k->header = TRUE;
|
||||||
k->headerline = 0; /* restart the header line counter */
|
k->headerline = 0; /* restart the header line counter */
|
||||||
/* if we did wait for this do enable write now! */
|
/* if we did wait for this do enable write now! */
|
||||||
if (k->write_after_100_header) {
|
if(k->write_after_100_header) {
|
||||||
|
|
||||||
k->write_after_100_header = FALSE;
|
k->write_after_100_header = FALSE;
|
||||||
k->keepon |= KEEP_WRITE;
|
k->keepon |= KEEP_WRITE;
|
||||||
@@ -590,7 +590,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (417 == k->httpcode) {
|
if(417 == k->httpcode) {
|
||||||
/*
|
/*
|
||||||
* we got: "417 Expectation Failed" this means:
|
* we got: "417 Expectation Failed" this means:
|
||||||
* we have made a HTTP call and our Expect Header
|
* we have made a HTTP call and our Expect Header
|
||||||
@@ -606,7 +606,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
* When all the headers have been parsed, see if we should give
|
* When all the headers have been parsed, see if we should give
|
||||||
* up and return an error.
|
* up and return an error.
|
||||||
*/
|
*/
|
||||||
if (Curl_http_should_fail(conn)) {
|
if(Curl_http_should_fail(conn)) {
|
||||||
failf (data, "The requested URL returned error: %d",
|
failf (data, "The requested URL returned error: %d",
|
||||||
k->httpcode);
|
k->httpcode);
|
||||||
return CURLE_HTTP_RETURNED_ERROR;
|
return CURLE_HTTP_RETURNED_ERROR;
|
||||||
@@ -616,7 +616,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* now, only output this if the header AND body are requested:
|
/* now, only output this if the header AND body are requested:
|
||||||
*/
|
*/
|
||||||
writetype = CLIENTWRITE_HEADER;
|
writetype = CLIENTWRITE_HEADER;
|
||||||
if (data->set.include_header)
|
if(data->set.include_header)
|
||||||
writetype |= CLIENTWRITE_BODY;
|
writetype |= CLIENTWRITE_BODY;
|
||||||
|
|
||||||
headerlen = k->p - data->state.headerbuff;
|
headerlen = k->p - data->state.headerbuff;
|
||||||
@@ -633,7 +633,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
data->reqdata.keep.deductheadercount =
|
data->reqdata.keep.deductheadercount =
|
||||||
(100 == k->httpcode)?data->reqdata.keep.headerbytecount:0;
|
(100 == k->httpcode)?data->reqdata.keep.headerbytecount:0;
|
||||||
|
|
||||||
if (data->reqdata.resume_from &&
|
if(data->reqdata.resume_from &&
|
||||||
(data->set.httpreq==HTTPREQ_GET) &&
|
(data->set.httpreq==HTTPREQ_GET) &&
|
||||||
(k->httpcode == 416)) {
|
(k->httpcode == 416)) {
|
||||||
/* "Requested Range Not Satisfiable" */
|
/* "Requested Range Not Satisfiable" */
|
||||||
@@ -721,7 +721,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
* Checks for special headers coming up.
|
* Checks for special headers coming up.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!k->headerline++) {
|
if(!k->headerline++) {
|
||||||
/* This is the first header, it MUST be the error code line
|
/* This is the first header, it MUST be the error code line
|
||||||
or else we consider this to be the body right away! */
|
or else we consider this to be the body right away! */
|
||||||
int httpversion_major;
|
int httpversion_major;
|
||||||
@@ -741,7 +741,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
res = Curl_convert_from_network(data,
|
res = Curl_convert_from_network(data,
|
||||||
&scratch[0],
|
&scratch[0],
|
||||||
SCRATCHSIZE);
|
SCRATCHSIZE);
|
||||||
if (CURLE_OK != res) {
|
if(CURLE_OK != res) {
|
||||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -754,7 +754,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
&httpversion_major,
|
&httpversion_major,
|
||||||
&k->httpversion,
|
&k->httpversion,
|
||||||
&k->httpcode);
|
&k->httpcode);
|
||||||
if (nc==3) {
|
if(nc==3) {
|
||||||
k->httpversion += 10 * httpversion_major;
|
k->httpversion += 10 * httpversion_major;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -767,8 +767,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* If user has set option HTTP200ALIASES,
|
/* If user has set option HTTP200ALIASES,
|
||||||
compare header line against list of aliases
|
compare header line against list of aliases
|
||||||
*/
|
*/
|
||||||
if (!nc) {
|
if(!nc) {
|
||||||
if (checkhttpprefix(data, k->p)) {
|
if(checkhttpprefix(data, k->p)) {
|
||||||
nc = 1;
|
nc = 1;
|
||||||
k->httpcode = 200;
|
k->httpcode = 200;
|
||||||
k->httpversion = 10;
|
k->httpversion = 10;
|
||||||
@@ -776,7 +776,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nc) {
|
if(nc) {
|
||||||
data->info.httpcode = k->httpcode;
|
data->info.httpcode = k->httpcode;
|
||||||
data->info.httpversion = k->httpversion;
|
data->info.httpversion = k->httpversion;
|
||||||
|
|
||||||
@@ -788,11 +788,11 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
* depending on how authentication is working. Other codes
|
* depending on how authentication is working. Other codes
|
||||||
* are definitely errors, so give up here.
|
* are definitely errors, so give up here.
|
||||||
*/
|
*/
|
||||||
if (data->set.http_fail_on_error && (k->httpcode >= 400) &&
|
if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
|
||||||
((k->httpcode != 401) || !conn->bits.user_passwd) &&
|
((k->httpcode != 401) || !conn->bits.user_passwd) &&
|
||||||
((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
|
((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
|
||||||
|
|
||||||
if (data->reqdata.resume_from &&
|
if(data->reqdata.resume_from &&
|
||||||
(data->set.httpreq==HTTPREQ_GET) &&
|
(data->set.httpreq==HTTPREQ_GET) &&
|
||||||
(k->httpcode == 416)) {
|
(k->httpcode == 416)) {
|
||||||
/* "Requested Range Not Satisfiable", just proceed and
|
/* "Requested Range Not Satisfiable", just proceed and
|
||||||
@@ -848,7 +848,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
/* convert from the network encoding */
|
/* convert from the network encoding */
|
||||||
result = Curl_convert_from_network(data, k->p, strlen(k->p));
|
result = Curl_convert_from_network(data, k->p, strlen(k->p));
|
||||||
if (CURLE_OK != result) {
|
if(CURLE_OK != result) {
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||||
@@ -858,10 +858,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
the header completely if we get a 416 response as then we're
|
the header completely if we get a 416 response as then we're
|
||||||
resuming a document that we don't get, and this header contains
|
resuming a document that we don't get, and this header contains
|
||||||
info about the true size of the document we didn't get now. */
|
info about the true size of the document we didn't get now. */
|
||||||
if (!k->ignorecl && !data->set.ignorecl &&
|
if(!k->ignorecl && !data->set.ignorecl &&
|
||||||
checkprefix("Content-Length:", k->p)) {
|
checkprefix("Content-Length:", k->p)) {
|
||||||
contentlength = curlx_strtoofft(k->p+15, NULL, 10);
|
contentlength = curlx_strtoofft(k->p+15, NULL, 10);
|
||||||
if (data->set.max_filesize &&
|
if(data->set.max_filesize &&
|
||||||
contentlength > data->set.max_filesize) {
|
contentlength > data->set.max_filesize) {
|
||||||
failf(data, "Maximum file size exceeded");
|
failf(data, "Maximum file size exceeded");
|
||||||
return CURLE_FILESIZE_EXCEEDED;
|
return CURLE_FILESIZE_EXCEEDED;
|
||||||
@@ -884,7 +884,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* check for Content-Type: header lines to get the mime-type */
|
/* check for Content-Type: header lines to get the mime-type */
|
||||||
else if (checkprefix("Content-Type:", k->p)) {
|
else if(checkprefix("Content-Type:", k->p)) {
|
||||||
char *start;
|
char *start;
|
||||||
char *end;
|
char *end;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -913,7 +913,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
Curl_safefree(data->info.contenttype);
|
Curl_safefree(data->info.contenttype);
|
||||||
|
|
||||||
data->info.contenttype = malloc(len + 1);
|
data->info.contenttype = malloc(len + 1);
|
||||||
if (NULL == data->info.contenttype)
|
if(NULL == data->info.contenttype)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
/* copy the content-type string */
|
/* copy the content-type string */
|
||||||
@@ -957,7 +957,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
conn->bits.close = FALSE; /* don't close when done */
|
conn->bits.close = FALSE; /* don't close when done */
|
||||||
infof(data, "HTTP/1.0 connection set to keep alive!\n");
|
infof(data, "HTTP/1.0 connection set to keep alive!\n");
|
||||||
}
|
}
|
||||||
else if (Curl_compareheader(k->p, "Connection:", "close")) {
|
else if(Curl_compareheader(k->p, "Connection:", "close")) {
|
||||||
/*
|
/*
|
||||||
* [RFC 2616, section 8.1.2.1]
|
* [RFC 2616, section 8.1.2.1]
|
||||||
* "Connection: close" is HTTP/1.1 language and means that
|
* "Connection: close" is HTTP/1.1 language and means that
|
||||||
@@ -966,7 +966,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
conn->bits.close = TRUE; /* close when done */
|
conn->bits.close = TRUE; /* close when done */
|
||||||
}
|
}
|
||||||
else if (Curl_compareheader(k->p,
|
else if(Curl_compareheader(k->p,
|
||||||
"Transfer-Encoding:", "chunked")) {
|
"Transfer-Encoding:", "chunked")) {
|
||||||
/*
|
/*
|
||||||
* [RFC 2616, section 3.6.1] A 'chunked' transfer encoding
|
* [RFC 2616, section 3.6.1] A 'chunked' transfer encoding
|
||||||
@@ -982,7 +982,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
Curl_httpchunk_init(conn);
|
Curl_httpchunk_init(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (checkprefix("Trailer:", k->p) ||
|
else if(checkprefix("Trailer:", k->p) ||
|
||||||
checkprefix("Trailers:", k->p)) {
|
checkprefix("Trailers:", k->p)) {
|
||||||
/*
|
/*
|
||||||
* This test helps Curl_httpchunk_read() to determine to look
|
* This test helps Curl_httpchunk_read() to determine to look
|
||||||
@@ -992,10 +992,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
*
|
*
|
||||||
* It seems both Trailer: and Trailers: occur in the wild.
|
* It seems both Trailer: and Trailers: occur in the wild.
|
||||||
*/
|
*/
|
||||||
conn->bits.trailerHdrPresent = TRUE;
|
conn->bits.trailerhdrpresent = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (checkprefix("Content-Encoding:", k->p) &&
|
else if(checkprefix("Content-Encoding:", k->p) &&
|
||||||
data->set.str[STRING_ENCODING]) {
|
data->set.str[STRING_ENCODING]) {
|
||||||
/*
|
/*
|
||||||
* Process Content-Encoding. Look for the values: identity,
|
* Process Content-Encoding. Look for the values: identity,
|
||||||
@@ -1013,18 +1013,18 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
; /* empty loop */
|
; /* empty loop */
|
||||||
|
|
||||||
/* Record the content-encoding for later use */
|
/* Record the content-encoding for later use */
|
||||||
if (checkprefix("identity", start))
|
if(checkprefix("identity", start))
|
||||||
k->content_encoding = IDENTITY;
|
k->content_encoding = IDENTITY;
|
||||||
else if (checkprefix("deflate", start))
|
else if(checkprefix("deflate", start))
|
||||||
k->content_encoding = DEFLATE;
|
k->content_encoding = DEFLATE;
|
||||||
else if (checkprefix("gzip", start)
|
else if(checkprefix("gzip", start)
|
||||||
|| checkprefix("x-gzip", start))
|
|| checkprefix("x-gzip", start))
|
||||||
k->content_encoding = GZIP;
|
k->content_encoding = GZIP;
|
||||||
else if (checkprefix("compress", start)
|
else if(checkprefix("compress", start)
|
||||||
|| checkprefix("x-compress", start))
|
|| checkprefix("x-compress", start))
|
||||||
k->content_encoding = COMPRESS;
|
k->content_encoding = COMPRESS;
|
||||||
}
|
}
|
||||||
else if (checkprefix("Content-Range:", k->p)) {
|
else if(checkprefix("Content-Range:", k->p)) {
|
||||||
/* Content-Range: bytes [num]-
|
/* Content-Range: bytes [num]-
|
||||||
Content-Range: bytes: [num]-
|
Content-Range: bytes: [num]-
|
||||||
Content-Range: [num]-
|
Content-Range: [num]-
|
||||||
@@ -1042,7 +1042,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
|
|
||||||
k->offset = curlx_strtoofft(ptr, NULL, 10);
|
k->offset = curlx_strtoofft(ptr, NULL, 10);
|
||||||
|
|
||||||
if (data->reqdata.resume_from == k->offset)
|
if(data->reqdata.resume_from == k->offset)
|
||||||
/* we asked for a resume and we got it */
|
/* we asked for a resume and we got it */
|
||||||
k->content_range = TRUE;
|
k->content_range = TRUE;
|
||||||
}
|
}
|
||||||
@@ -1077,7 +1077,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if ((k->httpcode >= 300 && k->httpcode < 400) &&
|
else if((k->httpcode >= 300 && k->httpcode < 400) &&
|
||||||
checkprefix("Location:", k->p)) {
|
checkprefix("Location:", k->p)) {
|
||||||
if(data->set.http_follow_location) {
|
if(data->set.http_follow_location) {
|
||||||
/* this is the URL that the server advices us to get instead */
|
/* this is the URL that the server advices us to get instead */
|
||||||
@@ -1119,7 +1119,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
writetype = CLIENTWRITE_HEADER;
|
writetype = CLIENTWRITE_HEADER;
|
||||||
if (data->set.include_header)
|
if(data->set.include_header)
|
||||||
writetype |= CLIENTWRITE_BODY;
|
writetype |= CLIENTWRITE_BODY;
|
||||||
|
|
||||||
if(data->set.verbose)
|
if(data->set.verbose)
|
||||||
@@ -1137,7 +1137,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
k->hbufp = data->state.headerbuff;
|
k->hbufp = data->state.headerbuff;
|
||||||
k->hbuflen = 0;
|
k->hbuflen = 0;
|
||||||
}
|
}
|
||||||
while (!stop_reading && *k->str); /* header line within buffer */
|
while(!stop_reading && *k->str); /* header line within buffer */
|
||||||
|
|
||||||
if(stop_reading)
|
if(stop_reading)
|
||||||
/* We've stopped dealing with input, get out of the do-while loop */
|
/* We've stopped dealing with input, get out of the do-while loop */
|
||||||
@@ -1152,7 +1152,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* This is not an 'else if' since it may be a rest from the header
|
/* This is not an 'else if' since it may be a rest from the header
|
||||||
parsing, where the beginning of the buffer is headers and the end
|
parsing, where the beginning of the buffer is headers and the end
|
||||||
is non-headers. */
|
is non-headers. */
|
||||||
if (k->str && !k->header && (nread > 0 || is_empty_data)) {
|
if(k->str && !k->header && (nread > 0 || is_empty_data)) {
|
||||||
|
|
||||||
if(0 == k->bodywrites && !is_empty_data) {
|
if(0 == k->bodywrites && !is_empty_data) {
|
||||||
/* These checks are only made the first time we are about to
|
/* These checks are only made the first time we are about to
|
||||||
@@ -1160,7 +1160,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
if(conn->protocol&PROT_HTTP) {
|
if(conn->protocol&PROT_HTTP) {
|
||||||
/* HTTP-only checks */
|
/* HTTP-only checks */
|
||||||
|
|
||||||
if (data->reqdata.newurl) {
|
if(data->reqdata.newurl) {
|
||||||
if(conn->bits.close) {
|
if(conn->bits.close) {
|
||||||
/* Abort after the headers if "follow Location" is set
|
/* Abort after the headers if "follow Location" is set
|
||||||
and we're set to close anyway. */
|
and we're set to close anyway. */
|
||||||
@@ -1174,7 +1174,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
k->ignorebody = TRUE;
|
k->ignorebody = TRUE;
|
||||||
infof(data, "Ignoring the response-body\n");
|
infof(data, "Ignoring the response-body\n");
|
||||||
}
|
}
|
||||||
if (data->reqdata.resume_from && !k->content_range &&
|
if(data->reqdata.resume_from && !k->content_range &&
|
||||||
(data->set.httpreq==HTTPREQ_GET) &&
|
(data->set.httpreq==HTTPREQ_GET) &&
|
||||||
!k->ignorebody) {
|
!k->ignorebody) {
|
||||||
/* we wanted to resume a download, although the server doesn't
|
/* we wanted to resume a download, although the server doesn't
|
||||||
@@ -1263,7 +1263,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
Push it back to be read on the next pass. */
|
Push it back to be read on the next pass. */
|
||||||
|
|
||||||
dataleft = conn->chunk.dataleft;
|
dataleft = conn->chunk.dataleft;
|
||||||
if (dataleft != 0) {
|
if(dataleft != 0) {
|
||||||
infof(conn->data, "Leftovers after chunking. "
|
infof(conn->data, "Leftovers after chunking. "
|
||||||
" Rewinding %d bytes\n",dataleft);
|
" Rewinding %d bytes\n",dataleft);
|
||||||
read_rewind(conn, dataleft);
|
read_rewind(conn, dataleft);
|
||||||
@@ -1278,7 +1278,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* The 'excess' amount below can't be more than BUFSIZE which
|
/* The 'excess' amount below can't be more than BUFSIZE which
|
||||||
always will fit in a size_t */
|
always will fit in a size_t */
|
||||||
size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
|
size_t excess = (size_t)(k->bytecount + nread - k->maxdownload);
|
||||||
if (excess > 0 && !k->ignorebody) {
|
if(excess > 0 && !k->ignorebody) {
|
||||||
infof(data,
|
infof(data,
|
||||||
"Rewinding stream by : %d"
|
"Rewinding stream by : %d"
|
||||||
" bytes on url %s (size = %" FORMAT_OFF_T
|
" bytes on url %s (size = %" FORMAT_OFF_T
|
||||||
@@ -1360,9 +1360,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* if (! header and data to read ) */
|
} /* if(! header and data to read ) */
|
||||||
|
|
||||||
if (is_empty_data) {
|
if(is_empty_data) {
|
||||||
/* if we received nothing, the server closed the connection and we
|
/* if we received nothing, the server closed the connection and we
|
||||||
are done */
|
are done */
|
||||||
k->keepon &= ~KEEP_READ;
|
k->keepon &= ~KEEP_READ;
|
||||||
@@ -1381,7 +1381,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
bool writedone=TRUE;
|
bool writedone=TRUE;
|
||||||
|
|
||||||
if ((k->bytecount == 0) && (k->writebytecount == 0))
|
if((k->bytecount == 0) && (k->writebytecount == 0))
|
||||||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||||
|
|
||||||
didwhat |= KEEP_WRITE;
|
didwhat |= KEEP_WRITE;
|
||||||
@@ -1427,7 +1427,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
|
|
||||||
/* the signed int typecase of nread of for systems that has
|
/* the signed int typecase of nread of for systems that has
|
||||||
unsigned size_t */
|
unsigned size_t */
|
||||||
if (nread<=0) {
|
if(nread<=0) {
|
||||||
/* done */
|
/* done */
|
||||||
k->keepon &= ~KEEP_WRITE; /* we're done writing */
|
k->keepon &= ~KEEP_WRITE; /* we're done writing */
|
||||||
writedone = TRUE;
|
writedone = TRUE;
|
||||||
@@ -1446,9 +1446,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
/* convert LF to CRLF if so asked */
|
/* convert LF to CRLF if so asked */
|
||||||
#ifdef CURL_DO_LINEEND_CONV
|
#ifdef CURL_DO_LINEEND_CONV
|
||||||
/* always convert if we're FTPing in ASCII mode */
|
/* always convert if we're FTPing in ASCII mode */
|
||||||
if ((data->set.crlf) || (data->set.prefer_ascii)) {
|
if((data->set.crlf) || (data->set.prefer_ascii)) {
|
||||||
#else
|
#else
|
||||||
if (data->set.crlf) {
|
if(data->set.crlf) {
|
||||||
#endif /* CURL_DO_LINEEND_CONV */
|
#endif /* CURL_DO_LINEEND_CONV */
|
||||||
if(data->state.scratch == NULL)
|
if(data->state.scratch == NULL)
|
||||||
data->state.scratch = malloc(2*BUFSIZE);
|
data->state.scratch = malloc(2*BUFSIZE);
|
||||||
@@ -1463,10 +1463,10 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
* must be used instead of the escape sequences \r & \n.
|
* must be used instead of the escape sequences \r & \n.
|
||||||
*/
|
*/
|
||||||
for(i = 0, si = 0; i < nread; i++, si++) {
|
for(i = 0, si = 0; i < nread; i++, si++) {
|
||||||
if (data->reqdata.upload_fromhere[i] == 0x0a) {
|
if(data->reqdata.upload_fromhere[i] == 0x0a) {
|
||||||
data->state.scratch[si++] = 0x0d;
|
data->state.scratch[si++] = 0x0d;
|
||||||
data->state.scratch[si] = 0x0a;
|
data->state.scratch[si] = 0x0a;
|
||||||
if (!data->set.crlf) {
|
if(!data->set.crlf) {
|
||||||
/* we're here only because FTP is in ASCII mode...
|
/* we're here only because FTP is in ASCII mode...
|
||||||
bump infilesize for the LF we just added */
|
bump infilesize for the LF we just added */
|
||||||
data->set.infilesize++;
|
data->set.infilesize++;
|
||||||
@@ -1550,7 +1550,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* no read no write, this is a timeout? */
|
/* no read no write, this is a timeout? */
|
||||||
if (k->write_after_100_header) {
|
if(k->write_after_100_header) {
|
||||||
/* This should allow some time for the header to arrive, but only a
|
/* This should allow some time for the header to arrive, but only a
|
||||||
very short time as otherwise it'll be too much wasted times too
|
very short time as otherwise it'll be too much wasted times too
|
||||||
often. */
|
often. */
|
||||||
@@ -1577,12 +1577,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
result = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
result = Curl_speedcheck(data, k->now);
|
result = Curl_speedcheck(data, k->now);
|
||||||
if (result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (data->set.timeout &&
|
if(data->set.timeout &&
|
||||||
(Curl_tvdiff(k->now, k->start) >= data->set.timeout)) {
|
(Curl_tvdiff(k->now, k->start) >= data->set.timeout)) {
|
||||||
if (k->size != -1) {
|
if(k->size != -1) {
|
||||||
failf(data, "Operation timed out after %ld milliseconds with %"
|
failf(data, "Operation timed out after %ld milliseconds with %"
|
||||||
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
|
FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
|
||||||
data->set.timeout, k->bytecount, k->size);
|
data->set.timeout, k->bytecount, k->size);
|
||||||
@@ -1640,102 +1640,6 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Curl_readwrite_init() inits the readwrite session. This is inited each time
|
|
||||||
* for a transfer, sometimes multiple times on the same SessionHandle
|
|
||||||
*/
|
|
||||||
|
|
||||||
CURLcode Curl_readwrite_init(struct connectdata *conn)
|
|
||||||
{
|
|
||||||
struct SessionHandle *data = conn->data;
|
|
||||||
struct Curl_transfer_keeper *k = &data->reqdata.keep;
|
|
||||||
|
|
||||||
/* NB: the content encoding software depends on this initialization of
|
|
||||||
Curl_transfer_keeper.*/
|
|
||||||
memset(k, 0, sizeof(struct Curl_transfer_keeper));
|
|
||||||
|
|
||||||
k->start = Curl_tvnow(); /* start time */
|
|
||||||
k->now = k->start; /* current time is now */
|
|
||||||
k->header = TRUE; /* assume header */
|
|
||||||
k->httpversion = -1; /* unknown at this point */
|
|
||||||
|
|
||||||
k->size = data->reqdata.size;
|
|
||||||
k->maxdownload = data->reqdata.maxdownload;
|
|
||||||
k->bytecountp = data->reqdata.bytecountp;
|
|
||||||
k->writebytecountp = data->reqdata.writebytecountp;
|
|
||||||
|
|
||||||
k->bytecount = 0;
|
|
||||||
|
|
||||||
k->buf = data->state.buffer;
|
|
||||||
k->uploadbuf = data->state.uploadbuffer;
|
|
||||||
k->maxfd = (conn->sockfd>conn->writesockfd?
|
|
||||||
conn->sockfd:conn->writesockfd)+1;
|
|
||||||
k->hbufp = data->state.headerbuff;
|
|
||||||
k->ignorebody=FALSE;
|
|
||||||
|
|
||||||
Curl_pgrsTime(data, TIMER_PRETRANSFER);
|
|
||||||
Curl_speedinit(data);
|
|
||||||
|
|
||||||
Curl_pgrsSetUploadCounter(data, 0);
|
|
||||||
Curl_pgrsSetDownloadCounter(data, 0);
|
|
||||||
|
|
||||||
if (!conn->bits.getheader) {
|
|
||||||
k->header = FALSE;
|
|
||||||
if(k->size > 0)
|
|
||||||
Curl_pgrsSetDownloadSize(data, k->size);
|
|
||||||
}
|
|
||||||
/* we want header and/or body, if neither then don't do this! */
|
|
||||||
if(conn->bits.getheader || !conn->bits.no_body) {
|
|
||||||
|
|
||||||
if(conn->sockfd != CURL_SOCKET_BAD) {
|
|
||||||
k->keepon |= KEEP_READ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(conn->writesockfd != CURL_SOCKET_BAD) {
|
|
||||||
/* HTTP 1.1 magic:
|
|
||||||
|
|
||||||
Even if we require a 100-return code before uploading data, we might
|
|
||||||
need to write data before that since the REQUEST may not have been
|
|
||||||
finished sent off just yet.
|
|
||||||
|
|
||||||
Thus, we must check if the request has been sent before we set the
|
|
||||||
state info where we wait for the 100-return code
|
|
||||||
*/
|
|
||||||
if (data->state.expect100header &&
|
|
||||||
(data->reqdata.proto.http->sending == HTTPSEND_BODY)) {
|
|
||||||
/* wait with write until we either got 100-continue or a timeout */
|
|
||||||
k->write_after_100_header = TRUE;
|
|
||||||
k->start100 = k->start;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(data->state.expect100header)
|
|
||||||
/* when we've sent off the rest of the headers, we must await a
|
|
||||||
100-continue */
|
|
||||||
k->wait100_after_headers = TRUE;
|
|
||||||
k->keepon |= KEEP_WRITE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CURLE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Curl_readwrite may get called multiple times. This function is called
|
|
||||||
* immediately before the first Curl_readwrite. Note that this can't be moved
|
|
||||||
* to Curl_readwrite_init since that function can get called while another
|
|
||||||
* pipeline request is in the middle of receiving data.
|
|
||||||
*
|
|
||||||
* We init chunking and trailer bits to their default values here immediately
|
|
||||||
* before receiving any header data for the current request in the pipeline.
|
|
||||||
*/
|
|
||||||
void Curl_pre_readwrite(struct connectdata *conn)
|
|
||||||
{
|
|
||||||
conn->bits.chunk=FALSE;
|
|
||||||
conn->bits.trailerHdrPresent=FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Curl_single_getsock() gets called by the multi interface code when the app
|
* Curl_single_getsock() gets called by the multi interface code when the app
|
||||||
* has requested to get the sockets for the current connection. This function
|
* has requested to get the sockets for the current connection. This function
|
||||||
@@ -1757,6 +1661,9 @@ int Curl_single_getsock(const struct connectdata *conn,
|
|||||||
return GETSOCK_BLANK;
|
return GETSOCK_BLANK;
|
||||||
|
|
||||||
if(data->reqdata.keep.keepon & KEEP_READ) {
|
if(data->reqdata.keep.keepon & KEEP_READ) {
|
||||||
|
|
||||||
|
DEBUGASSERT(conn->sockfd != CURL_SOCKET_BAD);
|
||||||
|
|
||||||
bitmap |= GETSOCK_READSOCK(sockindex);
|
bitmap |= GETSOCK_READSOCK(sockindex);
|
||||||
sock[sockindex] = conn->sockfd;
|
sock[sockindex] = conn->sockfd;
|
||||||
}
|
}
|
||||||
@@ -1769,6 +1676,9 @@ int Curl_single_getsock(const struct connectdata *conn,
|
|||||||
one, we increase index */
|
one, we increase index */
|
||||||
if(data->reqdata.keep.keepon & KEEP_READ)
|
if(data->reqdata.keep.keepon & KEEP_READ)
|
||||||
sockindex++; /* increase index if we need two entries */
|
sockindex++; /* increase index if we need two entries */
|
||||||
|
|
||||||
|
DEBUGASSERT(conn->writesockfd != CURL_SOCKET_BAD);
|
||||||
|
|
||||||
sock[sockindex] = conn->writesockfd;
|
sock[sockindex] = conn->writesockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1801,15 +1711,6 @@ Transfer(struct connectdata *conn)
|
|||||||
struct Curl_transfer_keeper *k = &data->reqdata.keep;
|
struct Curl_transfer_keeper *k = &data->reqdata.keep;
|
||||||
bool done=FALSE;
|
bool done=FALSE;
|
||||||
|
|
||||||
if(!(conn->protocol & (PROT_FILE|PROT_TFTP))) {
|
|
||||||
/* Only do this if we are not transferring FILE or TFTP, since those
|
|
||||||
transfers are treated differently. They do their entire transfers in
|
|
||||||
the DO function and just returns from this. That is ugly indeed.
|
|
||||||
*/
|
|
||||||
Curl_readwrite_init(conn);
|
|
||||||
Curl_pre_readwrite(conn);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((conn->sockfd == CURL_SOCKET_BAD) &&
|
if((conn->sockfd == CURL_SOCKET_BAD) &&
|
||||||
(conn->writesockfd == CURL_SOCKET_BAD))
|
(conn->writesockfd == CURL_SOCKET_BAD))
|
||||||
/* nothing to read, nothing to write, we're already OK! */
|
/* nothing to read, nothing to write, we're already OK! */
|
||||||
@@ -1819,14 +1720,14 @@ Transfer(struct connectdata *conn)
|
|||||||
if(!conn->bits.getheader && conn->bits.no_body)
|
if(!conn->bits.getheader && conn->bits.no_body)
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
while (!done) {
|
while(!done) {
|
||||||
curl_socket_t fd_read;
|
curl_socket_t fd_read;
|
||||||
curl_socket_t fd_write;
|
curl_socket_t fd_write;
|
||||||
|
|
||||||
/* limit-rate logic: if speed exceeds threshold, then do not include fd in
|
/* limit-rate logic: if speed exceeds threshold, then do not include fd in
|
||||||
select set. The current speed is recalculated in each Curl_readwrite()
|
select set. The current speed is recalculated in each Curl_readwrite()
|
||||||
call */
|
call */
|
||||||
if ((k->keepon & KEEP_WRITE) &&
|
if((k->keepon & KEEP_WRITE) &&
|
||||||
(!data->set.max_send_speed ||
|
(!data->set.max_send_speed ||
|
||||||
(data->progress.ulspeed < data->set.max_send_speed) )) {
|
(data->progress.ulspeed < data->set.max_send_speed) )) {
|
||||||
fd_write = conn->writesockfd;
|
fd_write = conn->writesockfd;
|
||||||
@@ -1838,7 +1739,7 @@ Transfer(struct connectdata *conn)
|
|||||||
k->keepon |= KEEP_WRITE_HOLD; /* hold it */
|
k->keepon |= KEEP_WRITE_HOLD; /* hold it */
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((k->keepon & KEEP_READ) &&
|
if((k->keepon & KEEP_READ) &&
|
||||||
(!data->set.max_recv_speed ||
|
(!data->set.max_recv_speed ||
|
||||||
(data->progress.dlspeed < data->set.max_recv_speed)) ) {
|
(data->progress.dlspeed < data->set.max_recv_speed)) ) {
|
||||||
fd_read = conn->sockfd;
|
fd_read = conn->sockfd;
|
||||||
@@ -2034,7 +1935,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
|
|||||||
char *newest;
|
char *newest;
|
||||||
|
|
||||||
if(!retry) {
|
if(!retry) {
|
||||||
if ((data->set.maxredirs != -1) &&
|
if((data->set.maxredirs != -1) &&
|
||||||
(data->set.followlocation >= data->set.maxredirs)) {
|
(data->set.followlocation >= data->set.maxredirs)) {
|
||||||
failf(data,"Maximum (%d) redirects followed", data->set.maxredirs);
|
failf(data,"Maximum (%d) redirects followed", data->set.maxredirs);
|
||||||
return CURLE_TOO_MANY_REDIRECTS;
|
return CURLE_TOO_MANY_REDIRECTS;
|
||||||
@@ -2350,7 +2251,7 @@ Curl_connect_host(struct SessionHandle *data,
|
|||||||
the Curl_connect(), we detect it here and act as if we are redirected
|
the Curl_connect(), we detect it here and act as if we are redirected
|
||||||
to the new URL */
|
to the new URL */
|
||||||
urlchanged = data->change.url_changed;
|
urlchanged = data->change.url_changed;
|
||||||
if ((CURLE_OK == res) && urlchanged) {
|
if((CURLE_OK == res) && urlchanged) {
|
||||||
res = Curl_done(conn, res, FALSE);
|
res = Curl_done(conn, res, FALSE);
|
||||||
if(CURLE_OK == res) {
|
if(CURLE_OK == res) {
|
||||||
char *gotourl = strdup(data->change.url);
|
char *gotourl = strdup(data->change.url);
|
||||||
@@ -2359,7 +2260,7 @@ Curl_connect_host(struct SessionHandle *data,
|
|||||||
free(gotourl);
|
free(gotourl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (urlchanged && res == CURLE_OK);
|
} while(urlchanged && res == CURLE_OK);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -2523,25 +2424,23 @@ CURLcode Curl_perform(struct SessionHandle *data)
|
|||||||
*/
|
*/
|
||||||
CURLcode
|
CURLcode
|
||||||
Curl_setup_transfer(
|
Curl_setup_transfer(
|
||||||
struct connectdata *c_conn, /* connection data */
|
struct connectdata *conn, /* connection data */
|
||||||
int sockindex, /* socket index to read from or -1 */
|
int sockindex, /* socket index to read from or -1 */
|
||||||
curl_off_t size, /* -1 if unknown at this point */
|
curl_off_t size, /* -1 if unknown at this point */
|
||||||
bool getheader, /* TRUE if header parsing is wanted */
|
bool getheader, /* TRUE if header parsing is wanted */
|
||||||
curl_off_t *bytecountp, /* return number of bytes read or NULL */
|
curl_off_t *bytecountp, /* return number of bytes read or NULL */
|
||||||
int writesockindex, /* socket index to write to, it may very
|
int writesockindex, /* socket index to write to, it may very well be
|
||||||
well be the same we read from. -1
|
the same we read from. -1 disables */
|
||||||
disables */
|
curl_off_t *writecountp /* return number of bytes written or NULL */
|
||||||
curl_off_t *writecountp /* return number of bytes written or
|
)
|
||||||
NULL */
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
struct connectdata *conn = (struct connectdata *)c_conn;
|
|
||||||
struct SessionHandle *data;
|
struct SessionHandle *data;
|
||||||
|
struct Curl_transfer_keeper *k;
|
||||||
|
|
||||||
if(!conn)
|
DEBUGASSERT(conn != NULL);
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
|
||||||
|
|
||||||
data = conn->data;
|
data = conn->data;
|
||||||
|
k = &data->reqdata.keep;
|
||||||
|
|
||||||
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
|
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
|
||||||
|
|
||||||
@@ -2556,5 +2455,47 @@ Curl_setup_transfer(
|
|||||||
data->reqdata.bytecountp = bytecountp;
|
data->reqdata.bytecountp = bytecountp;
|
||||||
data->reqdata.writebytecountp = writecountp;
|
data->reqdata.writebytecountp = writecountp;
|
||||||
|
|
||||||
|
/* The code sequence below is placed in this function just because all
|
||||||
|
necessary input is not always known in do_complete() as this function may
|
||||||
|
be called after that */
|
||||||
|
|
||||||
|
if(!conn->bits.getheader) {
|
||||||
|
k->header = FALSE;
|
||||||
|
if(k->size > 0)
|
||||||
|
Curl_pgrsSetDownloadSize(data, k->size);
|
||||||
|
}
|
||||||
|
/* we want header and/or body, if neither then don't do this! */
|
||||||
|
if(conn->bits.getheader || !conn->bits.no_body) {
|
||||||
|
|
||||||
|
if(conn->sockfd != CURL_SOCKET_BAD) {
|
||||||
|
k->keepon |= KEEP_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(conn->writesockfd != CURL_SOCKET_BAD) {
|
||||||
|
/* HTTP 1.1 magic:
|
||||||
|
|
||||||
|
Even if we require a 100-return code before uploading data, we might
|
||||||
|
need to write data before that since the REQUEST may not have been
|
||||||
|
finished sent off just yet.
|
||||||
|
|
||||||
|
Thus, we must check if the request has been sent before we set the
|
||||||
|
state info where we wait for the 100-return code
|
||||||
|
*/
|
||||||
|
if(data->state.expect100header &&
|
||||||
|
(data->reqdata.proto.http->sending == HTTPSEND_BODY)) {
|
||||||
|
/* wait with write until we either got 100-continue or a timeout */
|
||||||
|
k->write_after_100_header = TRUE;
|
||||||
|
k->start100 = k->start;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(data->state.expect100header)
|
||||||
|
/* when we've sent off the rest of the headers, we must await a
|
||||||
|
100-continue */
|
||||||
|
k->wait100_after_headers = TRUE;
|
||||||
|
k->keepon |= KEEP_WRITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ CURLcode Curl_readwrite(struct connectdata *conn, bool *done);
|
|||||||
int Curl_single_getsock(const struct connectdata *conn,
|
int Curl_single_getsock(const struct connectdata *conn,
|
||||||
curl_socket_t *socks,
|
curl_socket_t *socks,
|
||||||
int numsocks);
|
int numsocks);
|
||||||
CURLcode Curl_readwrite_init(struct connectdata *conn);
|
|
||||||
void Curl_pre_readwrite(struct connectdata *conn);
|
|
||||||
CURLcode Curl_readrewind(struct connectdata *conn);
|
CURLcode Curl_readrewind(struct connectdata *conn);
|
||||||
CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp);
|
CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp);
|
||||||
bool Curl_retry_request(struct connectdata *conn, char **url);
|
bool Curl_retry_request(struct connectdata *conn, char **url);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user