Commit 06d6d6c4 authored by Curl Upstream's avatar Curl Upstream Committed by Brad King

curl 2017-06-14 (54b636f1)

Code extracted from:

    https://github.com/curl/curl.git

at commit 54b636f14546d3fde9f9c67c3b32701d78563161 (curl-7_54_1).
parent fd7d521c
......@@ -380,7 +380,7 @@ if(CMAKE_USE_MBEDTLS)
set(SSL_ENABLED ON)
set(USE_MBEDTLS ON)
list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES})
include_directories(${MBEDTLS_INCLUDE_DIR})
include_directories(${MBEDTLS_INCLUDE_DIRS})
endif()
option(USE_NGHTTP2 "Use Nghttp2 library" OFF)
......@@ -623,6 +623,78 @@ else()
endif()
#
# CA handling
#
set(CURL_CA_BUNDLE "auto" CACHE STRING
"Path to the CA bundle. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
set(CURL_CA_FALLBACK OFF CACHE BOOL
"Set ON to use built-in CA store of TLS backend. Defaults to OFF")
set(CURL_CA_PATH "auto" CACHE STRING
"Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
if("${CURL_CA_BUNDLE}" STREQUAL "")
message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
elseif("${CURL_CA_BUNDLE}" STREQUAL "none")
unset(CURL_CA_BUNDLE CACHE)
elseif("${CURL_CA_BUNDLE}" STREQUAL "auto")
unset(CURL_CA_BUNDLE CACHE)
set(CURL_CA_BUNDLE_AUTODETECT TRUE)
else()
set(CURL_CA_BUNDLE_SET TRUE)
endif()
if("${CURL_CA_PATH}" STREQUAL "")
message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
elseif("${CURL_CA_PATH}" STREQUAL "none")
unset(CURL_CA_PATH CACHE)
elseif("${CURL_CA_PATH}" STREQUAL "auto")
unset(CURL_CA_PATH CACHE)
set(CURL_CA_PATH_AUTODETECT TRUE)
else()
set(CURL_CA_PATH_SET TRUE)
endif()
if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT)
# Skip autodetection of unset CA path because CA bundle is set explicitly
elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT)
# Skip autodetection of unset CA bundle because CA path is set explicitly
elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
# first try autodetecting a CA bundle, then a CA path
if(CURL_CA_BUNDLE_AUTODETECT)
set(SEARCH_CA_BUNDLE_PATHS
/etc/ssl/certs/ca-certificates.crt
/etc/pki/tls/certs/ca-bundle.crt
/usr/share/ssl/certs/ca-bundle.crt
/usr/local/share/certs/ca-root-nss.crt
/etc/ssl/cert.pem)
foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}")
set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
break()
endif()
endforeach()
endif()
if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
if(EXISTS "/etc/ssl/certs")
set(CURL_CA_PATH "/etc/ssl/certs")
set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
endif()
endif()
endif()
if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS)
message(FATAL_ERROR
"CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
"Set CURL_CA_PATH=none or enable one of those TLS backends.")
endif()
# Check for header files
if(NOT UNIX)
check_include_file_concat("windows.h" HAVE_WINDOWS_H)
......@@ -1127,8 +1199,7 @@ _add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND
(HAVE_GSSAPI OR USE_WINDOWS_SSPI))
# NTLM support requires crypto function adaptions from various SSL libs
# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR
USE_WINDOWS_SSPI OR GNUTLS_ENABLED OR NSS_ENABLED OR USE_DARWINSSL OR USE_MBEDTLS))
if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR USE_WINDOWS_SSPI OR USE_DARWINSSL OR USE_MBEDTLS))
_add_if("NTLM" 1)
# TODO missing option (autoconf: --enable-ntlm-wb)
_add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
......@@ -1177,8 +1248,6 @@ set(CC "${CMAKE_C_COMPILER}")
set(CONFIGURE_OPTIONS "")
# TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB?
set(CPPFLAG_CURL_STATICLIB "")
# TODO need to set this (see CURL_CHECK_CA_BUNDLE in acinclude.m4)
set(CURL_CA_BUNDLE "")
set(CURLVERSION "${CURL_VERSION}")
set(ENABLE_SHARED "yes")
if(CURL_STATICLIB)
......
......@@ -2251,6 +2251,7 @@ struct curl_tlssessioninfo {
#define CURLINFO_LONG 0x200000
#define CURLINFO_DOUBLE 0x300000
#define CURLINFO_SLIST 0x400000
#define CURLINFO_PTR 0x400000 /* same as SLIST */
#define CURLINFO_SOCKET 0x500000
#define CURLINFO_MASK 0x0fffff
#define CURLINFO_TYPEMASK 0xf00000
......@@ -2290,7 +2291,7 @@ typedef enum {
CURLINFO_REDIRECT_URL = CURLINFO_STRING + 31,
CURLINFO_PRIMARY_IP = CURLINFO_STRING + 32,
CURLINFO_APPCONNECT_TIME = CURLINFO_DOUBLE + 33,
CURLINFO_CERTINFO = CURLINFO_SLIST + 34,
CURLINFO_CERTINFO = CURLINFO_PTR + 34,
CURLINFO_CONDITION_UNMET = CURLINFO_LONG + 35,
CURLINFO_RTSP_SESSION_ID = CURLINFO_STRING + 36,
CURLINFO_RTSP_CLIENT_CSEQ = CURLINFO_LONG + 37,
......@@ -2299,9 +2300,9 @@ typedef enum {
CURLINFO_PRIMARY_PORT = CURLINFO_LONG + 40,
CURLINFO_LOCAL_IP = CURLINFO_STRING + 41,
CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42,
CURLINFO_TLS_SESSION = CURLINFO_SLIST + 43,
CURLINFO_TLS_SESSION = CURLINFO_PTR + 43,
CURLINFO_ACTIVESOCKET = CURLINFO_SOCKET + 44,
CURLINFO_TLS_SSL_PTR = CURLINFO_SLIST + 45,
CURLINFO_TLS_SSL_PTR = CURLINFO_PTR + 45,
CURLINFO_HTTP_VERSION = CURLINFO_LONG + 46,
CURLINFO_PROXY_SSL_VERIFYRESULT = CURLINFO_LONG + 47,
CURLINFO_PROTOCOL = CURLINFO_LONG + 48,
......
......@@ -30,13 +30,13 @@
/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "7.54.0-DEV"
#define LIBCURL_VERSION "7.54.1-DEV"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
#define LIBCURL_VERSION_MINOR 54
#define LIBCURL_VERSION_PATCH 0
#define LIBCURL_VERSION_PATCH 1
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
......@@ -57,18 +57,18 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x073600
#define LIBCURL_VERSION_NUM 0x073601
/*
* This is the date and time when the full source package was created. The
* timestamp is not stored in git, as the timestamp is properly set in the
* tarballs by the maketgz script.
*
* The format of the date should follow this template:
* The format of the date follows this template:
*
* "Mon Feb 12 11:35:33 UTC 2007"
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "DEV"
#define LIBCURL_TIMESTAMP "[unreleased]"
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
#define CURL_AT_LEAST_VERSION(x,y,z) \
......
This diff is collapsed.
......@@ -232,7 +232,7 @@ int Curl_resolver_getsock(struct connectdata *conn,
milli = (timeout->tv_sec * 1000) + (timeout->tv_usec/1000);
if(milli == 0)
milli += 10;
Curl_expire_latest(conn->data, milli);
Curl_expire(conn->data, milli, EXPIRE_ASYNC_NAME);
return max;
}
......@@ -373,7 +373,6 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
/* Wait for the name resolve query to complete. */
while(!result) {
struct timeval *tvp, tv, store;
long timediff;
int itimeout;
int timeout_ms;
......@@ -402,8 +401,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
result = CURLE_ABORTED_BY_CALLBACK;
else {
struct timeval now2 = Curl_tvnow();
timediff = Curl_tvdiff(now2, now); /* spent time */
timeout -= timediff?timediff:1; /* always deduct at least 1 */
time_t timediff = Curl_tvdiff(now2, now); /* spent time */
if(timediff <= 0)
timeout -= 1; /* always deduct at least 1 */
else if(timediff > timeout)
timeout = -1;
else
timeout -= (long)timediff;
now = now2; /* for next loop */
}
if(timeout < 0)
......
......@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
......@@ -22,6 +22,11 @@
#include "curl_setup.h"
/***********************************************************************
* Only for threaded name resolves builds
**********************************************************************/
#ifdef CURLRES_THREADED
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
......@@ -74,11 +79,6 @@
#include "curl_memory.h"
#include "memdebug.h"
/***********************************************************************
* Only for threaded name resolves builds
**********************************************************************/
#ifdef CURLRES_THREADED
/*
* Curl_resolver_global_init()
* Called from curl_global_init() to initialize global resolver environment.
......@@ -540,7 +540,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
td->poll_interval = 250;
td->interval_end = elapsed + td->poll_interval;
Curl_expire(conn->data, td->poll_interval);
Curl_expire(conn->data, td->poll_interval, EXPIRE_ASYNC_NAME);
}
return CURLE_OK;
......
......@@ -72,13 +72,11 @@ static void bundle_destroy(struct connectbundle *cb_ptr)
/* Add a connection to a bundle */
static CURLcode bundle_add_conn(struct connectbundle *cb_ptr,
struct connectdata *conn)
struct connectdata *conn)
{
if(!Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn))
return CURLE_OUT_OF_MEMORY;
Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn,
&conn->bundle_node);
conn->bundle = cb_ptr;
cb_ptr->num_connections++;
return CURLE_OK;
}
......
......@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
......@@ -1070,7 +1070,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
conn->connecttime = Curl_tvnow();
if(conn->num_addr > 1)
Curl_expire_latest(data, conn->timeoutms_per_addr);
Curl_expire(data, conn->timeoutms_per_addr, EXPIRE_DNS_PER_NAME);
/* Connect TCP sockets, bind UDP */
if(!isconnected && (conn->socktype == SOCK_STREAM)) {
......@@ -1169,7 +1169,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
conn->tempaddr[1] = NULL;
conn->tempsock[0] = CURL_SOCKET_BAD;
conn->tempsock[1] = CURL_SOCKET_BAD;
Curl_expire(conn->data, HAPPY_EYEBALLS_TIMEOUT);
Curl_expire(conn->data, HAPPY_EYEBALLS_TIMEOUT, EXPIRE_HAPPY_EYEBALLS);
/* Max time for the next connection attempt */
conn->timeoutms_per_addr =
......
......@@ -4,10 +4,13 @@
#cmakedefine BUILDING_LIBCURL 1
/* Location of default ca bundle */
#cmakedefine CURL_CA_BUNDLE ${CURL_CA_BUNDLE}
#cmakedefine CURL_CA_BUNDLE "${CURL_CA_BUNDLE}"
/* define "1" to use built-in ca store of TLS backend */
#cmakedefine CURL_CA_FALLBACK 1
/* Location of default ca path */
#cmakedefine CURL_CA_PATH ${CURL_CA_PATH}
#cmakedefine CURL_CA_PATH "${CURL_CA_PATH}"
/* to disable cookies support */
#cmakedefine CURL_DISABLE_COOKIES 1
......
......@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
......@@ -62,44 +62,6 @@ unsigned int Curl_read32_le(const unsigned char *buf)
((unsigned int)buf[2] << 16) | ((unsigned int)buf[3] << 24);
}
#if (CURL_SIZEOF_CURL_OFF_T > 4)
/*
* Curl_read64_le()
*
* This function converts a 64-bit integer from the little endian format, as
* used in the incoming package to whatever endian format we're using
* natively.
*
* Parameters:
*
* buf [in] - A pointer to a 8 byte buffer.
*
* Returns the integer.
*/
#if defined(HAVE_LONGLONG)
unsigned long long Curl_read64_le(const unsigned char *buf)
{
return ((unsigned long long)buf[0]) |
((unsigned long long)buf[1] << 8) |
((unsigned long long)buf[2] << 16) |
((unsigned long long)buf[3] << 24) |
((unsigned long long)buf[4] << 32) |
((unsigned long long)buf[5] << 40) |
((unsigned long long)buf[6] << 48) |
((unsigned long long)buf[7] << 56);
}
#else
unsigned __int64 Curl_read64_le(const unsigned char *buf)
{
return ((unsigned __int64)buf[0]) | ((unsigned __int64)buf[1] << 8) |
((unsigned __int64)buf[2] << 16) | ((unsigned __int64)buf[3] << 24) |
((unsigned __int64)buf[4] << 32) | ((unsigned __int64)buf[5] << 40) |
((unsigned __int64)buf[6] << 48) | ((unsigned __int64)buf[7] << 56);
}
#endif
#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */
/*
* Curl_read16_be()
*
......@@ -119,80 +81,6 @@ unsigned short Curl_read16_be(const unsigned char *buf)
((unsigned short)buf[1]));
}
/*
* Curl_read32_be()
*
* This function converts a 32-bit integer from the big endian format, as
* used in the incoming package to whatever endian format we're using
* natively.
*
* Parameters:
*
* buf [in] - A pointer to a 4 byte buffer.
*
* Returns the integer.
*/
unsigned int Curl_read32_be(const unsigned char *buf)
{
return ((unsigned int)buf[0] << 24) | ((unsigned int)buf[1] << 16) |
((unsigned int)buf[2] << 8) | ((unsigned int)buf[3]);
}
#if (CURL_SIZEOF_CURL_OFF_T > 4)
/*
* Curl_read64_be()
*
* This function converts a 64-bit integer from the big endian format, as
* used in the incoming package to whatever endian format we're using
* natively.
*
* Parameters:
*
* buf [in] - A pointer to a 8 byte buffer.
*
* Returns the integer.
*/
#if defined(HAVE_LONGLONG)
unsigned long long Curl_read64_be(const unsigned char *buf)
{
return ((unsigned long long)buf[0] << 56) |
((unsigned long long)buf[1] << 48) |
((unsigned long long)buf[2] << 40) |
((unsigned long long)buf[3] << 32) |
((unsigned long long)buf[4] << 24) |
((unsigned long long)buf[5] << 16) |
((unsigned long long)buf[6] << 8) |
((unsigned long long)buf[7]);
}
#else
unsigned __int64 Curl_read64_be(const unsigned char *buf)
{
return ((unsigned __int64)buf[0] << 56) | ((unsigned __int64)buf[1] << 48) |
((unsigned __int64)buf[2] << 40) | ((unsigned __int64)buf[3] << 32) |
((unsigned __int64)buf[4] << 24) | ((unsigned __int64)buf[5] << 16) |
((unsigned __int64)buf[6] << 8) | ((unsigned __int64)buf[7]);
}
#endif
#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */
/*
* Curl_write16_le()
*
* This function converts a 16-bit integer from the native endian format,
* to little endian format ready for sending down the wire.
*
* Parameters:
*
* value [in] - The 16-bit integer value.
* buffer [in] - A pointer to the output buffer.
*/
void Curl_write16_le(const short value, unsigned char *buffer)
{
buffer[0] = (char)(value & 0x00FF);
buffer[1] = (char)((value & 0xFF00) >> 8);
}
/*
* Curl_write32_le()
*
......
......@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
......@@ -28,33 +28,9 @@ unsigned short Curl_read16_le(const unsigned char *buf);
/* Converts a 32-bit integer from little endian */
unsigned int Curl_read32_le(const unsigned char *buf);
#if (CURL_SIZEOF_CURL_OFF_T > 4)
/* Converts a 64-bit integer from little endian */
#if defined(HAVE_LONGLONG)
unsigned long long Curl_read64_le(const unsigned char *buf);
#else
unsigned __int64 Curl_read64_le(const unsigned char *buf);
#endif
#endif
/* Converts a 16-bit integer from big endian */
unsigned short Curl_read16_be(const unsigned char *buf);
/* Converts a 32-bit integer from big endian */
unsigned int Curl_read32_be(const unsigned char *buf);
#if (CURL_SIZEOF_CURL_OFF_T > 4)
/* Converts a 64-bit integer from big endian */
#if defined(HAVE_LONGLONG)
unsigned long long Curl_read64_be(const unsigned char *buf);
#else
unsigned __int64 Curl_read64_be(const unsigned char *buf);
#endif
#endif
/* Converts a 16-bit integer to little endian */
void Curl_write16_le(const short value, unsigned char *buffer);
/* Converts a 32-bit integer to little endian */
void Curl_write32_le(const int value, unsigned char *buffer);
......
......@@ -24,12 +24,12 @@
#include "curl_setup.h"
/* NSS and OS/400 crypto library do not provide the MD4 hash algorithm, so
* that we have a local implementation of it */
#if defined(USE_NSS) || defined(USE_OS400CRYPTO)
#if defined(USE_NSS) || defined(USE_OS400CRYPTO) || \
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len);
#endif /* defined(USE_NSS) || defined(USE_OS400CRYPTO) */
#endif /* defined(USE_NSS) || defined(USE_OS400CRYPTO) ||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C)) */
#endif /* HEADER_CURL_MD4_H */
......@@ -80,6 +80,9 @@
# include <mbedtls/des.h>
# include <mbedtls/md4.h>
# if !defined(MBEDTLS_MD4_C)
# include "curl_md4.h"
# endif
#elif defined(USE_NSS)
......@@ -519,7 +522,7 @@ static void ascii_uppercase_to_unicode_le(unsigned char *dest,
{
size_t i;
for(i = 0; i < srclen; i++) {
dest[2 * i] = (unsigned char)(toupper(src[i]));
dest[2 * i] = (unsigned char)(Curl_raw_toupper(src[i]));
dest[2 * i + 1] = '\0';
}
}
......@@ -568,10 +571,11 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
gcry_md_write(MD4pw, pw, 2 * len);
memcpy(ntbuffer, gcry_md_read(MD4pw, 0), MD4_DIGEST_LENGTH);
gcry_md_close(MD4pw);
#elif defined(USE_NSS) || defined(USE_OS400CRYPTO) || \
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
Curl_md4it(ntbuffer, pw, 2 * len);
#elif defined(USE_MBEDTLS)
mbedtls_md4(pw, 2 * len, ntbuffer);
#elif defined(USE_NSS) || defined(USE_OS400CRYPTO)
Curl_md4it(ntbuffer, pw, 2 * len);
#elif defined(USE_DARWINSSL)
(void)CC_MD4(pw, (CC_LONG)(2 * len), ntbuffer);
#elif defined(USE_WIN32_CRYPTO)
......
......@@ -25,6 +25,7 @@
#ifdef USE_LIBRTMP
#include "curl_rtmp.h"
#include "urldata.h"
#include "nonblock.h" /* for curlx_nonblock */
#include "progress.h" /* for Curl_pgrsSetUploadSize */
......
......@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2017, 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
......@@ -415,7 +415,6 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
conn->host.name;
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
#if !defined(CURL_DISABLE_CRYPTO_AUTH)
char *serverdata;
char *chlg = NULL;
size_t chlglen = 0;
#endif
......@@ -423,6 +422,10 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
const char *service = data->set.str[STRING_SERVICE_NAME] ?
data->set.str[STRING_SERVICE_NAME] :
sasl->params->service;
#endif
#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
defined(USE_NTLM)
char *serverdata;
#endif
size_t len = 0;
......
......@@ -588,11 +588,15 @@ int netware_init(void);
#endif
#endif
#if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H)
#if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
/* The lib and header are present */
#define USE_LIBIDN2
#endif
#if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
#error "Both libidn2 and WinIDN are enabled, choose one."
#endif
#ifndef SIZEOF_TIME_T
/* assume default size of time_t to be 32 bit */
#define SIZEOF_TIME_T 4
......@@ -623,14 +627,14 @@ int netware_init(void);
#if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH)
#if defined(USE_OPENSSL) || defined(USE_WINDOWS_SSPI) || \
defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \
defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO)
defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
defined(USE_MBEDTLS)
#define USE_NTLM
#elif defined(USE_MBEDTLS)
# if defined(USE_MBEDTLS)
/* Get definition of MBEDTLS_MD4_C */
# include <mbedtls/md4.h>
# if defined(MBEDTLS_MD4_C)
#define USE_NTLM
# endif
#endif
......
......@@ -196,7 +196,7 @@ struct timeval {
/* */
#else
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
(SEND_TYPE_ARG2)(y), \
(SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
(SEND_TYPE_ARG3)(z), \
(SEND_TYPE_ARG4)(SEND_4TH_ARG))
#endif
......
......@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
......@@ -147,6 +147,7 @@ char *Curl_dedotdotify(const char *input)
else if(!strcmp(".", clone) || !strcmp("..", clone)) {
*clone=0;
*out=0;
}
else {
......
......@@ -561,7 +561,7 @@ static void events_setup(struct Curl_multi *multi, struct events *ev)
static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
{
bool done = FALSE;
CURLMcode mcode;
CURLMcode mcode = CURLM_OK;
CURLcode result = CURLE_OK;
while(!done) {
......@@ -615,12 +615,18 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
}
}
if(!ev->msbump)
if(!ev->msbump) {
/* If nothing updated the timeout, we decrease it by the spent time.
* If it was updated, it has the new timeout time stored already.
*/
ev->ms += (long)curlx_tvdiff(after, before);
time_t timediff = curlx_tvdiff(after, before);
if(timediff > 0) {
if(timediff > ev->ms)
ev->ms = 0;
else
ev->ms -= (long)timediff;
}
}
}
else
return CURLE_RECV_ERROR;
......@@ -870,7 +876,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
* the likeliness of us forgetting to init a buffer here in the future.
*/
outcurl->set.buffer_size = data->set.buffer_size;
outcurl->state.buffer = malloc(CURL_BUFSIZE(outcurl->set.buffer_size) + 1);
outcurl->state.buffer = malloc(outcurl->set.buffer_size + 1);
if(!outcurl->state.buffer)
goto fail;
......@@ -1044,7 +1050,7 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
if(!result &&
((newstate&(KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) !=
(KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) )
Curl_expire(data, 0); /* get this handle going again */
Curl_expire(data, 0, EXPIRE_RUN_NOW); /* get this handle going again */
return result;
}
......
......@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, 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
......@@ -311,7 +311,6 @@ static CURLcode file_upload(struct connectdata *conn)
size_t nread;
size_t nwrite;
curl_off_t bytecount = 0;
struct timeval now = Curl_tvnow();
struct_stat file_stat;
const char *buf2;
......@@ -360,7 +359,7 @@ static CURLcode file_upload(struct connectdata *conn)
while(!result) {
int readcount;
result = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
result = Curl_fillreadbuffer(conn, (int)data->set.buffer_size, &readcount);
if(result)
break;
......@@ -399,7 +398,7 @@ static CURLcode file_upload(struct connectdata *conn)
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, now);
result = Curl_speedcheck(data, Curl_tvnow());
}
if(!result && Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
......@@ -436,7 +435,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
char *buf = data->state.buffer;
curl_off_t bytecount = 0;
int fd;
struct timeval now = Curl_tvnow();
struct FILEPROTO *file;
*done = TRUE; /* unconditionally */
......@@ -475,9 +473,10 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
time_t filetime;
struct tm buffer;
const struct tm *tm = &buffer;
snprintf(buf, CURL_BUFSIZE(data->set.buffer_size),