Skip to content

Commit

Permalink
Patched the Darwin, Schannel and OpenSSL interfaces. Also adjusted in…
Browse files Browse the repository at this point in the history
… the curl tool sets a CURLOPT_SSL_VERIFYHOST of value 0.
  • Loading branch information
okoeroo committed Nov 6, 2012
2 parents c70617a + da82f59 commit 9d3e503
Show file tree
Hide file tree
Showing 34 changed files with 438 additions and 173 deletions.
28 changes: 24 additions & 4 deletions RELEASE-NOTES
Expand Up @@ -9,11 +9,23 @@ Curl and libcurl 7.28.1

This release includes the following changes:

o
o metalink/md5: Use CommonCrypto on Apple operating systems
o href_extractor: new example code extracting href elements

This release includes the following bugfixes:

o
o Fix broken libmetalink-aware OpenSSL build
o gnutls: put reset code into else block [1]
o darwinssl: un-broke iOS build, fix error on server disconnect
o asyn-ares: restore functionality with c-ares < 1.6.1 [2]
o tlsauthtype: deal with the string case insensitively [3]
o Fixed MSVC libssh2 static build
o evhiperfifo: fix the pointer passed to WRITEDATA [6]
o BUGS: fix the bug tracker URL [4]
o winbuild: Use machine type of development environment
o FTP: prevent the multi interface from blocking [5]
o uniformly use AM_CPPFLAGS, avoid deprecated INCLUDES
o httpcustomheader.c: free the headers after use

This release includes the following known bugs:

Expand All @@ -22,9 +34,17 @@ This release includes the following known bugs:
This release would not have looked like this without help, code, reports and
advice from friends like these:


Guenter Knauf, Alessandro Ghedini, Nick Zitzmann, Michal Kowalczyk,
Jeff Connelly, Oscar Norlander, Guido Berhoerster, Marc Hoersken,
Dave Reisner, Jan Ehrhardt

Thanks! (and sorry if I forgot to mention someone)

References to bug reports and discussions on issues:


[1] = http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=690551
[2] = http://curl.haxx.se/bug/view.cgi?id=3577710
[3] = http://curl.haxx.se/bug/view.cgi?id=3578418
[4] = http://curl.haxx.se/bug/view.cgi?id=3582408
[5] = http://curl.haxx.se/bug/view.cgi?id=3579064
[6] = http://curl.haxx.se/bug/view.cgi?id=3582407
6 changes: 4 additions & 2 deletions docs/BUGS
Expand Up @@ -35,9 +35,11 @@ BUGS
have a go at a solution. You can optionally also post your bug/problem at
curl's bug tracking system over at

http://sourceforge.net/bugs/?group_id=976
http://sourceforge.net/tracker/?group_id=976&atid=100976

(but please read the sections below first before doing that)
Please read the rest of this document below first before doing that! Also,
you need to login to your sourceforge account before being able to submit a
bug report (necessary evil done to avoid spam).

If you feel you need to ask around first, find a suitable mailing list and
post there. The lists are available on http://curl.haxx.se/mail/
Expand Down
9 changes: 4 additions & 5 deletions docs/examples/Makefile.am
Expand Up @@ -34,14 +34,13 @@ EXTRA_DIST = README Makefile.example Makefile.inc Makefile.m32 \
# $(top_builddir)/include for generated curlbuild.h included from lib/setup.h
# $(top_srcdir)/include is for libcurl's external include files

INCLUDES = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-DCURL_NO_OLDIES

LIBDIR = $(top_builddir)/lib

AM_CPPFLAGS = -DCURL_NO_OLDIES

# Mostly for Windows build targets, when using static libcurl
if USE_CPPFLAG_CURL_STATICLIB
AM_CPPFLAGS += -DCURL_STATICLIB
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/evhiperfifo.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -336,7 +336,7 @@ static void new_conn(char *url, GlobalInfo *g )
conn->url = strdup(url);
curl_easy_setopt(conn->easy, CURLOPT_URL, conn->url);
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, &conn);
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, conn);
curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
Expand Down
5 changes: 4 additions & 1 deletion docs/examples/httpcustomheader.c
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -53,6 +53,9 @@ int main(void)

/* always cleanup */
curl_easy_cleanup(curl);

/* free the custom headers */
curl_slist_free_all(chunk);
}
return 0;
}
5 changes: 3 additions & 2 deletions docs/libcurl/curl_easy_setopt.3
Expand Up @@ -2323,8 +2323,9 @@ Curl considers the server the intended one when the Common Name field or a
Subject Alternate Name field in the certificate matches the host name in the
URL to which you told Curl to connect.

When the value is 1, the certificate must contain a Common Name field, but it
doesn't matter what name it says. (This is not ordinarily a useful setting).
When the value is 1, libcurl will return a failure. It was previously (in
7.28.0 and earlier) a debug option of some sorts, but it is no longer
supported due to frequently leading to programmer mistakes.

When the value is 0, the connection succeeds regardless of the names in the
certificate.
Expand Down
26 changes: 12 additions & 14 deletions lib/Makefile.am
Expand Up @@ -64,23 +64,21 @@ CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@
# $(top_srcdir)/ares is for in-tree c-ares's external include files

if USE_EMBEDDED_ARES
INCLUDES = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_builddir)/ares \
-I$(top_srcdir)/ares
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_builddir)/ares \
-I$(top_srcdir)/ares
else
INCLUDES = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib
AM_CPPFLAGS = -I$(top_builddir)/include/curl \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib
endif

AM_CPPFLAGS =

# Mostly for Windows build targets, when building libcurl library
if USE_CPPFLAG_BUILDING_LIBCURL
AM_CPPFLAGS += -DBUILDING_LIBCURL
Expand Down
5 changes: 3 additions & 2 deletions lib/curl_darwinssl.c
Expand Up @@ -803,12 +803,13 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn,
}
#endif /* defined(__MAC_10_6) || defined(__IPHONE_5_0) */

/* If this is a domain name and not an IP address, then configure SNI: */
/* If this is a domain name and not an IP address, then configure SNI.
* Also: the verifyhost setting influences SNI usage */
if((0 == Curl_inet_pton(AF_INET, conn->host.name, &addr))
#ifdef ENABLE_IPV6
&& (0 == Curl_inet_pton(AF_INET6, conn->host.name, &addr))
#endif
) {
&& data->set.ssl.verifyhost) {
err = SSLSetPeerDomainName(connssl->ssl_ctx, conn->host.name,
strlen(conn->host.name));
if(err != noErr) {
Expand Down
7 changes: 2 additions & 5 deletions lib/curl_schannel.c
Expand Up @@ -166,7 +166,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
"subject names in server certificates.\n");
}

if(data->set.ssl.verifyhost < 2) {
if(!data->set.ssl.verifyhost) {
schannel_cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK;
infof(data, "schannel: verifyhost setting prevents Schannel "
"from comparing the supplied target name with the "
Expand Down Expand Up @@ -1245,10 +1245,7 @@ static CURLcode verify_certificate(struct connectdata *conn, int sockindex)
}

if(result == CURLE_OK) {
if(data->set.ssl.verifyhost == 1) {
infof(data, "warning: ignoring unsupported value (1) ssl.verifyhost\n");
}
else if(data->set.ssl.verifyhost == 2) {
if(data->set.ssl.verifyhost) {
TCHAR cert_hostname_buff[128];
xcharp_u hostname;
xcharp_u cert_hostname;
Expand Down
60 changes: 43 additions & 17 deletions lib/ftp.c
Expand Up @@ -632,8 +632,8 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
size_t *size) /* size of the response */
{
struct connectdata *conn = pp->conn;
#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
struct SessionHandle *data = conn->data;
#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
char * const buf = data->state.buffer;
#endif
CURLcode result = CURLE_OK;
Expand Down Expand Up @@ -661,16 +661,23 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
#endif

/* store the latest code for later retrieval */
conn->data->info.httpcode=code;
data->info.httpcode=code;

if(ftpcode)
*ftpcode = code;

if(421 == code)
if(421 == code) {
/* 421 means "Service not available, closing control connection." and FTP
* servers use it to signal that idle session timeout has been exceeded.
* If we ignored the response, it could end up hanging in some cases. */
* If we ignored the response, it could end up hanging in some cases.
*
* This response code can come at any point so having it treated
* generically is a good idea.
*/
infof(data, "We got a 421 - timeout!\n");
state(conn, FTP_STOP);
return CURLE_OPERATION_TIMEDOUT;
}

return result;
}
Expand Down Expand Up @@ -2394,6 +2401,7 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,

if(ftpcode>=400) {
failf(data, "Failed FTP upload: %0d", ftpcode);
state(conn, FTP_STOP);
/* oops, we never close the sockets! */
return CURLE_UPLOAD_FAILED;
}
Expand All @@ -2411,9 +2419,6 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,
if(!connected) {
struct ftp_conn *ftpc = &conn->proto.ftpc;
infof(data, "Data conn was not available immediately\n");
/* as there's not necessarily an immediate action on the control
connection now, we halt the state machine */
state(conn, FTP_STOP);
ftpc->wait_data_conn = TRUE;
}

Expand Down Expand Up @@ -3663,6 +3668,8 @@ static CURLcode ftp_do_more(struct connectdata *conn, bool *complete)
/* the ftp struct is inited in ftp_connect() */
struct FTP *ftp = data->state.proto.ftp;

*complete = FALSE;

/* if the second connection isn't done yet, wait for it */
if(!conn->bits.tcpconnect[SECONDARYSOCKET]) {
result = Curl_is_connected(conn, SECONDARYSOCKET, &connected);
Expand All @@ -3675,6 +3682,18 @@ static CURLcode ftp_do_more(struct connectdata *conn, bool *complete)
return result;
}

if((data->state.used_interface == Curl_if_multi) &&
ftpc->state) {
/* multi interface and already in a state so skip the intial commands.
They are only done to kickstart the do_more state */
result = ftp_multi_statemach(conn, complete);

/* if we got an error or if we don't wait for a data connection return
immediately */
if(result || (ftpc->wait_data_conn != TRUE))
return result;
}

if(ftp->transfer <= FTPTRANSFER_INFO) {
/* a transfer is about to take place, or if not a file name was given
so we'll do a SIZE on it later and then we need the right TYPE first */
Expand Down Expand Up @@ -3728,7 +3747,13 @@ static CURLcode ftp_do_more(struct connectdata *conn, bool *complete)
return result;
}
}
result = ftp_easy_statemach(conn);
if(data->state.used_interface == Curl_if_multi) {
result = ftp_multi_statemach(conn, complete);

return result;
}
else
result = ftp_easy_statemach(conn);
}

if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY))
Expand Down Expand Up @@ -4402,20 +4427,21 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
static CURLcode ftp_dophase_done(struct connectdata *conn,
bool connected)
{
CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->state.proto.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;

if(connected) {
bool completed;
result = ftp_do_more(conn, &completed);
}
CURLcode result = ftp_do_more(conn, &completed);

if(result && (conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD)) {
/* Failure detected, close the second socket if it was created already */
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
return result;
if(result) {
if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) {
/* close the second socket if it was created already */
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
}
return result;
}
}

if(ftp->transfer != FTPTRANSFER_BODY)
Expand All @@ -4427,7 +4453,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn,

ftpc->ctl_valid = TRUE; /* seems good */

return result;
return CURLE_OK;
}

/* called from multi.c while DOing */
Expand Down
38 changes: 29 additions & 9 deletions lib/gtls.c
Expand Up @@ -299,21 +299,41 @@ static CURLcode handshake(struct connectdata *conn,
connssl->connecting_state =
gnutls_record_get_direction(session)?
ssl_connect_2_writing:ssl_connect_2_reading;
continue;
if(nonblocking)
return CURLE_OK;
}
else if((rc < 0) && gnutls_error_is_fatal(rc)) {
failf(data, "gnutls_handshake() warning: %s", gnutls_strerror(rc));
else if((rc < 0) && !gnutls_error_is_fatal(rc)) {
const char *strerr = NULL;

if(rc == GNUTLS_E_WARNING_ALERT_RECEIVED) {
int alert = gnutls_alert_get(session);
strerr = gnutls_alert_get_name(alert);
}

if(strerr == NULL)
strerr = gnutls_strerror(rc);

failf(data, "gnutls_handshake() warning: %s", strerr);
}
else if(rc < 0) {
failf(data, "gnutls_handshake() failed: %s", gnutls_strerror(rc));
const char *strerr = NULL;

if(rc == GNUTLS_E_FATAL_ALERT_RECEIVED) {
int alert = gnutls_alert_get(session);
strerr = gnutls_alert_get_name(alert);
}

if(strerr == NULL)
strerr = gnutls_strerror(rc);

failf(data, "gnutls_handshake() failed: %s", strerr);
return CURLE_SSL_CONNECT_ERROR;
}
else {
/* Reset our connect state machine */
connssl->connecting_state = ssl_connect_1;
return CURLE_OK;
}

/* Reset our connect state machine */
connssl->connecting_state = ssl_connect_1;
return CURLE_OK;
}
}

Expand Down Expand Up @@ -661,7 +681,7 @@ gtls_connect_step3(struct connectdata *conn,
rc = gnutls_x509_crt_check_hostname(x509_cert, conn->host.name);

if(!rc) {
if(data->set.ssl.verifyhost > 1) {
if(data->set.ssl.verifyhost) {
failf(data, "SSL: certificate subject name (%s) does not match "
"target host name '%s'", certbuf, conn->host.dispname);
gnutls_x509_crt_deinit(x509_cert);
Expand Down

0 comments on commit 9d3e503

Please sign in to comment.