Merge branch 'upstream-curl' into update-curl

* upstream-curl:
  curl 2016-08-03 (f2cb3a01)
This commit is contained in:
Brad King 2016-08-03 14:26:53 -04:00
commit f53f4a8a2d
259 changed files with 11880 additions and 7417 deletions

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -10,8 +10,8 @@ endmacro(add_header_include)
set(signature_call_conv) set(signature_call_conv)
if(HAVE_WINDOWS_H) if(HAVE_WINDOWS_H)
add_header_include(HAVE_WINDOWS_H "windows.h")
add_header_include(HAVE_WINSOCK2_H "winsock2.h") add_header_include(HAVE_WINSOCK2_H "winsock2.h")
add_header_include(HAVE_WINDOWS_H "windows.h")
add_header_include(HAVE_WINSOCK_H "winsock.h") add_header_include(HAVE_WINSOCK_H "winsock.h")
set(_source_epilogue set(_source_epilogue
"${_source_epilogue}\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif") "${_source_epilogue}\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif")

View File

@ -1,6 +1,5 @@
# Set curl options as needed for CMake build # Set curl options as needed for CMake build
set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe") set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe")
set(BUILD_CURL_TESTS OFF CACHE INTERNAL "No curl tests")
set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports") set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports")
set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs") set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs")
set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi") set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi")
@ -70,7 +69,7 @@ endif()
# #
# 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
# are also available at http://curl.haxx.se/docs/copyright.html. # are also available at https://curl.haxx.se/docs/copyright.html.
# #
# You may opt to use, copy, modify, merge, publish, distribute and/or sell # You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is # copies of the Software, and permit persons to whom the Software is
@ -129,7 +128,7 @@ endif()
# SET(PACKAGE_NAME "curl") # SET(PACKAGE_NAME "curl")
# SET(PACKAGE_VERSION "-") # SET(PACKAGE_VERSION "-")
# SET(PACKAGE_STRING "curl-") # SET(PACKAGE_STRING "curl-")
# SET(PACKAGE_BUGREPORT "a suitable curl mailing list => http://curl.haxx.se/mail/") # SET(PACKAGE_BUGREPORT "a suitable curl mailing list => https://curl.haxx.se/mail/")
set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}") set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
set(OS "\"${CMAKE_SYSTEM_NAME}\"") set(OS "\"${CMAKE_SYSTEM_NAME}\"")
@ -137,7 +136,6 @@ include_directories(${PROJECT_BINARY_DIR}/include/curl)
include_directories( ${CURL_SOURCE_DIR}/include ) include_directories( ${CURL_SOURCE_DIR}/include )
option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON) option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON)
option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON)
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF) option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
option(ENABLE_ARES "Set to ON to enable c-ares support" OFF) option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF) option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF)
@ -173,12 +171,6 @@ if(ENABLE_ARES)
set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY}) set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
endif() endif()
option(BUILD_DASHBOARD_REPORTS "Set to ON to activate reporting of cURL builds here http://www.cdash.org/CDashPublic/index.php?project=CURL" OFF)
if(BUILD_DASHBOARD_REPORTS)
#INCLUDE(Dart)
include(CTest)
endif(BUILD_DASHBOARD_REPORTS)
if(MSVC) if(MSVC)
option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF) option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF)
mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS) mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS)
@ -187,11 +179,6 @@ endif()
option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that aren't officially external)." ON) option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that aren't officially external)." ON)
mark_as_advanced(CURL_HIDDEN_SYMBOLS) mark_as_advanced(CURL_HIDDEN_SYMBOLS)
# IF(WIN32)
# OPTION(CURL_WINDOWS_SSPI "Use windows libraries to allow NTLM authentication without openssl" ON)
# MARK_AS_ADVANCED(CURL_WINDOWS_SSPI)
# ENDIF()
option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF) option(HTTP_ONLY "disables all protocols except HTTP (This overrides all CURL_DISABLE_* options)" OFF)
mark_as_advanced(HTTP_ONLY) mark_as_advanced(HTTP_ONLY)
option(CURL_DISABLE_FTP "disables FTP" OFF) option(CURL_DISABLE_FTP "disables FTP" OFF)
@ -251,7 +238,7 @@ option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use threa
mark_as_advanced(DISABLED_THREADSAFE) mark_as_advanced(DISABLED_THREADSAFE)
option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON)
mark_as_advanced(ENABLE_IPV6) mark_as_advanced(ENABLE_IPV6)
if(ENABLE_IPV6) if(ENABLE_IPV6 AND NOT WIN32)
include(CheckStructHasMember) include(CheckStructHasMember)
check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h"
HAVE_SOCKADDR_IN6_SIN6_ADDR) HAVE_SOCKADDR_IN6_SIN6_ADDR)
@ -402,8 +389,7 @@ if(CMAKE_USE_OPENSSL)
endif() endif()
elseif(WIN32) elseif(WIN32)
# Use Windows SSL/TLS native implementation. # Use Windows SSL/TLS native implementation.
add_definitions(-DUSE_SCHANNEL) set(CURL_WINDOWS_SSPI ON)
set(USE_WINDOWS_SSPI 1)
elseif(APPLE) elseif(APPLE)
# Use OS X SSL/TLS native implementation if available on target version. # Use OS X SSL/TLS native implementation if available on target version.
if(CMAKE_OSX_DEPLOYMENT_TARGET) if(CMAKE_OSX_DEPLOYMENT_TARGET)
@ -426,11 +412,10 @@ elseif(APPLE)
endif() endif()
if(NOT CURL_DISABLE_LDAP) if(NOT CURL_DISABLE_LDAP)
if(WIN32) if(WIN32)
option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON) option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON)
if(USE_WIN32_LDAP) if(USE_WIN32_LDAP)
check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32) check_library_exists_concat("wldap32" cldap_open HAVE_WLDAP32)
if(NOT HAVE_WLDAP32) if(NOT HAVE_WLDAP32)
set(USE_WIN32_LDAP OFF) set(USE_WIN32_LDAP OFF)
endif() endif()
@ -445,75 +430,78 @@ if(NOT CURL_DISABLE_LDAP)
if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP) if(CMAKE_USE_OPENLDAP AND USE_WIN32_LDAP)
message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time") message(FATAL_ERROR "Cannot use USE_WIN32_LDAP and CMAKE_USE_OPENLDAP at the same time")
endif() endif()
# Now that we know, we're not using windows LDAP... # Now that we know, we're not using windows LDAP...
if(NOT USE_WIN32_LDAP) if(USE_WIN32_LDAP)
check_include_file_concat("winldap.h" HAVE_WINLDAP_H)
check_include_file_concat("winber.h" HAVE_WINBER_H)
else()
# Check for LDAP # Check for LDAP
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES})
check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP) check_library_exists_concat(${CMAKE_LDAP_LIB} ldap_init HAVE_LIBLDAP)
check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER) check_library_exists_concat(${CMAKE_LBER_LIB} ber_init HAVE_LIBLBER)
else()
check_include_file_concat("winldap.h" HAVE_WINLDAP_H)
check_include_file_concat("winber.h" HAVE_WINBER_H)
endif()
set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
if(CMAKE_LDAP_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR})
endif()
check_include_file_concat("ldap.h" HAVE_LDAP_H)
check_include_file_concat("lber.h" HAVE_LBER_H)
if(NOT HAVE_LDAP_H) set(CMAKE_REQUIRED_INCLUDES_BAK ${CMAKE_REQUIRED_INCLUDES})
message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON") set(CMAKE_LDAP_INCLUDE_DIR "" CACHE STRING "Path to LDAP include directory")
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
elseif(NOT HAVE_LIBLDAP)
message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON")
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
else()
if(CMAKE_USE_OPENLDAP)
set(USE_OPENLDAP ON)
endif()
if(CMAKE_LDAP_INCLUDE_DIR) if(CMAKE_LDAP_INCLUDE_DIR)
include_directories(${CMAKE_LDAP_INCLUDE_DIR}) list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_LDAP_INCLUDE_DIR})
endif() endif()
set(NEED_LBER_H ON) check_include_file_concat("ldap.h" HAVE_LDAP_H)
set(_HEADER_LIST) check_include_file_concat("lber.h" HAVE_LBER_H)
if(HAVE_WINDOWS_H)
list(APPEND _HEADER_LIST "windows.h")
endif()
if(HAVE_SYS_TYPES_H)
list(APPEND _HEADER_LIST "sys/types.h")
endif()
list(APPEND _HEADER_LIST "ldap.h")
set(_SRC_STRING "") if(NOT HAVE_LDAP_H)
foreach(_HEADER ${_HEADER_LIST}) message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n") set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
endforeach() set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
elseif(NOT HAVE_LIBLDAP)
set(_SRC_STRING message(STATUS "LDAP library '${CMAKE_LDAP_LIB}' not found CURL_DISABLE_LDAP set ON")
" set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
${_INCLUDE_STRING} set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_BAK}) #LDAP includes won't be used
int main(int argc, char ** argv)
{
BerValue *bvp = NULL;
BerElement *bep = ber_init(bvp);
ber_free(bep, 1);
return 0;
}"
)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1")
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB})
if(HAVE_LIBLBER)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB})
endif()
check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H)
if(NOT_NEED_LBER_H)
set(NEED_LBER_H OFF)
else() else()
set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H") if(CMAKE_USE_OPENLDAP)
set(USE_OPENLDAP ON)
endif()
if(CMAKE_LDAP_INCLUDE_DIR)
include_directories(${CMAKE_LDAP_INCLUDE_DIR})
endif()
set(NEED_LBER_H ON)
set(_HEADER_LIST)
if(HAVE_WINDOWS_H)
list(APPEND _HEADER_LIST "windows.h")
endif()
if(HAVE_SYS_TYPES_H)
list(APPEND _HEADER_LIST "sys/types.h")
endif()
list(APPEND _HEADER_LIST "ldap.h")
set(_SRC_STRING "")
foreach(_HEADER ${_HEADER_LIST})
set(_INCLUDE_STRING "${_INCLUDE_STRING}#include <${_HEADER}>\n")
endforeach()
set(_SRC_STRING
"
${_INCLUDE_STRING}
int main(int argc, char ** argv)
{
BerValue *bvp = NULL;
BerElement *bep = ber_init(bvp);
ber_free(bep, 1);
return 0;
}"
)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DLDAP_DEPRECATED=1")
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LDAP_LIB})
if(HAVE_LIBLBER)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB})
endif()
check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H)
if(NOT_NEED_LBER_H)
set(NEED_LBER_H OFF)
else()
set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -DNEED_LBER_H")
endif()
endif() endif()
endif() endif()
@ -551,6 +539,7 @@ if(CURL_ZLIB)
set(HAVE_LIBZ ON) set(HAVE_LIBZ ON)
list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS}) include_directories(${ZLIB_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
endif() endif()
endif() endif()
endif() endif()
@ -577,7 +566,7 @@ if(CMAKE_USE_LIBSSH2)
if(LIBSSH2_FOUND) if(LIBSSH2_FOUND)
list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY}) list(APPEND CURL_LIBS ${LIBSSH2_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}") list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBSSH2_INCLUDE_DIR}")
include_directories("${LIBSSH2_INCLUDE_DIR}") include_directories("${LIBSSH2_INCLUDE_DIR}")
set(HAVE_LIBSSH2 ON) set(HAVE_LIBSSH2 ON)
set(USE_LIBSSH2 ON) set(USE_LIBSSH2 ON)
@ -610,7 +599,7 @@ if(CMAKE_USE_GSSAPI)
message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"") message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"")
set(CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR}) list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIRECTORIES})
check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H) check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H) check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H) check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
@ -646,7 +635,7 @@ if(CMAKE_USE_GSSAPI)
endif() endif()
include_directories(${GSS_INCLUDE_DIR}) include_directories(${GSS_INCLUDE_DIRECTORIES})
link_directories(${GSS_LINK_DIRECTORIES}) link_directories(${GSS_LINK_DIRECTORIES})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
@ -666,12 +655,26 @@ else()
unset(USE_UNIX_SOCKETS CACHE) unset(USE_UNIX_SOCKETS CACHE)
endif() endif()
# Check for header files # Check for header files
if(NOT UNIX) if(NOT UNIX)
check_include_file_concat("windows.h" HAVE_WINDOWS_H) check_include_file_concat("windows.h" HAVE_WINDOWS_H)
check_include_file_concat("winsock.h" HAVE_WINSOCK_H) check_include_file_concat("winsock.h" HAVE_WINSOCK_H)
check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H) check_include_file_concat("ws2tcpip.h" HAVE_WS2TCPIP_H)
check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H) check_include_file_concat("winsock2.h" HAVE_WINSOCK2_H)
if(CURL_WINDOWS_SSPI)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -DSECURITY_WIN32")
check_include_file_concat("sspi.h" HAVE_SSPI_H)
if(HAVE_SSPI_H)
check_include_file_concat("schannel.h" HAVE_SCHANNEL_H)
set(USE_WINDOWS_SSPI ON)
if(HAVE_SCHANNEL_H)
set(USE_SCHANNEL ON)
set(SSL_ENABLED ON)
set(CURL_LIBS ${CURL_LIBS} "crypt32")
endif()
endif()
endif()
else() else()
set(HAVE_WINDOWS_H 0) set(HAVE_WINDOWS_H 0)
set(HAVE_WINSOCK_H 0) set(HAVE_WINSOCK_H 0)
@ -1090,9 +1093,6 @@ add_subdirectory(lib)
if(BUILD_CURL_EXE) if(BUILD_CURL_EXE)
add_subdirectory(src) add_subdirectory(src)
endif() endif()
if(BUILD_CURL_TESTS)
add_subdirectory(tests)
endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# CMake-specific curl code. # CMake-specific curl code.
@ -1107,6 +1107,11 @@ install(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmcurl)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
if(0) # This code not needed for building within CMake. if(0) # This code not needed for building within CMake.
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
# TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL, WINSSL, DARWINSSL # TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL, WINSSL, DARWINSSL
if(USE_OPENSSL) if(USE_OPENSSL)
set(SSL_ENABLED 1) set(SSL_ENABLED 1)
@ -1123,7 +1128,8 @@ endfunction()
# Clear list and try to detect available features # Clear list and try to detect available features
set(_items) set(_items)
_add_if("SSL" SSL_ENABLED) _add_if("WinSSL" SSL_ENABLED AND USE_WINDOWS_SSPI)
_add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL)
_add_if("IPv6" ENABLE_IPV6) _add_if("IPv6" ENABLE_IPV6)
_add_if("unix-sockets" USE_UNIX_SOCKETS) _add_if("unix-sockets" USE_UNIX_SOCKETS)
_add_if("libz" HAVE_LIBZ) _add_if("libz" HAVE_LIBZ)
@ -1221,7 +1227,7 @@ set(VERSIONNUM "${CURL_VERSION_NUM}")
# Finally generate a "curl-config" matching this config # Finally generate a "curl-config" matching this config
configure_file("${CURL_SOURCE_DIR}/curl-config.in" configure_file("${CURL_SOURCE_DIR}/curl-config.in"
"${CURL_BINARY_DIR}/curl-config" @ONLY) "${CURL_BINARY_DIR}/curl-config" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/curl-config" install(FILES "${CURL_BINARY_DIR}/curl-config"
DESTINATION bin DESTINATION bin
PERMISSIONS PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE OWNER_EXECUTE
@ -1231,7 +1237,7 @@ install(FILES "${CMAKE_BINARY_DIR}/curl-config"
# Finally generate a pkg-config file matching this config # Finally generate a pkg-config file matching this config
configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in" configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in"
"${CURL_BINARY_DIR}/libcurl.pc" @ONLY) "${CURL_BINARY_DIR}/libcurl.pc" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/libcurl.pc" install(FILES "${CURL_BINARY_DIR}/libcurl.pc"
DESTINATION lib/pkgconfig) DESTINATION lib/pkgconfig)
# This needs to be run very last so other parts of the scripts can take advantage of this. # This needs to be run very last so other parts of the scripts can take advantage of this.

View File

@ -1,6 +1,7 @@
COPYRIGHT AND PERMISSION NOTICE COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1996 - 2015, Daniel Stenberg, <daniel@haxx.se>. Copyright (c) 1996 - 2016, Daniel Stenberg, <daniel@haxx.se>, and many
contributors, see the THANKS file.
All rights reserved. All rights reserved.

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -24,10 +24,10 @@
/* /*
* If you have libcurl problems, all docs and details are found here: * If you have libcurl problems, all docs and details are found here:
* http://curl.haxx.se/libcurl/ * https://curl.haxx.se/libcurl/
* *
* curl-library mailing list subscription and unsubscription web interface: * curl-library mailing list subscription and unsubscription web interface:
* http://cool.haxx.se/mailman/listinfo/curl-library/ * https://cool.haxx.se/mailman/listinfo/curl-library/
*/ */
#include "curlver.h" /* libcurl version defines */ #include "curlver.h" /* libcurl version defines */
@ -56,7 +56,8 @@
#include <time.h> #include <time.h>
#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__CYGWIN__)
#if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || defined(__LWIP_OPT_H__)) #if !(defined(_WINSOCKAPI_) || defined(_WINSOCK_H) || \
defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H))
/* The check above prevents the winsock2 inclusion if winsock.h already was /* The check above prevents the winsock2 inclusion if winsock.h already was
included, since they can't co-exist without problems */ included, since they can't co-exist without problems */
#include <winsock2.h> #include <winsock2.h>
@ -90,7 +91,13 @@
extern "C" { extern "C" {
#endif #endif
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_easy CURL;
typedef struct Curl_share CURLSH;
#else
typedef void CURL; typedef void CURL;
typedef void CURLSH;
#endif
/* /*
* libcurl external API function linkage decorations. * libcurl external API function linkage decorations.
@ -112,7 +119,7 @@ typedef void CURL;
#ifndef curl_socket_typedef #ifndef curl_socket_typedef
/* socket typedef */ /* socket typedef */
#if defined(WIN32) && !defined(__LWIP_OPT_H__) #if defined(WIN32) && !defined(__LWIP_OPT_H__) && !defined(LWIP_HDR_OPT_H)
typedef SOCKET curl_socket_t; typedef SOCKET curl_socket_t;
#define CURL_SOCKET_BAD INVALID_SOCKET #define CURL_SOCKET_BAD INVALID_SOCKET
#else #else
@ -127,7 +134,8 @@ struct curl_httppost {
char *name; /* pointer to allocated name */ char *name; /* pointer to allocated name */
long namelength; /* length of name length */ long namelength; /* length of name length */
char *contents; /* pointer to allocated data contents */ char *contents; /* pointer to allocated data contents */
long contentslength; /* length of contents field */ long contentslength; /* length of contents field, see also
CURL_HTTPPOST_LARGE */
char *buffer; /* pointer to allocated buffer contents */ char *buffer; /* pointer to allocated buffer contents */
long bufferlength; /* length of buffer field */ long bufferlength; /* length of buffer field */
char *contenttype; /* Content-Type */ char *contenttype; /* Content-Type */
@ -136,24 +144,33 @@ struct curl_httppost {
file, this link should link to following file, this link should link to following
files */ files */
long flags; /* as defined below */ long flags; /* as defined below */
#define HTTPPOST_FILENAME (1<<0) /* specified content is a file name */
#define HTTPPOST_READFILE (1<<1) /* specified content is a file name */ /* specified content is a file name */
#define HTTPPOST_PTRNAME (1<<2) /* name is only stored pointer #define CURL_HTTPPOST_FILENAME (1<<0)
do not free in formfree */ /* specified content is a file name */
#define HTTPPOST_PTRCONTENTS (1<<3) /* contents is only stored pointer #define CURL_HTTPPOST_READFILE (1<<1)
do not free in formfree */ /* name is only stored pointer do not free in formfree */
#define HTTPPOST_BUFFER (1<<4) /* upload file from buffer */ #define CURL_HTTPPOST_PTRNAME (1<<2)
#define HTTPPOST_PTRBUFFER (1<<5) /* upload file from pointer contents */ /* contents is only stored pointer do not free in formfree */
#define HTTPPOST_CALLBACK (1<<6) /* upload file contents by using the #define CURL_HTTPPOST_PTRCONTENTS (1<<3)
regular read callback to get the data /* upload file from buffer */
and pass the given pointer as custom #define CURL_HTTPPOST_BUFFER (1<<4)
pointer */ /* upload file from pointer contents */
#define CURL_HTTPPOST_PTRBUFFER (1<<5)
/* upload file contents by using the regular read callback to get the data and
pass the given pointer as custom pointer */
#define CURL_HTTPPOST_CALLBACK (1<<6)
/* use size in 'contentlen', added in 7.46.0 */
#define CURL_HTTPPOST_LARGE (1<<7)
char *showfilename; /* The file name to show. If not set, the char *showfilename; /* The file name to show. If not set, the
actual file name will be used (if this actual file name will be used (if this
is a file part) */ is a file part) */
void *userp; /* custom pointer used for void *userp; /* custom pointer used for
HTTPPOST_CALLBACK posts */ HTTPPOST_CALLBACK posts */
curl_off_t contentlen; /* alternative length of contents
field. Used if CURL_HTTPPOST_LARGE is
set. Added in 7.46.0 */
}; };
/* This is the CURLOPT_PROGRESSFUNCTION callback proto. It is now considered /* This is the CURLOPT_PROGRESSFUNCTION callback proto. It is now considered
@ -362,6 +379,7 @@ typedef curlioerr (*curl_ioctl_callback)(CURL *handle,
int cmd, int cmd,
void *clientp); void *clientp);
#ifndef CURL_DID_MEMORY_FUNC_TYPEDEFS
/* /*
* The following typedef's are signatures of malloc, free, realloc, strdup and * The following typedef's are signatures of malloc, free, realloc, strdup and
* calloc respectively. Function pointers of these types can be passed to the * calloc respectively. Function pointers of these types can be passed to the
@ -374,6 +392,9 @@ typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
typedef char *(*curl_strdup_callback)(const char *str); typedef char *(*curl_strdup_callback)(const char *str);
typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size); typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
#define CURL_DID_MEMORY_FUNC_TYPEDEFS
#endif
/* the kind of data that is passed to information_callback*/ /* the kind of data that is passed to information_callback*/
typedef enum { typedef enum {
CURLINFO_TEXT = 0, CURLINFO_TEXT = 0,
@ -460,9 +481,9 @@ typedef enum {
CURLE_OBSOLETE44, /* 44 - NOT USED */ CURLE_OBSOLETE44, /* 44 - NOT USED */
CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */ CURLE_INTERFACE_FAILED, /* 45 - CURLOPT_INTERFACE failed */
CURLE_OBSOLETE46, /* 46 - NOT USED */ CURLE_OBSOLETE46, /* 46 - NOT USED */
CURLE_TOO_MANY_REDIRECTS , /* 47 - catch endless re-direct loops */ CURLE_TOO_MANY_REDIRECTS, /* 47 - catch endless re-direct loops */
CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */ CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */
CURLE_TELNET_OPTION_SYNTAX , /* 49 - Malformed telnet option */ CURLE_TELNET_OPTION_SYNTAX, /* 49 - Malformed telnet option */
CURLE_OBSOLETE50, /* 50 - NOT USED */ CURLE_OBSOLETE50, /* 50 - NOT USED */
CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint
wasn't verified fine */ wasn't verified fine */
@ -524,6 +545,8 @@ typedef enum {
CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not CURLE_SSL_PINNEDPUBKEYNOTMATCH, /* 90 - specified pinned public key did not
match */ match */
CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */ CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */
CURLE_HTTP2_STREAM, /* 92 - stream error in HTTP/2 framing layer
*/
CURL_LAST /* never use! */ CURL_LAST /* never use! */
} CURLcode; } CURLcode;
@ -818,9 +841,13 @@ typedef enum {
but 32 */ but 32 */
#define CURLOPTTYPE_LONG 0 #define CURLOPTTYPE_LONG 0
#define CURLOPTTYPE_OBJECTPOINT 10000 #define CURLOPTTYPE_OBJECTPOINT 10000
#define CURLOPTTYPE_STRINGPOINT 10000
#define CURLOPTTYPE_FUNCTIONPOINT 20000 #define CURLOPTTYPE_FUNCTIONPOINT 20000
#define CURLOPTTYPE_OFF_T 30000 #define CURLOPTTYPE_OFF_T 30000
/* *STRINGPOINT is an alias for OBJECTPOINT to allow tools to extract the
string options from the header file */
/* name is uppercase CURLOPT_<name>, /* name is uppercase CURLOPT_<name>,
type is one of the defined CURLOPTTYPE_<type> type is one of the defined CURLOPTTYPE_<type>
number is unique identifier */ number is unique identifier */
@ -834,6 +861,7 @@ typedef enum {
/* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */ /* The macro "##" is ISO C, we assume pre-ISO C doesn't support it. */
#define LONG CURLOPTTYPE_LONG #define LONG CURLOPTTYPE_LONG
#define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT #define OBJECTPOINT CURLOPTTYPE_OBJECTPOINT
#define STRINGPOINT CURLOPTTYPE_OBJECTPOINT
#define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT #define FUNCTIONPOINT CURLOPTTYPE_FUNCTIONPOINT
#define OFF_T CURLOPTTYPE_OFF_T #define OFF_T CURLOPTTYPE_OFF_T
#define CINIT(name,type,number) CURLOPT_/**/name = type + number #define CINIT(name,type,number) CURLOPT_/**/name = type + number
@ -850,22 +878,22 @@ typedef enum {
CINIT(WRITEDATA, OBJECTPOINT, 1), CINIT(WRITEDATA, OBJECTPOINT, 1),
/* The full URL to get/put */ /* The full URL to get/put */
CINIT(URL, OBJECTPOINT, 2), CINIT(URL, STRINGPOINT, 2),
/* Port number to connect to, if other than default. */ /* Port number to connect to, if other than default. */
CINIT(PORT, LONG, 3), CINIT(PORT, LONG, 3),
/* Name of proxy to use. */ /* Name of proxy to use. */
CINIT(PROXY, OBJECTPOINT, 4), CINIT(PROXY, STRINGPOINT, 4),
/* "user:password;options" to use when fetching. */ /* "user:password;options" to use when fetching. */
CINIT(USERPWD, OBJECTPOINT, 5), CINIT(USERPWD, STRINGPOINT, 5),
/* "user:password" to use with proxy. */ /* "user:password" to use with proxy. */
CINIT(PROXYUSERPWD, OBJECTPOINT, 6), CINIT(PROXYUSERPWD, STRINGPOINT, 6),
/* Range to get, specified as an ASCII string. */ /* Range to get, specified as an ASCII string. */
CINIT(RANGE, OBJECTPOINT, 7), CINIT(RANGE, STRINGPOINT, 7),
/* not used */ /* not used */
@ -902,14 +930,14 @@ typedef enum {
CINIT(POSTFIELDS, OBJECTPOINT, 15), CINIT(POSTFIELDS, OBJECTPOINT, 15),
/* Set the referrer page (needed by some CGIs) */ /* Set the referrer page (needed by some CGIs) */
CINIT(REFERER, OBJECTPOINT, 16), CINIT(REFERER, STRINGPOINT, 16),
/* Set the FTP PORT string (interface name, named or numerical IP address) /* Set the FTP PORT string (interface name, named or numerical IP address)
Use i.e '-' to use default address. */ Use i.e '-' to use default address. */
CINIT(FTPPORT, OBJECTPOINT, 17), CINIT(FTPPORT, STRINGPOINT, 17),
/* Set the User-Agent string (examined by some CGIs) */ /* Set the User-Agent string (examined by some CGIs) */
CINIT(USERAGENT, OBJECTPOINT, 18), CINIT(USERAGENT, STRINGPOINT, 18),
/* If the download receives less than "low speed limit" bytes/second /* If the download receives less than "low speed limit" bytes/second
* during "low speed time" seconds, the operations is aborted. * during "low speed time" seconds, the operations is aborted.
@ -932,7 +960,7 @@ typedef enum {
CINIT(RESUME_FROM, LONG, 21), CINIT(RESUME_FROM, LONG, 21),
/* Set cookie in request: */ /* Set cookie in request: */
CINIT(COOKIE, OBJECTPOINT, 22), CINIT(COOKIE, STRINGPOINT, 22),
/* This points to a linked list of headers, struct curl_slist kind. This /* This points to a linked list of headers, struct curl_slist kind. This
list is also used for RTSP (in spite of its name) */ list is also used for RTSP (in spite of its name) */
@ -942,10 +970,10 @@ typedef enum {
CINIT(HTTPPOST, OBJECTPOINT, 24), CINIT(HTTPPOST, OBJECTPOINT, 24),
/* name of the file keeping your private SSL-certificate */ /* name of the file keeping your private SSL-certificate */
CINIT(SSLCERT, OBJECTPOINT, 25), CINIT(SSLCERT, STRINGPOINT, 25),
/* password for the SSL or SSH private key */ /* password for the SSL or SSH private key */
CINIT(KEYPASSWD, OBJECTPOINT, 26), CINIT(KEYPASSWD, STRINGPOINT, 26),
/* send TYPE parameter? */ /* send TYPE parameter? */
CINIT(CRLF, LONG, 27), CINIT(CRLF, LONG, 27),
@ -959,7 +987,7 @@ typedef enum {
/* point to a file to read the initial cookies from, also enables /* point to a file to read the initial cookies from, also enables
"cookie awareness" */ "cookie awareness" */
CINIT(COOKIEFILE, OBJECTPOINT, 31), CINIT(COOKIEFILE, STRINGPOINT, 31),
/* What version to specifically try to use. /* What version to specifically try to use.
See CURL_SSLVERSION defines below. */ See CURL_SSLVERSION defines below. */
@ -978,9 +1006,9 @@ typedef enum {
HTTP: DELETE, TRACE and others HTTP: DELETE, TRACE and others
FTP: to use a different list command FTP: to use a different list command
*/ */
CINIT(CUSTOMREQUEST, OBJECTPOINT, 36), CINIT(CUSTOMREQUEST, STRINGPOINT, 36),
/* HTTP request, for odd commands like DELETE, TRACE and others */ /* FILE handle to use instead of stderr */
CINIT(STDERR, OBJECTPOINT, 37), CINIT(STDERR, OBJECTPOINT, 37),
/* 38 is not used */ /* 38 is not used */
@ -1037,19 +1065,19 @@ typedef enum {
CINIT(HTTPPROXYTUNNEL, LONG, 61), CINIT(HTTPPROXYTUNNEL, LONG, 61),
/* Set the interface string to use as outgoing network interface */ /* Set the interface string to use as outgoing network interface */
CINIT(INTERFACE, OBJECTPOINT, 62), CINIT(INTERFACE, STRINGPOINT, 62),
/* Set the krb4/5 security level, this also enables krb4/5 awareness. This /* Set the krb4/5 security level, this also enables krb4/5 awareness. This
* is a string, 'clear', 'safe', 'confidential' or 'private'. If the string * is a string, 'clear', 'safe', 'confidential' or 'private'. If the string
* is set but doesn't match one of these, 'private' will be used. */ * is set but doesn't match one of these, 'private' will be used. */
CINIT(KRBLEVEL, OBJECTPOINT, 63), CINIT(KRBLEVEL, STRINGPOINT, 63),
/* Set if we should verify the peer in ssl handshake, set 1 to verify. */ /* Set if we should verify the peer in ssl handshake, set 1 to verify. */
CINIT(SSL_VERIFYPEER, LONG, 64), CINIT(SSL_VERIFYPEER, LONG, 64),
/* The CApath or CAfile used to validate the peer certificate /* The CApath or CAfile used to validate the peer certificate
this option is used only if SSL_VERIFYPEER is true */ this option is used only if SSL_VERIFYPEER is true */
CINIT(CAINFO, OBJECTPOINT, 65), CINIT(CAINFO, STRINGPOINT, 65),
/* 66 = OBSOLETE */ /* 66 = OBSOLETE */
/* 67 = OBSOLETE */ /* 67 = OBSOLETE */
@ -1083,10 +1111,10 @@ typedef enum {
/* Set to a file name that contains random data for libcurl to use to /* Set to a file name that contains random data for libcurl to use to
seed the random engine when doing SSL connects. */ seed the random engine when doing SSL connects. */
CINIT(RANDOM_FILE, OBJECTPOINT, 76), CINIT(RANDOM_FILE, STRINGPOINT, 76),
/* Set to the Entropy Gathering Daemon socket pathname */ /* Set to the Entropy Gathering Daemon socket pathname */
CINIT(EGDSOCKET, OBJECTPOINT, 77), CINIT(EGDSOCKET, STRINGPOINT, 77),
/* Time-out connect operations after this amount of seconds, if connects are /* Time-out connect operations after this amount of seconds, if connects are
OK within this time, then fine... This only aborts the connect phase. */ OK within this time, then fine... This only aborts the connect phase. */
@ -1108,10 +1136,10 @@ typedef enum {
/* Specify which file name to write all known cookies in after completed /* Specify which file name to write all known cookies in after completed
operation. Set file name to "-" (dash) to make it go to stdout. */ operation. Set file name to "-" (dash) to make it go to stdout. */
CINIT(COOKIEJAR, OBJECTPOINT, 82), CINIT(COOKIEJAR, STRINGPOINT, 82),
/* Specify which SSL ciphers to use */ /* Specify which SSL ciphers to use */
CINIT(SSL_CIPHER_LIST, OBJECTPOINT, 83), CINIT(SSL_CIPHER_LIST, STRINGPOINT, 83),
/* Specify which HTTP version to use! This must be set to one of the /* Specify which HTTP version to use! This must be set to one of the
CURL_HTTP_VERSION* enums set below. */ CURL_HTTP_VERSION* enums set below. */
@ -1123,16 +1151,16 @@ typedef enum {
CINIT(FTP_USE_EPSV, LONG, 85), CINIT(FTP_USE_EPSV, LONG, 85),
/* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */ /* type of the file keeping your SSL-certificate ("DER", "PEM", "ENG") */
CINIT(SSLCERTTYPE, OBJECTPOINT, 86), CINIT(SSLCERTTYPE, STRINGPOINT, 86),
/* name of the file keeping your private SSL-key */ /* name of the file keeping your private SSL-key */
CINIT(SSLKEY, OBJECTPOINT, 87), CINIT(SSLKEY, STRINGPOINT, 87),
/* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */ /* type of the file keeping your private SSL-key ("DER", "PEM", "ENG") */
CINIT(SSLKEYTYPE, OBJECTPOINT, 88), CINIT(SSLKEYTYPE, STRINGPOINT, 88),
/* crypto engine for the SSL-sub system */ /* crypto engine for the SSL-sub system */
CINIT(SSLENGINE, OBJECTPOINT, 89), CINIT(SSLENGINE, STRINGPOINT, 89),
/* set the crypto engine for the SSL-sub system as default /* set the crypto engine for the SSL-sub system as default
the param has no meaning... the param has no meaning...
@ -1159,7 +1187,7 @@ typedef enum {
/* The CApath directory used to validate the peer certificate /* The CApath directory used to validate the peer certificate
this option is used only if SSL_VERIFYPEER is true */ this option is used only if SSL_VERIFYPEER is true */
CINIT(CAPATH, OBJECTPOINT, 97), CINIT(CAPATH, STRINGPOINT, 97),
/* Instruct libcurl to use a smaller receive buffer */ /* Instruct libcurl to use a smaller receive buffer */
CINIT(BUFFERSIZE, LONG, 98), CINIT(BUFFERSIZE, LONG, 98),
@ -1179,7 +1207,7 @@ typedef enum {
/* Set the Accept-Encoding string. Use this to tell a server you would like /* Set the Accept-Encoding string. Use this to tell a server you would like
the response to be compressed. Before 7.21.6, this was known as the response to be compressed. Before 7.21.6, this was known as
CURLOPT_ENCODING */ CURLOPT_ENCODING */
CINIT(ACCEPT_ENCODING, OBJECTPOINT, 102), CINIT(ACCEPT_ENCODING, STRINGPOINT, 102),
/* Set pointer to private data */ /* Set pointer to private data */
CINIT(PRIVATE, OBJECTPOINT, 103), CINIT(PRIVATE, OBJECTPOINT, 103),
@ -1260,7 +1288,7 @@ typedef enum {
to parse (using the CURLOPT_NETRC option). If not set, libcurl will do to parse (using the CURLOPT_NETRC option). If not set, libcurl will do
a poor attempt to find the user's home directory and check for a .netrc a poor attempt to find the user's home directory and check for a .netrc
file in there. */ file in there. */
CINIT(NETRC_FILE, OBJECTPOINT, 118), CINIT(NETRC_FILE, STRINGPOINT, 118),
/* Enable SSL/TLS for FTP, pick one of: /* Enable SSL/TLS for FTP, pick one of:
CURLUSESSL_TRY - try using SSL, proceed anyway otherwise CURLUSESSL_TRY - try using SSL, proceed anyway otherwise
@ -1303,10 +1331,10 @@ typedef enum {
/* zero terminated string for pass on to the FTP server when asked for /* zero terminated string for pass on to the FTP server when asked for
"account" info */ "account" info */
CINIT(FTP_ACCOUNT, OBJECTPOINT, 134), CINIT(FTP_ACCOUNT, STRINGPOINT, 134),
/* feed cookies into cookie engine */ /* feed cookie into cookie engine */
CINIT(COOKIELIST, OBJECTPOINT, 135), CINIT(COOKIELIST, STRINGPOINT, 135),
/* ignore Content-Length */ /* ignore Content-Length */
CINIT(IGNORE_CONTENT_LENGTH, LONG, 136), CINIT(IGNORE_CONTENT_LENGTH, LONG, 136),
@ -1352,7 +1380,7 @@ typedef enum {
CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146), CINIT(MAX_RECV_SPEED_LARGE, OFF_T, 146),
/* Pointer to command string to send if USER/PASS fails. */ /* Pointer to command string to send if USER/PASS fails. */
CINIT(FTP_ALTERNATIVE_TO_USER, OBJECTPOINT, 147), CINIT(FTP_ALTERNATIVE_TO_USER, STRINGPOINT, 147),
/* callback function for setting socket options */ /* callback function for setting socket options */
CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148), CINIT(SOCKOPTFUNCTION, FUNCTIONPOINT, 148),
@ -1366,8 +1394,8 @@ typedef enum {
CINIT(SSH_AUTH_TYPES, LONG, 151), CINIT(SSH_AUTH_TYPES, LONG, 151),
/* Used by scp/sftp to do public/private key authentication */ /* Used by scp/sftp to do public/private key authentication */
CINIT(SSH_PUBLIC_KEYFILE, OBJECTPOINT, 152), CINIT(SSH_PUBLIC_KEYFILE, STRINGPOINT, 152),
CINIT(SSH_PRIVATE_KEYFILE, OBJECTPOINT, 153), CINIT(SSH_PRIVATE_KEYFILE, STRINGPOINT, 153),
/* Send CCC (Clear Command Channel) after authentication */ /* Send CCC (Clear Command Channel) after authentication */
CINIT(FTP_SSL_CCC, LONG, 154), CINIT(FTP_SSL_CCC, LONG, 154),
@ -1391,7 +1419,7 @@ typedef enum {
CINIT(POSTREDIR, LONG, 161), CINIT(POSTREDIR, LONG, 161),
/* used by scp/sftp to verify the host's public key */ /* used by scp/sftp to verify the host's public key */
CINIT(SSH_HOST_PUBLIC_KEY_MD5, OBJECTPOINT, 162), CINIT(SSH_HOST_PUBLIC_KEY_MD5, STRINGPOINT, 162),
/* Callback function for opening socket (instead of socket(2)). Optionally, /* Callback function for opening socket (instead of socket(2)). Optionally,
callback is able change the address or refuse to connect returning callback is able change the address or refuse to connect returning
@ -1411,10 +1439,10 @@ typedef enum {
CINIT(SEEKDATA, OBJECTPOINT, 168), CINIT(SEEKDATA, OBJECTPOINT, 168),
/* CRL file */ /* CRL file */
CINIT(CRLFILE, OBJECTPOINT, 169), CINIT(CRLFILE, STRINGPOINT, 169),
/* Issuer certificate */ /* Issuer certificate */
CINIT(ISSUERCERT, OBJECTPOINT, 170), CINIT(ISSUERCERT, STRINGPOINT, 170),
/* (IPv6) Address scope */ /* (IPv6) Address scope */
CINIT(ADDRESS_SCOPE, LONG, 171), CINIT(ADDRESS_SCOPE, LONG, 171),
@ -1424,12 +1452,12 @@ typedef enum {
CINIT(CERTINFO, LONG, 172), CINIT(CERTINFO, LONG, 172),
/* "name" and "pwd" to use when fetching. */ /* "name" and "pwd" to use when fetching. */
CINIT(USERNAME, OBJECTPOINT, 173), CINIT(USERNAME, STRINGPOINT, 173),
CINIT(PASSWORD, OBJECTPOINT, 174), CINIT(PASSWORD, STRINGPOINT, 174),
/* "name" and "pwd" to use with Proxy when fetching. */ /* "name" and "pwd" to use with Proxy when fetching. */
CINIT(PROXYUSERNAME, OBJECTPOINT, 175), CINIT(PROXYUSERNAME, STRINGPOINT, 175),
CINIT(PROXYPASSWORD, OBJECTPOINT, 176), CINIT(PROXYPASSWORD, STRINGPOINT, 176),
/* Comma separated list of hostnames defining no-proxy zones. These should /* Comma separated list of hostnames defining no-proxy zones. These should
match both hostnames directly, and hostnames within a domain. For match both hostnames directly, and hostnames within a domain. For
@ -1438,13 +1466,13 @@ typedef enum {
implementations of this, .local.com will be considered to be the same as implementations of this, .local.com will be considered to be the same as
local.com. A single * is the only valid wildcard, and effectively local.com. A single * is the only valid wildcard, and effectively
disables the use of proxy. */ disables the use of proxy. */
CINIT(NOPROXY, OBJECTPOINT, 177), CINIT(NOPROXY, STRINGPOINT, 177),
/* block size for TFTP transfers */ /* block size for TFTP transfers */
CINIT(TFTP_BLKSIZE, LONG, 178), CINIT(TFTP_BLKSIZE, LONG, 178),
/* Socks Service */ /* Socks Service */
CINIT(SOCKS5_GSSAPI_SERVICE, OBJECTPOINT, 179), CINIT(SOCKS5_GSSAPI_SERVICE, STRINGPOINT, 179), /* DEPRECATED, do not use! */
/* Socks Service */ /* Socks Service */
CINIT(SOCKS5_GSSAPI_NEC, LONG, 180), CINIT(SOCKS5_GSSAPI_NEC, LONG, 180),
@ -1462,7 +1490,7 @@ typedef enum {
CINIT(REDIR_PROTOCOLS, LONG, 182), CINIT(REDIR_PROTOCOLS, LONG, 182),
/* set the SSH knownhost file name to use */ /* set the SSH knownhost file name to use */
CINIT(SSH_KNOWNHOSTS, OBJECTPOINT, 183), CINIT(SSH_KNOWNHOSTS, STRINGPOINT, 183),
/* set the SSH host key callback, must point to a curl_sshkeycallback /* set the SSH host key callback, must point to a curl_sshkeycallback
function */ function */
@ -1472,9 +1500,9 @@ typedef enum {
CINIT(SSH_KEYDATA, OBJECTPOINT, 185), CINIT(SSH_KEYDATA, OBJECTPOINT, 185),
/* set the SMTP mail originator */ /* set the SMTP mail originator */
CINIT(MAIL_FROM, OBJECTPOINT, 186), CINIT(MAIL_FROM, STRINGPOINT, 186),
/* set the SMTP mail receiver(s) */ /* set the list of SMTP mail receiver(s) */
CINIT(MAIL_RCPT, OBJECTPOINT, 187), CINIT(MAIL_RCPT, OBJECTPOINT, 187),
/* FTP: send PRET before PASV */ /* FTP: send PRET before PASV */
@ -1484,13 +1512,13 @@ typedef enum {
CINIT(RTSP_REQUEST, LONG, 189), CINIT(RTSP_REQUEST, LONG, 189),
/* The RTSP session identifier */ /* The RTSP session identifier */
CINIT(RTSP_SESSION_ID, OBJECTPOINT, 190), CINIT(RTSP_SESSION_ID, STRINGPOINT, 190),
/* The RTSP stream URI */ /* The RTSP stream URI */
CINIT(RTSP_STREAM_URI, OBJECTPOINT, 191), CINIT(RTSP_STREAM_URI, STRINGPOINT, 191),
/* The Transport: header to use in RTSP requests */ /* The Transport: header to use in RTSP requests */
CINIT(RTSP_TRANSPORT, OBJECTPOINT, 192), CINIT(RTSP_TRANSPORT, STRINGPOINT, 192),
/* Manually initialize the client RTSP CSeq for this handle */ /* Manually initialize the client RTSP CSeq for this handle */
CINIT(RTSP_CLIENT_CSEQ, LONG, 193), CINIT(RTSP_CLIENT_CSEQ, LONG, 193),
@ -1528,13 +1556,13 @@ typedef enum {
CINIT(RESOLVE, OBJECTPOINT, 203), CINIT(RESOLVE, OBJECTPOINT, 203),
/* Set a username for authenticated TLS */ /* Set a username for authenticated TLS */
CINIT(TLSAUTH_USERNAME, OBJECTPOINT, 204), CINIT(TLSAUTH_USERNAME, STRINGPOINT, 204),
/* Set a password for authenticated TLS */ /* Set a password for authenticated TLS */
CINIT(TLSAUTH_PASSWORD, OBJECTPOINT, 205), CINIT(TLSAUTH_PASSWORD, STRINGPOINT, 205),
/* Set authentication type for authenticated TLS */ /* Set authentication type for authenticated TLS */
CINIT(TLSAUTH_TYPE, OBJECTPOINT, 206), CINIT(TLSAUTH_TYPE, STRINGPOINT, 206),
/* Set to 1 to enable the "TE:" header in HTTP requests to ask for /* Set to 1 to enable the "TE:" header in HTTP requests to ask for
compressed transfer-encoded responses. Set to 0 to disable the use of TE: compressed transfer-encoded responses. Set to 0 to disable the use of TE:
@ -1557,7 +1585,7 @@ typedef enum {
CINIT(GSSAPI_DELEGATION, LONG, 210), CINIT(GSSAPI_DELEGATION, LONG, 210),
/* Set the name servers to use for DNS resolution */ /* Set the name servers to use for DNS resolution */
CINIT(DNS_SERVERS, OBJECTPOINT, 211), CINIT(DNS_SERVERS, STRINGPOINT, 211),
/* Time-out accept operations (currently for FTP only) after this amount /* Time-out accept operations (currently for FTP only) after this amount
of miliseconds. */ of miliseconds. */
@ -1574,7 +1602,7 @@ typedef enum {
CINIT(SSL_OPTIONS, LONG, 216), CINIT(SSL_OPTIONS, LONG, 216),
/* Set the SMTP auth originator */ /* Set the SMTP auth originator */
CINIT(MAIL_AUTH, OBJECTPOINT, 217), CINIT(MAIL_AUTH, STRINGPOINT, 217),
/* Enable/disable SASL initial response */ /* Enable/disable SASL initial response */
CINIT(SASL_IR, LONG, 218), CINIT(SASL_IR, LONG, 218),
@ -1585,23 +1613,23 @@ typedef enum {
CINIT(XFERINFOFUNCTION, FUNCTIONPOINT, 219), CINIT(XFERINFOFUNCTION, FUNCTIONPOINT, 219),
/* The XOAUTH2 bearer token */ /* The XOAUTH2 bearer token */
CINIT(XOAUTH2_BEARER, OBJECTPOINT, 220), CINIT(XOAUTH2_BEARER, STRINGPOINT, 220),
/* Set the interface string to use as outgoing network /* Set the interface string to use as outgoing network
* interface for DNS requests. * interface for DNS requests.
* Only supported by the c-ares DNS backend */ * Only supported by the c-ares DNS backend */
CINIT(DNS_INTERFACE, OBJECTPOINT, 221), CINIT(DNS_INTERFACE, STRINGPOINT, 221),
/* Set the local IPv4 address to use for outgoing DNS requests. /* Set the local IPv4 address to use for outgoing DNS requests.
* Only supported by the c-ares DNS backend */ * Only supported by the c-ares DNS backend */
CINIT(DNS_LOCAL_IP4, OBJECTPOINT, 222), CINIT(DNS_LOCAL_IP4, STRINGPOINT, 222),
/* Set the local IPv4 address to use for outgoing DNS requests. /* Set the local IPv4 address to use for outgoing DNS requests.
* Only supported by the c-ares DNS backend */ * Only supported by the c-ares DNS backend */
CINIT(DNS_LOCAL_IP6, OBJECTPOINT, 223), CINIT(DNS_LOCAL_IP6, STRINGPOINT, 223),
/* Set authentication options directly */ /* Set authentication options directly */
CINIT(LOGIN_OPTIONS, OBJECTPOINT, 224), CINIT(LOGIN_OPTIONS, STRINGPOINT, 224),
/* Enable/disable TLS NPN extension (http2 over ssl might fail without) */ /* Enable/disable TLS NPN extension (http2 over ssl might fail without) */
CINIT(SSL_ENABLE_NPN, LONG, 225), CINIT(SSL_ENABLE_NPN, LONG, 225),
@ -1622,10 +1650,10 @@ typedef enum {
/* The public key in DER form used to validate the peer public key /* The public key in DER form used to validate the peer public key
this option is used only if SSL_VERIFYPEER is true */ this option is used only if SSL_VERIFYPEER is true */
CINIT(PINNEDPUBLICKEY, OBJECTPOINT, 230), CINIT(PINNEDPUBLICKEY, STRINGPOINT, 230),
/* Path to Unix domain socket */ /* Path to Unix domain socket */
CINIT(UNIX_SOCKET_PATH, OBJECTPOINT, 231), CINIT(UNIX_SOCKET_PATH, STRINGPOINT, 231),
/* Set if we should verify the certificate status. */ /* Set if we should verify the certificate status. */
CINIT(SSL_VERIFYSTATUS, LONG, 232), CINIT(SSL_VERIFYSTATUS, LONG, 232),
@ -1637,14 +1665,36 @@ typedef enum {
CINIT(PATH_AS_IS, LONG, 234), CINIT(PATH_AS_IS, LONG, 234),
/* Proxy Service Name */ /* Proxy Service Name */
CINIT(PROXY_SERVICE_NAME, OBJECTPOINT, 235), CINIT(PROXY_SERVICE_NAME, STRINGPOINT, 235),
/* Service Name */ /* Service Name */
CINIT(SERVICE_NAME, OBJECTPOINT, 236), CINIT(SERVICE_NAME, STRINGPOINT, 236),
/* Wait/don't wait for pipe/mutex to clarify */ /* Wait/don't wait for pipe/mutex to clarify */
CINIT(PIPEWAIT, LONG, 237), CINIT(PIPEWAIT, LONG, 237),
/* Set the protocol used when curl is given a URL without a protocol */
CINIT(DEFAULT_PROTOCOL, STRINGPOINT, 238),
/* Set stream weight, 1 - 256 (default is 16) */
CINIT(STREAM_WEIGHT, LONG, 239),
/* Set stream dependency on another CURL handle */
CINIT(STREAM_DEPENDS, OBJECTPOINT, 240),
/* Set E-xclusive stream dependency on another CURL handle */
CINIT(STREAM_DEPENDS_E, OBJECTPOINT, 241),
/* Do not send any tftp option requests to the server */
CINIT(TFTP_NO_OPTIONS, LONG, 242),
/* Linked-list of host:port:connect-to-host:connect-to-port,
overrides the URL's host:port (only for the network layer) */
CINIT(CONNECT_TO, OBJECTPOINT, 243),
/* Set TCP Fast Open */
CINIT(TCP_FASTOPEN, LONG, 244),
CURLOPT_LASTENTRY /* the last unused */ CURLOPT_LASTENTRY /* the last unused */
} CURLoption; } CURLoption;
@ -1694,7 +1744,10 @@ enum {
for us! */ for us! */
CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */ CURL_HTTP_VERSION_1_0, /* please use HTTP 1.0 in the request */
CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */ CURL_HTTP_VERSION_1_1, /* please use HTTP 1.1 in the request */
CURL_HTTP_VERSION_2_0, /* please use HTTP 2.0 in the request */ CURL_HTTP_VERSION_2_0, /* please use HTTP 2 in the request */
CURL_HTTP_VERSION_2TLS, /* use version 2 for HTTPS, version 1.1 for HTTP */
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE, /* please use HTTP 2 without HTTP/1.1
Upgrade */
CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */ CURL_HTTP_VERSION_LAST /* *ILLEGAL* http version */
}; };
@ -1819,6 +1872,7 @@ typedef enum {
CFINIT(OBSOLETE2), CFINIT(OBSOLETE2),
CFINIT(STREAM), CFINIT(STREAM),
CFINIT(CONTENTLEN), /* added in 7.46.0, provide a curl_off_t length */
CURLFORM_LASTENTRY /* the last unused */ CURLFORM_LASTENTRY /* the last unused */
} CURLformoption; } CURLformoption;
@ -2073,12 +2127,18 @@ typedef enum {
CURLSSLBACKEND_CYASSL = 7, CURLSSLBACKEND_CYASSL = 7,
CURLSSLBACKEND_SCHANNEL = 8, CURLSSLBACKEND_SCHANNEL = 8,
CURLSSLBACKEND_DARWINSSL = 9, CURLSSLBACKEND_DARWINSSL = 9,
CURLSSLBACKEND_AXTLS = 10 CURLSSLBACKEND_AXTLS = 10,
CURLSSLBACKEND_MBEDTLS = 11
} curl_sslbackend; } curl_sslbackend;
/* aliases for library clones and renames */
#define CURLSSLBACKEND_LIBRESSL 1
#define CURLSSLBACKEND_BORINGSSL 1
#define CURLSSLBACKEND_WOLFSSL 6
/* Information about the SSL library used and the respective internal SSL /* Information about the SSL library used and the respective internal SSL
handle, which can be used to obtain further information regarding the handle, which can be used to obtain further information regarding the
connection. Asked for with CURLINFO_TLS_SESSION. */ connection. Asked for with CURLINFO_TLS_SSL_PTR or CURLINFO_TLS_SESSION. */
struct curl_tlssessioninfo { struct curl_tlssessioninfo {
curl_sslbackend backend; curl_sslbackend backend;
void *internals; void *internals;
@ -2088,6 +2148,7 @@ struct curl_tlssessioninfo {
#define CURLINFO_LONG 0x200000 #define CURLINFO_LONG 0x200000
#define CURLINFO_DOUBLE 0x300000 #define CURLINFO_DOUBLE 0x300000
#define CURLINFO_SLIST 0x400000 #define CURLINFO_SLIST 0x400000
#define CURLINFO_SOCKET 0x500000
#define CURLINFO_MASK 0x0fffff #define CURLINFO_MASK 0x0fffff
#define CURLINFO_TYPEMASK 0xf00000 #define CURLINFO_TYPEMASK 0xf00000
@ -2136,9 +2197,12 @@ typedef enum {
CURLINFO_LOCAL_IP = CURLINFO_STRING + 41, CURLINFO_LOCAL_IP = CURLINFO_STRING + 41,
CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42, CURLINFO_LOCAL_PORT = CURLINFO_LONG + 42,
CURLINFO_TLS_SESSION = CURLINFO_SLIST + 43, CURLINFO_TLS_SESSION = CURLINFO_SLIST + 43,
CURLINFO_ACTIVESOCKET = CURLINFO_SOCKET + 44,
CURLINFO_TLS_SSL_PTR = CURLINFO_SLIST + 45,
CURLINFO_HTTP_VERSION = CURLINFO_LONG + 46,
/* Fill in new entries below here! */ /* Fill in new entries below here! */
CURLINFO_LASTONE = 43 CURLINFO_LASTONE = 46
} CURLINFO; } CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
@ -2200,7 +2264,6 @@ typedef void (*curl_unlock_function)(CURL *handle,
curl_lock_data data, curl_lock_data data,
void *userptr); void *userptr);
typedef void CURLSH;
typedef enum { typedef enum {
CURLSHE_OK, /* all is fine */ CURLSHE_OK, /* all is fine */
@ -2298,6 +2361,8 @@ typedef struct {
#define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */ #define CURL_VERSION_GSSAPI (1<<17) /* Built against a GSS-API library */
#define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */ #define CURL_VERSION_KERBEROS5 (1<<18) /* Kerberos V5 auth is supported */
#define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */ #define CURL_VERSION_UNIX_SOCKETS (1<<19) /* Unix domain sockets support */
#define CURL_VERSION_PSL (1<<20) /* Mozilla's Public Suffix List, used
for cookie domain verification */
/* /*
* NAME curl_version_info() * NAME curl_version_info()

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -35,7 +35,7 @@
* *
* If you think that something actually needs to be changed, adjusted * If you think that something actually needs to be changed, adjusted
* or fixed in this file, then, report it on the libcurl development * or fixed in this file, then, report it on the libcurl development
* mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/ * mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/
* *
* This header file shall only export symbols which are 'curl' or 'CURL' * This header file shall only export symbols which are 'curl' or 'CURL'
* prefixed, otherwise public name space would be polluted. * prefixed, otherwise public name space would be polluted.

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -47,7 +47,7 @@
* library is properly built and used. * library is properly built and used.
* *
* You can find further help on the libcurl development mailing list: * You can find further help on the libcurl development mailing list:
* http://cool.haxx.se/mailman/listinfo/curl-library/ * https://cool.haxx.se/mailman/listinfo/curl-library/
* *
* NOTE 2 * NOTE 2
* ------ * ------

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -26,17 +26,17 @@
a script at release-time. This was made its own header file in 7.11.2 */ a script at release-time. This was made its own header file in 7.11.2 */
/* This is the global package copyright */ /* This is the global package copyright */
#define LIBCURL_COPYRIGHT "1996 - 2015 Daniel Stenberg, <daniel@haxx.se>." #define LIBCURL_COPYRIGHT "1996 - 2016 Daniel Stenberg, <daniel@haxx.se>."
/* 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.44.0" #define LIBCURL_VERSION "7.50.1"
/* 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 44 #define LIBCURL_VERSION_MINOR 50
#define LIBCURL_VERSION_PATCH 0 #define LIBCURL_VERSION_PATCH 1
/* 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
@ -57,7 +57,7 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number. and needs it to contain the full number.
*/ */
#define LIBCURL_VERSION_NUM 0x072C00 #define LIBCURL_VERSION_NUM 0x073201
/* /*
* 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

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -24,8 +24,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> /* needed for FILE */ #include <stdio.h> /* needed for FILE */
#include "curl.h" /* for CURL_EXTERN */
#include "curl.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -44,29 +43,6 @@ CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
CURL_EXTERN char *curl_maprintf(const char *format, ...); CURL_EXTERN char *curl_maprintf(const char *format, ...);
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args); CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
#ifdef _MPRINTF_REPLACE
# undef printf
# undef fprintf
# undef sprintf
# undef vsprintf
# undef snprintf
# undef vprintf
# undef vfprintf
# undef vsnprintf
# undef aprintf
# undef vaprintf
# define printf curl_mprintf
# define fprintf curl_mfprintf
# define sprintf curl_msprintf
# define vsprintf curl_mvsprintf
# define snprintf curl_msnprintf
# define vprintf curl_mvprintf
# define vfprintf curl_mvfprintf
# define vsnprintf curl_mvsnprintf
# define aprintf curl_maprintf
# define vaprintf curl_mvaprintf
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -52,7 +52,11 @@
extern "C" { extern "C" {
#endif #endif
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_multi CURLM;
#else
typedef void CURLM; typedef void CURLM;
#endif
typedef enum { typedef enum {
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -218,60 +218,67 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
/* evaluates to true if option takes a char* argument */ /* evaluates to true if option takes a char* argument */
#define _curl_is_string_option(option) \ #define _curl_is_string_option(option) \
((option) == CURLOPT_URL || \ ((option) == CURLOPT_ACCEPT_ENCODING || \
(option) == CURLOPT_PROXY || \ (option) == CURLOPT_CAINFO || \
(option) == CURLOPT_INTERFACE || \ (option) == CURLOPT_CAPATH || \
(option) == CURLOPT_NETRC_FILE || \
(option) == CURLOPT_USERPWD || \
(option) == CURLOPT_USERNAME || \
(option) == CURLOPT_PASSWORD || \
(option) == CURLOPT_PROXYUSERPWD || \
(option) == CURLOPT_PROXYUSERNAME || \
(option) == CURLOPT_PROXYPASSWORD || \
(option) == CURLOPT_NOPROXY || \
(option) == CURLOPT_ACCEPT_ENCODING || \
(option) == CURLOPT_REFERER || \
(option) == CURLOPT_USERAGENT || \
(option) == CURLOPT_COOKIE || \ (option) == CURLOPT_COOKIE || \
(option) == CURLOPT_COOKIEFILE || \ (option) == CURLOPT_COOKIEFILE || \
(option) == CURLOPT_COOKIEJAR || \ (option) == CURLOPT_COOKIEJAR || \
(option) == CURLOPT_COOKIELIST || \ (option) == CURLOPT_COOKIELIST || \
(option) == CURLOPT_FTPPORT || \
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
(option) == CURLOPT_FTP_ACCOUNT || \
(option) == CURLOPT_RANGE || \
(option) == CURLOPT_CUSTOMREQUEST || \
(option) == CURLOPT_SSLCERT || \
(option) == CURLOPT_SSLCERTTYPE || \
(option) == CURLOPT_SSLKEY || \
(option) == CURLOPT_SSLKEYTYPE || \
(option) == CURLOPT_KEYPASSWD || \
(option) == CURLOPT_SSLENGINE || \
(option) == CURLOPT_CAINFO || \
(option) == CURLOPT_CAPATH || \
(option) == CURLOPT_RANDOM_FILE || \
(option) == CURLOPT_EGDSOCKET || \
(option) == CURLOPT_SSL_CIPHER_LIST || \
(option) == CURLOPT_KRBLEVEL || \
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
(option) == CURLOPT_CRLFILE || \ (option) == CURLOPT_CRLFILE || \
(option) == CURLOPT_ISSUERCERT || \ (option) == CURLOPT_CUSTOMREQUEST || \
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \ (option) == CURLOPT_DEFAULT_PROTOCOL || \
(option) == CURLOPT_SSH_KNOWNHOSTS || \
(option) == CURLOPT_MAIL_FROM || \
(option) == CURLOPT_RTSP_SESSION_ID || \
(option) == CURLOPT_RTSP_STREAM_URI || \
(option) == CURLOPT_RTSP_TRANSPORT || \
(option) == CURLOPT_XOAUTH2_BEARER || \
(option) == CURLOPT_DNS_SERVERS || \
(option) == CURLOPT_DNS_INTERFACE || \ (option) == CURLOPT_DNS_INTERFACE || \
(option) == CURLOPT_DNS_LOCAL_IP4 || \ (option) == CURLOPT_DNS_LOCAL_IP4 || \
(option) == CURLOPT_DNS_LOCAL_IP6 || \ (option) == CURLOPT_DNS_LOCAL_IP6 || \
(option) == CURLOPT_DNS_SERVERS || \
(option) == CURLOPT_EGDSOCKET || \
(option) == CURLOPT_FTPPORT || \
(option) == CURLOPT_FTP_ACCOUNT || \
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
(option) == CURLOPT_INTERFACE || \
(option) == CURLOPT_ISSUERCERT || \
(option) == CURLOPT_KEYPASSWD || \
(option) == CURLOPT_KRBLEVEL || \
(option) == CURLOPT_LOGIN_OPTIONS || \ (option) == CURLOPT_LOGIN_OPTIONS || \
(option) == CURLOPT_MAIL_AUTH || \
(option) == CURLOPT_MAIL_FROM || \
(option) == CURLOPT_NETRC_FILE || \
(option) == CURLOPT_NOPROXY || \
(option) == CURLOPT_PASSWORD || \
(option) == CURLOPT_PINNEDPUBLICKEY || \
(option) == CURLOPT_PROXY || \
(option) == CURLOPT_PROXYPASSWORD || \
(option) == CURLOPT_PROXYUSERNAME || \
(option) == CURLOPT_PROXYUSERPWD || \
(option) == CURLOPT_PROXY_SERVICE_NAME || \ (option) == CURLOPT_PROXY_SERVICE_NAME || \
(option) == CURLOPT_RANDOM_FILE || \
(option) == CURLOPT_RANGE || \
(option) == CURLOPT_REFERER || \
(option) == CURLOPT_RTSP_SESSION_ID || \
(option) == CURLOPT_RTSP_STREAM_URI || \
(option) == CURLOPT_RTSP_TRANSPORT || \
(option) == CURLOPT_SERVICE_NAME || \ (option) == CURLOPT_SERVICE_NAME || \
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
(option) == CURLOPT_SSH_KNOWNHOSTS || \
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
(option) == CURLOPT_SSLCERT || \
(option) == CURLOPT_SSLCERTTYPE || \
(option) == CURLOPT_SSLENGINE || \
(option) == CURLOPT_SSLKEY || \
(option) == CURLOPT_SSLKEYTYPE || \
(option) == CURLOPT_SSL_CIPHER_LIST || \
(option) == CURLOPT_TLSAUTH_PASSWORD || \
(option) == CURLOPT_TLSAUTH_TYPE || \
(option) == CURLOPT_TLSAUTH_USERNAME || \
(option) == CURLOPT_UNIX_SOCKET_PATH || \
(option) == CURLOPT_URL || \
(option) == CURLOPT_USERAGENT || \
(option) == CURLOPT_USERNAME || \
(option) == CURLOPT_USERPWD || \
(option) == CURLOPT_XOAUTH2_BEARER || \
0) 0)
/* evaluates to true if option takes a curl_write_callback argument */ /* evaluates to true if option takes a curl_write_callback argument */
@ -287,21 +294,22 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
/* evaluates to true if option takes a data argument to pass to a callback */ /* evaluates to true if option takes a data argument to pass to a callback */
#define _curl_is_cb_data_option(option) \ #define _curl_is_cb_data_option(option) \
((option) == CURLOPT_WRITEDATA || \ ((option) == CURLOPT_CHUNK_DATA || \
(option) == CURLOPT_READDATA || \ (option) == CURLOPT_CLOSESOCKETDATA || \
(option) == CURLOPT_IOCTLDATA || \
(option) == CURLOPT_SOCKOPTDATA || \
(option) == CURLOPT_OPENSOCKETDATA || \
(option) == CURLOPT_PROGRESSDATA || \
(option) == CURLOPT_HEADERDATA || \
(option) == CURLOPT_DEBUGDATA || \ (option) == CURLOPT_DEBUGDATA || \
(option) == CURLOPT_SSL_CTX_DATA || \
(option) == CURLOPT_SEEKDATA || \
(option) == CURLOPT_PRIVATE || \
(option) == CURLOPT_SSH_KEYDATA || \
(option) == CURLOPT_INTERLEAVEDATA || \
(option) == CURLOPT_CHUNK_DATA || \
(option) == CURLOPT_FNMATCH_DATA || \ (option) == CURLOPT_FNMATCH_DATA || \
(option) == CURLOPT_HEADERDATA || \
(option) == CURLOPT_INTERLEAVEDATA || \
(option) == CURLOPT_IOCTLDATA || \
(option) == CURLOPT_OPENSOCKETDATA || \
(option) == CURLOPT_PRIVATE || \
(option) == CURLOPT_PROGRESSDATA || \
(option) == CURLOPT_READDATA || \
(option) == CURLOPT_SEEKDATA || \
(option) == CURLOPT_SOCKOPTDATA || \
(option) == CURLOPT_SSH_KEYDATA || \
(option) == CURLOPT_SSL_CTX_DATA || \
(option) == CURLOPT_WRITEDATA || \
0) 0)
/* evaluates to true if option takes a POST data argument (void* or char*) */ /* evaluates to true if option takes a POST data argument (void* or char*) */
@ -312,13 +320,15 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
/* evaluates to true if option takes a struct curl_slist * argument */ /* evaluates to true if option takes a struct curl_slist * argument */
#define _curl_is_slist_option(option) \ #define _curl_is_slist_option(option) \
((option) == CURLOPT_HTTPHEADER || \ ((option) == CURLOPT_HTTP200ALIASES || \
(option) == CURLOPT_HTTP200ALIASES || \ (option) == CURLOPT_HTTPHEADER || \
(option) == CURLOPT_QUOTE || \ (option) == CURLOPT_MAIL_RCPT || \
(option) == CURLOPT_POSTQUOTE || \ (option) == CURLOPT_POSTQUOTE || \
(option) == CURLOPT_PREQUOTE || \ (option) == CURLOPT_PREQUOTE || \
(option) == CURLOPT_PROXYHEADER || \
(option) == CURLOPT_QUOTE || \
(option) == CURLOPT_RESOLVE || \
(option) == CURLOPT_TELNETOPTIONS || \ (option) == CURLOPT_TELNETOPTIONS || \
(option) == CURLOPT_MAIL_RCPT || \
0) 0)
/* groups of curl_easy_getinfo infos that take the same type of argument */ /* groups of curl_easy_getinfo infos that take the same type of argument */

View File

@ -5,11 +5,11 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
# #
# Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. # Copyright (C) 1998 - 2016, 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
# are also available at http://curl.haxx.se/docs/copyright.html. # are also available at https://curl.haxx.se/docs/copyright.html.
# #
# You may opt to use, copy, modify, merge, publish, distribute and/or sell # You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is # copies of the Software, and permit persons to whom the Software is
@ -20,13 +20,22 @@
# #
########################################################################### ###########################################################################
LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c vauth/cram.c \
vauth/digest.c vauth/digest_sspi.c vauth/krb5_gssapi.c \
vauth/krb5_sspi.c vauth/ntlm.c vauth/ntlm_sspi.c vauth/oauth2.c \
vauth/spnego_gssapi.c vauth/spnego_sspi.c
LIB_VAUTH_HFILES = vauth/vauth.h vauth/digest.h vauth/ntlm.h
LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \ LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \
vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \ vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \
vtls/cyassl.c vtls/schannel.c vtls/darwinssl.c vtls/gskit.c vtls/cyassl.c vtls/schannel.c vtls/darwinssl.c vtls/gskit.c \
vtls/mbedtls.c
LIB_VTLS_HFILES = vtls/openssl.h vtls/vtls.h vtls/gtls.h \ LIB_VTLS_HFILES = vtls/openssl.h vtls/vtls.h vtls/gtls.h \
vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h vtls/axtls.h \ vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h vtls/axtls.h \
vtls/cyassl.h vtls/schannel.h vtls/darwinssl.h vtls/gskit.h vtls/cyassl.h vtls/schannel.h vtls/darwinssl.h vtls/gskit.h \
vtls/mbedtls.h
LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \ cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \
@ -41,12 +50,10 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \ curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \ pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \
openldap.c curl_gethostname.c gopher.c idn_win32.c \ openldap.c curl_gethostname.c gopher.c idn_win32.c \
http_negotiate_sspi.c http_proxy.c non-ascii.c asyn-ares.c \ http_proxy.c non-ascii.c asyn-ares.c asyn-thread.c curl_gssapi.c \
asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c \ http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c \
curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c \ curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \
hostcheck.c conncache.c pipeline.c dotdot.c x509asn1.c \ x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c
http2.c curl_sasl_sspi.c smb.c curl_sasl_gssapi.c curl_endian.c \
curl_des.c
LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
@ -61,13 +68,13 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
slist.h nonblock.h curl_memrchr.h imap.h pop3.h smtp.h pingpong.h \ slist.h nonblock.h curl_memrchr.h imap.h pop3.h smtp.h pingpong.h \
rtsp.h curl_threads.h warnless.h curl_hmac.h curl_rtmp.h \ rtsp.h curl_threads.h warnless.h curl_hmac.h curl_rtmp.h \
curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \ curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \
curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \ http_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \
curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h \ curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \
conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h \ curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \
dotdot.h x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \
curl_printf.h curl_printf.h system_win32.h
LIB_RCFILES = libcurl.rc LIB_RCFILES = libcurl.rc
CSOURCES = $(LIB_CFILES) $(LIB_VTLS_CFILES) CSOURCES = $(LIB_CFILES) $(LIB_VAUTH_CFILES) $(LIB_VTLS_CFILES)
HHEADERS = $(LIB_HFILES) $(LIB_VTLS_HFILES) HHEADERS = $(LIB_HFILES) $(LIB_VAUTH_HFILES) $(LIB_VTLS_HFILES)

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -35,7 +35,7 @@ extern int errno, h_errno;
#include <stabs.h> #include <stabs.h>
void __request(const char *msg); void __request(const char *msg);
#else #else
# define __request( msg ) Printf( msg "\n\a") # define __request(msg) Printf(msg "\n\a")
#endif #endif
void Curl_amiga_cleanup() void Curl_amiga_cleanup()

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -68,7 +68,6 @@
#include "connect.h" #include "connect.h"
#include "select.h" #include "select.h"
#include "progress.h" #include "progress.h"
#include "curl_printf.h"
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \ # if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)) (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
@ -83,8 +82,9 @@
#define HAVE_CARES_CALLBACK_TIMEOUTS 1 #define HAVE_CARES_CALLBACK_TIMEOUTS 1
#endif #endif
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
struct ResolverResults { struct ResolverResults {
@ -249,7 +249,7 @@ int Curl_resolver_getsock(struct connectdata *conn,
static int waitperform(struct connectdata *conn, int timeout_ms) static int waitperform(struct connectdata *conn, int timeout_ms)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
int nfds; int nfds;
int bitmask; int bitmask;
ares_socket_t socks[ARES_GETSOCK_MAXNUM]; ares_socket_t socks[ARES_GETSOCK_MAXNUM];
@ -309,7 +309,7 @@ static int waitperform(struct connectdata *conn, int timeout_ms)
CURLcode Curl_resolver_is_resolved(struct connectdata *conn, CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
struct Curl_dns_entry **dns) struct Curl_dns_entry **dns)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ResolverResults *res = (struct ResolverResults *) struct ResolverResults *res = (struct ResolverResults *)
conn->async.os_specific; conn->async.os_specific;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -353,7 +353,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
struct Curl_dns_entry **entry) struct Curl_dns_entry **entry)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
long timeout; long timeout;
struct timeval now = Curl_tvnow(); struct timeval now = Curl_tvnow();
struct Curl_dns_entry *temp_entry; struct Curl_dns_entry *temp_entry;
@ -492,7 +492,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
int *waitp) int *waitp)
{ {
char *bufp; char *bufp;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct in_addr in; struct in_addr in;
int family = PF_INET; int family = PF_INET;
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */ #ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
@ -583,7 +583,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
return NULL; /* no struct yet */ return NULL; /* no struct yet */
} }
CURLcode Curl_set_dns_servers(struct SessionHandle *data, CURLcode Curl_set_dns_servers(struct Curl_easy *data,
char *servers) char *servers)
{ {
CURLcode result = CURLE_NOT_BUILT_IN; CURLcode result = CURLE_NOT_BUILT_IN;
@ -621,7 +621,7 @@ CURLcode Curl_set_dns_servers(struct SessionHandle *data,
return result; return result;
} }
CURLcode Curl_set_dns_interface(struct SessionHandle *data, CURLcode Curl_set_dns_interface(struct Curl_easy *data,
const char *interf) const char *interf)
{ {
#if (ARES_VERSION >= 0x010704) #if (ARES_VERSION >= 0x010704)
@ -638,7 +638,7 @@ CURLcode Curl_set_dns_interface(struct SessionHandle *data,
#endif #endif
} }
CURLcode Curl_set_dns_local_ip4(struct SessionHandle *data, CURLcode Curl_set_dns_local_ip4(struct Curl_easy *data,
const char *local_ip4) const char *local_ip4)
{ {
#if (ARES_VERSION >= 0x010704) #if (ARES_VERSION >= 0x010704)
@ -663,7 +663,7 @@ CURLcode Curl_set_dns_local_ip4(struct SessionHandle *data,
#endif #endif
} }
CURLcode Curl_set_dns_local_ip6(struct SessionHandle *data, CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
const char *local_ip6) const char *local_ip6)
{ {
#if (ARES_VERSION >= 0x010704) && defined(ENABLE_IPV6) #if (ARES_VERSION >= 0x010704) && defined(ENABLE_IPV6)

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -69,10 +69,9 @@
#include "inet_ntop.h" #include "inet_ntop.h"
#include "curl_threads.h" #include "curl_threads.h"
#include "connect.h" #include "connect.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
/*********************************************************************** /***********************************************************************
@ -280,6 +279,9 @@ static unsigned int CURL_STDCALL getaddrinfo_thread (void *arg)
if(tsd->sock_error == 0) if(tsd->sock_error == 0)
tsd->sock_error = RESOLVER_ENOMEM; tsd->sock_error = RESOLVER_ENOMEM;
} }
else {
Curl_addrinfo_set_port(tsd->res, tsd->port);
}
Curl_mutex_acquire(tsd->mtx); Curl_mutex_acquire(tsd->mtx);
if(tsd->done) { if(tsd->done) {
@ -495,7 +497,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
CURLcode Curl_resolver_is_resolved(struct connectdata *conn, CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
struct Curl_dns_entry **entry) struct Curl_dns_entry **entry)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct thread_data *td = (struct thread_data*) conn->async.os_specific; struct thread_data *td = (struct thread_data*) conn->async.os_specific;
int done = 0; int done = 0;
@ -603,6 +605,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
*waitp = 0; /* default to synchronous response */ *waitp = 0; /* default to synchronous response */
#ifndef USE_RESOLVE_ON_IPS
/* First check if this is an IPv4 address string */ /* First check if this is an IPv4 address string */
if(Curl_inet_pton(AF_INET, hostname, &in) > 0) if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
/* This is a dotted IP address 123.123.123.123-style */ /* This is a dotted IP address 123.123.123.123-style */
@ -610,10 +613,13 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
#ifdef CURLRES_IPV6 #ifdef CURLRES_IPV6
/* check if this is an IPv6 address string */ /* check if this is an IPv6 address string */
if(Curl_inet_pton (AF_INET6, hostname, &in6) > 0) if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
/* This is an IPv6 address literal */ /* This is an IPv6 address literal */
return Curl_ip2addr(AF_INET6, &in6, hostname, port); return Curl_ip2addr(AF_INET6, &in6, hostname, port);
#endif /* CURLRES_IPV6 */
#endif /* !USE_RESOLVE_ON_IPS */
#ifdef CURLRES_IPV6
/* /*
* Check if a limited name resolve has been requested. * Check if a limited name resolve has been requested.
*/ */
@ -632,7 +638,6 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
if((pf != PF_INET) && !Curl_ipv6works()) if((pf != PF_INET) && !Curl_ipv6works())
/* The stack seems to be a non-IPv6 one */ /* The stack seems to be a non-IPv6 one */
pf = PF_INET; pf = PF_INET;
#endif /* CURLRES_IPV6 */ #endif /* CURLRES_IPV6 */
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
@ -657,12 +662,16 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
hostname, port, Curl_strerror(conn, SOCKERRNO)); hostname, port, Curl_strerror(conn, SOCKERRNO));
return NULL; return NULL;
} }
else {
Curl_addrinfo_set_port(res, port);
}
return res; return res;
} }
#endif /* !HAVE_GETADDRINFO */ #endif /* !HAVE_GETADDRINFO */
CURLcode Curl_set_dns_servers(struct SessionHandle *data, CURLcode Curl_set_dns_servers(struct Curl_easy *data,
char *servers) char *servers)
{ {
(void)data; (void)data;
@ -671,7 +680,7 @@ CURLcode Curl_set_dns_servers(struct SessionHandle *data,
} }
CURLcode Curl_set_dns_interface(struct SessionHandle *data, CURLcode Curl_set_dns_interface(struct Curl_easy *data,
const char *interf) const char *interf)
{ {
(void)data; (void)data;
@ -679,7 +688,7 @@ CURLcode Curl_set_dns_interface(struct SessionHandle *data,
return CURLE_NOT_BUILT_IN; return CURLE_NOT_BUILT_IN;
} }
CURLcode Curl_set_dns_local_ip4(struct SessionHandle *data, CURLcode Curl_set_dns_local_ip4(struct Curl_easy *data,
const char *local_ip4) const char *local_ip4)
{ {
(void)data; (void)data;
@ -687,7 +696,7 @@ CURLcode Curl_set_dns_local_ip4(struct SessionHandle *data,
return CURLE_NOT_BUILT_IN; return CURLE_NOT_BUILT_IN;
} }
CURLcode Curl_set_dns_local_ip6(struct SessionHandle *data, CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
const char *local_ip6) const char *local_ip6)
{ {
(void)data; (void)data;

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -27,7 +27,7 @@
struct addrinfo; struct addrinfo;
struct hostent; struct hostent;
struct SessionHandle; struct Curl_easy;
struct connectdata; struct connectdata;
struct Curl_dns_entry; struct Curl_dns_entry;

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -23,13 +23,13 @@
/* Base64 encoding/decoding */ /* Base64 encoding/decoding */
#include "curl_setup.h" #include "curl_setup.h"
#include "curl_printf.h" #include "urldata.h" /* for the Curl_easy definition */
#include "urldata.h" /* for the SessionHandle definition */
#include "warnless.h" #include "warnless.h"
#include "curl_base64.h" #include "curl_base64.h"
#include "non-ascii.h" #include "non-ascii.h"
/* The last #include files should be: */ /* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -169,11 +169,11 @@ CURLcode Curl_base64_decode(const char *src,
} }
static CURLcode base64_encode(const char *table64, static CURLcode base64_encode(const char *table64,
struct SessionHandle *data, struct Curl_easy *data,
const char *inputbuff, size_t insize, const char *inputbuff, size_t insize,
char **outptr, size_t *outlen) char **outptr, size_t *outlen)
{ {
CURLcode error; CURLcode result;
unsigned char ibuf[3]; unsigned char ibuf[3];
unsigned char obuf[4]; unsigned char obuf[4];
int i; int i;
@ -187,11 +187,11 @@ static CURLcode base64_encode(const char *table64,
*outptr = NULL; *outptr = NULL;
*outlen = 0; *outlen = 0;
if(0 == insize) if(!insize)
insize = strlen(indata); insize = strlen(indata);
base64data = output = malloc(insize*4/3+4); base64data = output = malloc(insize * 4 / 3 + 4);
if(NULL == output) if(!output)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
/* /*
@ -199,10 +199,10 @@ static CURLcode base64_encode(const char *table64,
* not the host encoding. And we can't change the actual input * not the host encoding. And we can't change the actual input
* so we copy it to a buffer, translate it, and use that instead. * so we copy it to a buffer, translate it, and use that instead.
*/ */
error = Curl_convert_clone(data, indata, insize, &convbuf); result = Curl_convert_clone(data, indata, insize, &convbuf);
if(error) { if(result) {
free(output); free(output);
return error; return result;
} }
if(convbuf) if(convbuf)
@ -233,28 +233,35 @@ static CURLcode base64_encode(const char *table64,
table64[obuf[0]], table64[obuf[0]],
table64[obuf[1]]); table64[obuf[1]]);
break; break;
case 2: /* two bytes read */ case 2: /* two bytes read */
snprintf(output, 5, "%c%c%c=", snprintf(output, 5, "%c%c%c=",
table64[obuf[0]], table64[obuf[0]],
table64[obuf[1]], table64[obuf[1]],
table64[obuf[2]]); table64[obuf[2]]);
break; break;
default: default:
snprintf(output, 5, "%c%c%c%c", snprintf(output, 5, "%c%c%c%c",
table64[obuf[0]], table64[obuf[0]],
table64[obuf[1]], table64[obuf[1]],
table64[obuf[2]], table64[obuf[2]],
table64[obuf[3]] ); table64[obuf[3]]);
break; break;
} }
output += 4; output += 4;
} }
/* Zero terminate */
*output = '\0'; *output = '\0';
*outptr = base64data; /* return pointer to new data, allocated memory */
/* Return the pointer to the new data (allocated memory) */
*outptr = base64data;
free(convbuf); free(convbuf);
*outlen = strlen(base64data); /* return the length of the new data */ /* Return the length of the new data */
*outlen = strlen(base64data);
return CURLE_OK; return CURLE_OK;
} }
@ -276,7 +283,7 @@ static CURLcode base64_encode(const char *table64,
* *
* @unittest: 1302 * @unittest: 1302
*/ */
CURLcode Curl_base64_encode(struct SessionHandle *data, CURLcode Curl_base64_encode(struct Curl_easy *data,
const char *inputbuff, size_t insize, const char *inputbuff, size_t insize,
char **outptr, size_t *outlen) char **outptr, size_t *outlen)
{ {
@ -300,10 +307,9 @@ CURLcode Curl_base64_encode(struct SessionHandle *data,
* *
* @unittest: 1302 * @unittest: 1302
*/ */
CURLcode Curl_base64url_encode(struct SessionHandle *data, CURLcode Curl_base64url_encode(struct Curl_easy *data,
const char *inputbuff, size_t insize, const char *inputbuff, size_t insize,
char **outptr, size_t *outlen) char **outptr, size_t *outlen)
{ {
return base64_encode(base64url, data, inputbuff, insize, outptr, outlen); return base64_encode(base64url, data, inputbuff, insize, outptr, outlen);
} }
/* ---- End of Base64 Encoding ---- */

View File

@ -5,12 +5,12 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2012, Linus Nielsen Feltzing, <linus@haxx.se> * Copyright (C) 2012, 2016, Linus Nielsen Feltzing, <linus@haxx.se>
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2015, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -32,10 +32,9 @@
#include "sendf.h" #include "sendf.h"
#include "rawstr.h" #include "rawstr.h"
#include "conncache.h" #include "conncache.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
static void conn_llist_dtor(void *user, void *element) static void conn_llist_dtor(void *user, void *element)
@ -46,7 +45,7 @@ static void conn_llist_dtor(void *user, void *element)
data->bundle = NULL; data->bundle = NULL;
} }
static CURLcode bundle_create(struct SessionHandle *data, static CURLcode bundle_create(struct Curl_easy *data,
struct connectbundle **cb_ptr) struct connectbundle **cb_ptr)
{ {
(void)data; (void)data;
@ -132,9 +131,16 @@ void Curl_conncache_destroy(struct conncache *connc)
/* returns an allocated key to find a bundle for this connection */ /* returns an allocated key to find a bundle for this connection */
static char *hashkey(struct connectdata *conn) static char *hashkey(struct connectdata *conn)
{ {
return aprintf("%s:%d", const char *hostname;
conn->bits.proxy?conn->proxy.name:conn->host.name,
conn->localport); if(conn->bits.proxy)
hostname = conn->proxy.name;
else if(conn->bits.conn_to_host)
hostname = conn->conn_to_host.name;
else
hostname = conn->host.name;
return aprintf("%s:%d", hostname, conn->port);
} }
/* Look up the bundle with all the connections to the same host this /* Look up the bundle with all the connections to the same host this
@ -193,7 +199,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
CURLcode result; CURLcode result;
struct connectbundle *bundle; struct connectbundle *bundle;
struct connectbundle *new_bundle = NULL; struct connectbundle *new_bundle = NULL;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache); bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache);
if(!bundle) { if(!bundle) {

View File

@ -12,7 +12,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -56,7 +56,6 @@
#include <inet.h> #include <inet.h>
#endif #endif
#include "curl_printf.h"
#include "urldata.h" #include "urldata.h"
#include "sendf.h" #include "sendf.h"
#include "if2ip.h" #include "if2ip.h"
@ -73,8 +72,10 @@
#include "warnless.h" #include "warnless.h"
#include "conncache.h" #include "conncache.h"
#include "multihandle.h" #include "multihandle.h"
#include "system_win32.h"
/* The last #include files should be: */ /* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -103,7 +104,7 @@ struct tcp_keepalive {
#endif #endif
static void static void
tcpkeepalive(struct SessionHandle *data, tcpkeepalive(struct Curl_easy *data,
curl_socket_t sockfd) curl_socket_t sockfd)
{ {
int optval = data->set.tcp_keepalive?1:0; int optval = data->set.tcp_keepalive?1:0;
@ -178,7 +179,7 @@ singleipconnect(struct connectdata *conn,
* *
* @unittest: 1303 * @unittest: 1303
*/ */
long Curl_timeleft(struct SessionHandle *data, long Curl_timeleft(struct Curl_easy *data,
struct timeval *nowp, struct timeval *nowp,
bool duringconnect) bool duringconnect)
{ {
@ -238,7 +239,7 @@ long Curl_timeleft(struct SessionHandle *data,
static CURLcode bindlocal(struct connectdata *conn, static CURLcode bindlocal(struct connectdata *conn,
curl_socket_t sockfd, int af, unsigned int scope) curl_socket_t sockfd, int af, unsigned int scope)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct Curl_sockaddr_storage sa; struct Curl_sockaddr_storage sa;
struct sockaddr *sock = (struct sockaddr *)&sa; /* bind to this address */ struct sockaddr *sock = (struct sockaddr *)&sa; /* bind to this address */
@ -619,7 +620,7 @@ static bool getaddressinfo(struct sockaddr* sa, char* addr,
switch (sa->sa_family) { switch (sa->sa_family) {
case AF_INET: case AF_INET:
si = (struct sockaddr_in*) sa; si = (struct sockaddr_in*)(void*) sa;
if(Curl_inet_ntop(sa->sa_family, &si->sin_addr, if(Curl_inet_ntop(sa->sa_family, &si->sin_addr,
addr, MAX_IPADR_LEN)) { addr, MAX_IPADR_LEN)) {
us_port = ntohs(si->sin_port); us_port = ntohs(si->sin_port);
@ -629,7 +630,7 @@ static bool getaddressinfo(struct sockaddr* sa, char* addr,
break; break;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
case AF_INET6: case AF_INET6:
si6 = (struct sockaddr_in6*)sa; si6 = (struct sockaddr_in6*)(void*) sa;
if(Curl_inet_ntop(sa->sa_family, &si6->sin6_addr, if(Curl_inet_ntop(sa->sa_family, &si6->sin6_addr,
addr, MAX_IPADR_LEN)) { addr, MAX_IPADR_LEN)) {
us_port = ntohs(si6->sin6_port); us_port = ntohs(si6->sin6_port);
@ -662,13 +663,13 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
curl_socklen_t len; curl_socklen_t len;
struct Curl_sockaddr_storage ssrem; struct Curl_sockaddr_storage ssrem;
struct Curl_sockaddr_storage ssloc; struct Curl_sockaddr_storage ssloc;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
if(conn->socktype == SOCK_DGRAM) if(conn->socktype == SOCK_DGRAM)
/* there's no connection! */ /* there's no connection! */
return; return;
if(!conn->bits.reuse) { if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
int error; int error;
len = sizeof(struct Curl_sockaddr_storage); len = sizeof(struct Curl_sockaddr_storage);
@ -719,7 +720,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
int sockindex, int sockindex,
bool *connected) bool *connected)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
long allow; long allow;
int error = 0; int error = 0;
@ -764,6 +765,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
rc = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0); rc = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0);
if(rc == 0) { /* no connection yet */ if(rc == 0) { /* no connection yet */
error = 0;
if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) { if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) {
infof(data, "After %ldms connect time, move on!\n", infof(data, "After %ldms connect time, move on!\n",
conn->timeoutms_per_addr); conn->timeoutms_per_addr);
@ -776,7 +778,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
trynextip(conn, sockindex, 1); trynextip(conn, sockindex, 1);
} }
} }
else if(rc == CURL_CSELECT_OUT) { else if(rc == CURL_CSELECT_OUT || conn->bits.tcp_fastopen) {
if(verifyconnect(conn->tempsock[i], &error)) { if(verifyconnect(conn->tempsock[i], &error)) {
/* we are connected with TCP, awesome! */ /* we are connected with TCP, awesome! */
@ -841,6 +843,8 @@ CURLcode Curl_is_connected(struct connectdata *conn,
if(result) { if(result) {
/* no more addresses to try */ /* no more addresses to try */
const char* hostname;
/* if the first address family runs out of addresses to try before /* if the first address family runs out of addresses to try before
the happy eyeball timeout, go ahead and try the next family now */ the happy eyeball timeout, go ahead and try the next family now */
if(conn->tempaddr[1] == NULL) { if(conn->tempaddr[1] == NULL) {
@ -849,20 +853,27 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return result; return result;
} }
if(conn->bits.proxy)
hostname = conn->proxy.name;
else if(conn->bits.conn_to_host)
hostname = conn->conn_to_host.name;
else
hostname = conn->host.name;
failf(data, "Failed to connect to %s port %ld: %s", failf(data, "Failed to connect to %s port %ld: %s",
conn->bits.proxy?conn->proxy.name:conn->host.name, hostname, conn->port, Curl_strerror(conn, error));
conn->port, Curl_strerror(conn, error));
} }
return result; return result;
} }
static void tcpnodelay(struct connectdata *conn, void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
curl_socket_t sockfd)
{ {
#ifdef TCP_NODELAY #if defined(TCP_NODELAY)
struct SessionHandle *data= conn->data; #if !defined(CURL_DISABLE_VERBOSE_STRINGS)
curl_socklen_t onoff = (curl_socklen_t) data->set.tcp_nodelay; struct Curl_easy *data = conn->data;
#endif
curl_socklen_t onoff = (curl_socklen_t) 1;
int level = IPPROTO_TCP; int level = IPPROTO_TCP;
#if 0 #if 0
@ -878,6 +889,10 @@ static void tcpnodelay(struct connectdata *conn,
level = pe->p_proto; level = pe->p_proto;
#endif #endif
#if defined(CURL_DISABLE_VERBOSE_STRINGS)
(void) conn;
#endif
if(setsockopt(sockfd, level, TCP_NODELAY, (void *)&onoff, if(setsockopt(sockfd, level, TCP_NODELAY, (void *)&onoff,
sizeof(onoff)) < 0) sizeof(onoff)) < 0)
infof(data, "Could not set TCP_NODELAY: %s\n", infof(data, "Could not set TCP_NODELAY: %s\n",
@ -898,7 +913,7 @@ static void tcpnodelay(struct connectdata *conn,
static void nosigpipe(struct connectdata *conn, static void nosigpipe(struct connectdata *conn,
curl_socket_t sockfd) curl_socket_t sockfd)
{ {
struct SessionHandle *data= conn->data; struct Curl_easy *data= conn->data;
int onoff = 1; int onoff = 1;
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff, if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
sizeof(onoff)) < 0) sizeof(onoff)) < 0)
@ -913,7 +928,7 @@ static void nosigpipe(struct connectdata *conn,
/* When you run a program that uses the Windows Sockets API, you may /* When you run a program that uses the Windows Sockets API, you may
experience slow performance when you copy data to a TCP server. experience slow performance when you copy data to a TCP server.
http://support.microsoft.com/kb/823764 https://support.microsoft.com/kb/823764
Work-around: Make the Socket Send Buffer Size Larger Than the Program Send Work-around: Make the Socket Send Buffer Size Larger Than the Program Send
Buffer Size Buffer Size
@ -931,43 +946,15 @@ void Curl_sndbufset(curl_socket_t sockfd)
int val = CURL_MAX_WRITE_SIZE + 32; int val = CURL_MAX_WRITE_SIZE + 32;
int curval = 0; int curval = 0;
int curlen = sizeof(curval); int curlen = sizeof(curval);
DWORD majorVersion = 6;
static int detectOsState = DETECT_OS_NONE; static int detectOsState = DETECT_OS_NONE;
if(detectOsState == DETECT_OS_NONE) { if(detectOsState == DETECT_OS_NONE) {
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \ if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT,
(_WIN32_WINNT < _WIN32_WINNT_WIN2K) VERSION_GREATER_THAN_EQUAL))
OSVERSIONINFO osver;
memset(&osver, 0, sizeof(osver));
osver.dwOSVersionInfoSize = sizeof(osver);
detectOsState = DETECT_OS_PREVISTA;
if(GetVersionEx(&osver)) {
if(osver.dwMajorVersion >= majorVersion)
detectOsState = DETECT_OS_VISTA_OR_LATER;
}
#else
ULONGLONG cm;
OSVERSIONINFOEX osver;
memset(&osver, 0, sizeof(osver));
osver.dwOSVersionInfoSize = sizeof(osver);
osver.dwMajorVersion = majorVersion;
cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_GREATER_EQUAL);
cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
cm))
detectOsState = DETECT_OS_VISTA_OR_LATER; detectOsState = DETECT_OS_VISTA_OR_LATER;
else else
detectOsState = DETECT_OS_PREVISTA; detectOsState = DETECT_OS_PREVISTA;
#endif
} }
if(detectOsState == DETECT_OS_VISTA_OR_LATER) if(detectOsState == DETECT_OS_VISTA_OR_LATER)
@ -995,10 +982,10 @@ static CURLcode singleipconnect(struct connectdata *conn,
curl_socket_t *sockp) curl_socket_t *sockp)
{ {
struct Curl_sockaddr_ex addr; struct Curl_sockaddr_ex addr;
int rc; int rc = -1;
int error = 0; int error = 0;
bool isconnected = FALSE; bool isconnected = FALSE;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
curl_socket_t sockfd; curl_socket_t sockfd;
CURLcode result; CURLcode result;
char ipaddress[MAX_IPADR_LEN]; char ipaddress[MAX_IPADR_LEN];
@ -1033,7 +1020,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
is_tcp = (addr.family == AF_INET) && addr.socktype == SOCK_STREAM; is_tcp = (addr.family == AF_INET) && addr.socktype == SOCK_STREAM;
#endif #endif
if(is_tcp && data->set.tcp_nodelay) if(is_tcp && data->set.tcp_nodelay)
tcpnodelay(conn, sockfd); Curl_tcpnodelay(conn, sockfd);
nosigpipe(conn, sockfd); nosigpipe(conn, sockfd);
@ -1084,7 +1071,29 @@ static CURLcode singleipconnect(struct connectdata *conn,
/* Connect TCP sockets, bind UDP */ /* Connect TCP sockets, bind UDP */
if(!isconnected && (conn->socktype == SOCK_STREAM)) { if(!isconnected && (conn->socktype == SOCK_STREAM)) {
rc = connect(sockfd, &addr.sa_addr, addr.addrlen); if(conn->bits.tcp_fastopen) {
#if defined(CONNECT_DATA_IDEMPOTENT) /* OS X */
sa_endpoints_t endpoints;
endpoints.sae_srcif = 0;
endpoints.sae_srcaddr = NULL;
endpoints.sae_srcaddrlen = 0;
endpoints.sae_dstaddr = &addr.sa_addr;
endpoints.sae_dstaddrlen = addr.addrlen;
rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT,
NULL, 0, NULL, NULL);
#elif defined(MSG_FASTOPEN) /* Linux */
if(conn->given->flags & PROTOPT_SSL)
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
else
rc = 0; /* Do nothing */
#endif
}
else {
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
}
if(-1 == rc) if(-1 == rc)
error = SOCKERRNO; error = SOCKERRNO;
} }
@ -1140,7 +1149,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
CURLcode Curl_connecthost(struct connectdata *conn, /* context */ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
const struct Curl_dns_entry *remotehost) const struct Curl_dns_entry *remotehost)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct timeval before = Curl_tvnow(); struct timeval before = Curl_tvnow();
CURLcode result = CURLE_COULDNT_CONNECT; CURLcode result = CURLE_COULDNT_CONNECT;
@ -1199,11 +1208,11 @@ static int conn_is_conn(struct connectdata *conn, void *param)
/* /*
* Used to extract socket and connectdata struct for the most recent * Used to extract socket and connectdata struct for the most recent
* transfer on the given SessionHandle. * transfer on the given Curl_easy.
* *
* The returned socket will be CURL_SOCKET_BAD in case of failure! * The returned socket will be CURL_SOCKET_BAD in case of failure!
*/ */
curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
struct connectdata **connp) struct connectdata **connp)
{ {
curl_socket_t sockfd; curl_socket_t sockfd;
@ -1243,10 +1252,10 @@ curl_socket_t Curl_getconnectinfo(struct SessionHandle *data,
} }
/* 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 */
#ifdef MSG_PEEK #ifdef MSG_PEEK
else { else if(sockfd != CURL_SOCKET_BAD) {
/* use the socket */ /* use the socket */
char buf; char buf;
if(recv((RECV_TYPE_ARG1)c->sock[FIRSTSOCKET], (RECV_TYPE_ARG2)&buf, if(recv((RECV_TYPE_ARG1)sockfd, (RECV_TYPE_ARG2)&buf,
(RECV_TYPE_ARG3)1, (RECV_TYPE_ARG4)MSG_PEEK) == 0) { (RECV_TYPE_ARG3)1, (RECV_TYPE_ARG4)MSG_PEEK) == 0) {
return CURL_SOCKET_BAD; /* FIN received */ return CURL_SOCKET_BAD; /* FIN received */
} }
@ -1303,7 +1312,7 @@ CURLcode Curl_socket(struct connectdata *conn,
struct Curl_sockaddr_ex *addr, struct Curl_sockaddr_ex *addr,
curl_socket_t *sockfd) curl_socket_t *sockfd)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct Curl_sockaddr_ex dummy; struct Curl_sockaddr_ex dummy;
if(!addr) if(!addr)

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2015, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -35,7 +35,7 @@ CURLcode Curl_connecthost(struct connectdata *conn,
/* generic function that returns how much time there's left to run, according /* generic function that returns how much time there's left to run, according
to the timeouts set */ to the timeouts set */
long Curl_timeleft(struct SessionHandle *data, long Curl_timeleft(struct Curl_easy *data,
struct timeval *nowp, struct timeval *nowp,
bool duringconnect); bool duringconnect);
@ -45,18 +45,18 @@ long Curl_timeleft(struct SessionHandle *data,
/* /*
* Used to extract socket and connectdata struct for the most recent * Used to extract socket and connectdata struct for the most recent
* transfer on the given SessionHandle. * transfer on the given Curl_easy.
* *
* The returned socket will be CURL_SOCKET_BAD in case of failure! * The returned socket will be CURL_SOCKET_BAD in case of failure!
*/ */
curl_socket_t Curl_getconnectinfo(struct SessionHandle *data, curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
struct connectdata **connp); struct connectdata **connp);
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
/* When you run a program that uses the Windows Sockets API, you may /* When you run a program that uses the Windows Sockets API, you may
experience slow performance when you copy data to a TCP server. experience slow performance when you copy data to a TCP server.
http://support.microsoft.com/kb/823764 https://support.microsoft.com/kb/823764
Work-around: Make the Socket Send Buffer Size Larger Than the Program Send Work-around: Make the Socket Send Buffer Size Larger Than the Program Send
Buffer Size Buffer Size
@ -102,6 +102,8 @@ CURLcode Curl_socket(struct connectdata *conn,
struct Curl_sockaddr_ex *addr, struct Curl_sockaddr_ex *addr,
curl_socket_t *sockfd); curl_socket_t *sockfd);
void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd);
#ifdef CURLDEBUG #ifdef CURLDEBUG
/* /*
* Curl_connclose() sets the bit.close bit to TRUE with an explanation. * Curl_connclose() sets the bit.close bit to TRUE with an explanation.

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -67,7 +67,7 @@ zfree_cb(voidpf opaque, voidpf ptr)
static CURLcode 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 Curl_easy *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);
@ -425,7 +425,7 @@ Curl_unencode_gzip_write(struct connectdata *conn,
void Curl_unencode_cleanup(struct connectdata *conn) void Curl_unencode_cleanup(struct connectdata *conn)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req; struct SingleRequest *k = &data->req;
z_stream *z = &k->z; z_stream *z = &k->z;
if(k->zlib_init != ZLIB_UNINIT) if(k->zlib_init != ZLIB_UNINIT)

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -26,13 +26,13 @@
RECEIVING COOKIE INFORMATION RECEIVING COOKIE INFORMATION
============================ ============================
struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
const char *file, struct CookieInfo *inc, bool newsession); const char *file, struct CookieInfo *inc, bool newsession);
Inits a cookie struct to store data in a local file. This is always Inits a cookie struct to store data in a local file. This is always
called before any cookies are set. called before any cookies are set.
struct Cookie *Curl_cookie_add(struct SessionHandle *data, struct Cookie *Curl_cookie_add(struct Curl_easy *data,
struct CookieInfo *c, bool httpheader, char *lineptr, struct CookieInfo *c, bool httpheader, char *lineptr,
const char *domain, const char *path); const char *domain, const char *path);
@ -84,7 +84,10 @@ Example set of cookies:
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
#include "curl_printf.h" #ifdef USE_LIBPSL
# include <libpsl.h>
#endif
#include "urldata.h" #include "urldata.h"
#include "cookie.h" #include "cookie.h"
#include "strequal.h" #include "strequal.h"
@ -97,7 +100,8 @@ Example set of cookies:
#include "curl_memrchr.h" #include "curl_memrchr.h"
#include "inet_pton.h" #include "inet_pton.h"
/* The last #include files should be: */ /* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -256,7 +260,7 @@ static char *sanitize_cookie_path(const char *cookie_path)
* *
* NOTE: OOM or cookie parsing failures are ignored. * NOTE: OOM or cookie parsing failures are ignored.
*/ */
void Curl_cookie_loadfiles(struct SessionHandle *data) void Curl_cookie_loadfiles(struct Curl_easy *data)
{ {
struct curl_slist *list = data->change.cookielist; struct curl_slist *list = data->change.cookielist;
if(list) { if(list) {
@ -305,7 +309,7 @@ static void remove_expired(struct CookieInfo *cookies)
pv = NULL; pv = NULL;
while(co) { while(co) {
nx = co->next; nx = co->next;
if((co->expirestr || co->maxage) && co->expires < now) { if(co->expires && co->expires < now) {
if(co == cookies->cookies) { if(co == cookies->cookies) {
cookies->cookies = co->next; cookies->cookies = co->next;
} }
@ -358,7 +362,7 @@ static bool isip(const char *domain)
***************************************************************************/ ***************************************************************************/
struct Cookie * struct Cookie *
Curl_cookie_add(struct SessionHandle *data, Curl_cookie_add(struct Curl_easy *data,
/* The 'data' pointer here may be NULL at times, and thus /* The 'data' pointer here may be NULL at times, and thus
must only be used very carefully for things that can deal must only be used very carefully for things that can deal
with data being NULL. Such as infof() and similar */ with data being NULL. Such as infof() and similar */
@ -379,6 +383,10 @@ Curl_cookie_add(struct SessionHandle *data,
bool replace_old = FALSE; bool replace_old = FALSE;
bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */ bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */
#ifdef USE_LIBPSL
const psl_ctx_t *psl;
#endif
#ifdef CURL_DISABLE_VERBOSE_STRINGS #ifdef CURL_DISABLE_VERBOSE_STRINGS
(void)data; (void)data;
#endif #endif
@ -409,7 +417,7 @@ Curl_cookie_add(struct SessionHandle *data,
do { do {
/* we have a <what>=<this> pair or a stand-alone word here */ /* we have a <what>=<this> pair or a stand-alone word here */
name[0]=what[0]=0; /* init the buffers */ name[0]=what[0]=0; /* init the buffers */
if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n =] =%" if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n=] =%"
MAX_COOKIE_LINE_TXT "[^;\r\n]", MAX_COOKIE_LINE_TXT "[^;\r\n]",
name, what)) { name, what)) {
/* Use strstore() below to properly deal with received cookie /* Use strstore() below to properly deal with received cookie
@ -419,15 +427,24 @@ Curl_cookie_add(struct SessionHandle *data,
bool done = FALSE; bool done = FALSE;
bool sep; bool sep;
size_t len=strlen(what); size_t len=strlen(what);
const char *endofn = &ptr[ strlen(name) ]; size_t nlen = strlen(name);
const char *endofn = &ptr[ nlen ];
/* skip trailing spaces in name */
while(*endofn && ISBLANK(*endofn))
endofn++;
/* name ends with a '=' ? */ /* name ends with a '=' ? */
sep = (*endofn == '=')?TRUE:FALSE; sep = (*endofn == '=')?TRUE:FALSE;
if(nlen) {
endofn--; /* move to the last character */
if(ISBLANK(*endofn)) {
/* skip trailing spaces in name */
while(*endofn && ISBLANK(*endofn) && nlen) {
endofn--;
nlen--;
}
name[nlen]=0; /* new end of name */
}
}
/* Strip off trailing whitespace from the 'what' */ /* Strip off trailing whitespace from the 'what' */
while(len && ISBLANK(what[len-1])) { while(len && ISBLANK(what[len-1])) {
what[len-1]=0; what[len-1]=0;
@ -439,7 +456,16 @@ Curl_cookie_add(struct SessionHandle *data,
while(*whatptr && ISBLANK(*whatptr)) while(*whatptr && ISBLANK(*whatptr))
whatptr++; whatptr++;
if(!len) { if(!co->name && sep) {
/* The very first name/value pair is the actual cookie name */
co->name = strdup(name);
co->value = strdup(whatptr);
if(!co->name || !co->value) {
badcookie = TRUE;
break;
}
}
else if(!len) {
/* this was a "<name>=" with no content, and we must allow /* this was a "<name>=" with no content, and we must allow
'secure' and 'httponly' specified this weirdly */ 'secure' and 'httponly' specified this weirdly */
done = TRUE; done = TRUE;
@ -533,14 +559,6 @@ Curl_cookie_add(struct SessionHandle *data,
break; break;
} }
} }
else if(!co->name) {
co->name = strdup(name);
co->value = strdup(whatptr);
if(!co->name || !co->value) {
badcookie = TRUE;
break;
}
}
/* /*
else this is the second (or more) name we don't know else this is the second (or more) name we don't know
about! */ about! */
@ -777,6 +795,21 @@ Curl_cookie_add(struct SessionHandle *data,
/* at first, remove expired cookies */ /* at first, remove expired cookies */
remove_expired(c); remove_expired(c);
#ifdef USE_LIBPSL
/* Check if the domain is a Public Suffix and if yes, ignore the cookie.
This needs a libpsl compiled with builtin data. */
if(domain && co->domain && !isip(co->domain)) {
if(((psl = psl_builtin()) != NULL)
&& !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
infof(data,
"cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n",
co->name, domain, co->domain);
freecookie(co);
return NULL;
}
}
#endif
clist = c->cookies; clist = c->cookies;
replace_old = FALSE; replace_old = FALSE;
while(clist) { while(clist) {
@ -880,7 +913,7 @@ Curl_cookie_add(struct SessionHandle *data,
* *
* Returns NULL on out of memory. Invalid cookies are ignored. * Returns NULL on out of memory. Invalid cookies are ignored.
****************************************************************************/ ****************************************************************************/
struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
const char *file, const char *file,
struct CookieInfo *inc, struct CookieInfo *inc,
bool newsession) bool newsession)
@ -1247,6 +1280,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
struct Cookie *co; struct Cookie *co;
FILE *out; FILE *out;
bool use_stdout=FALSE; bool use_stdout=FALSE;
char *format_ptr;
if((NULL == c) || (0 == c->numcookies)) if((NULL == c) || (0 == c->numcookies))
/* If there are no known cookies, we don't write or even create any /* If there are no known cookies, we don't write or even create any
@ -1267,27 +1301,23 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
return 1; /* failure */ return 1; /* failure */
} }
if(c) { fputs("# Netscape HTTP Cookie File\n"
char *format_ptr; "# https://curl.haxx.se/docs/http-cookies.html\n"
"# This file was generated by libcurl! Edit at your own risk.\n\n",
out);
fputs("# Netscape HTTP Cookie File\n" for(co = c->cookies; co; co = co->next) {
"# http://curl.haxx.se/docs/http-cookies.html\n" if(!co->domain)
"# This file was generated by libcurl! Edit at your own risk.\n\n", continue;
out); format_ptr = get_netscape_format(co);
if(format_ptr == NULL) {
for(co = c->cookies; co; co = co->next) { fprintf(out, "#\n# Fatal libcurl error\n");
if(!co->domain) if(!use_stdout)
continue; fclose(out);
format_ptr = get_netscape_format(co); return 1;
if(format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n");
if(!use_stdout)
fclose(out);
return 1;
}
fprintf(out, "%s\n", format_ptr);
free(format_ptr);
} }
fprintf(out, "%s\n", format_ptr);
free(format_ptr);
} }
if(!use_stdout) if(!use_stdout)
@ -1296,7 +1326,7 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
return 0; return 0;
} }
struct curl_slist *Curl_cookie_list(struct SessionHandle *data) struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
{ {
struct curl_slist *list = NULL; struct curl_slist *list = NULL;
struct curl_slist *beg; struct curl_slist *beg;
@ -1327,7 +1357,7 @@ struct curl_slist *Curl_cookie_list(struct SessionHandle *data)
return list; return list;
} }
void Curl_flush_cookies(struct SessionHandle *data, int cleanup) void Curl_flush_cookies(struct Curl_easy *data, int cleanup)
{ {
if(data->set.str[STRING_COOKIEJAR]) { if(data->set.str[STRING_COOKIEJAR]) {
if(data->change.cookielist) { if(data->change.cookielist) {

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -70,13 +70,13 @@ struct CookieInfo {
#define MAX_NAME 1024 #define MAX_NAME 1024
#define MAX_NAME_TXT "1023" #define MAX_NAME_TXT "1023"
struct SessionHandle; struct Curl_easy;
/* /*
* Add a cookie to the internal list of cookies. The domain and path arguments * Add a cookie to the internal list of cookies. The domain and path arguments
* are only used if the header boolean is TRUE. * are only used if the header boolean is TRUE.
*/ */
struct Cookie *Curl_cookie_add(struct SessionHandle *data, struct Cookie *Curl_cookie_add(struct Curl_easy *data,
struct CookieInfo *, bool header, char *lineptr, struct CookieInfo *, bool header, char *lineptr,
const char *domain, const char *path); const char *domain, const char *path);
@ -93,12 +93,12 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies);
#define Curl_cookie_cleanup(x) Curl_nop_stmt #define Curl_cookie_cleanup(x) Curl_nop_stmt
#define Curl_flush_cookies(x,y) Curl_nop_stmt #define Curl_flush_cookies(x,y) Curl_nop_stmt
#else #else
void Curl_flush_cookies(struct SessionHandle *data, int cleanup); void Curl_flush_cookies(struct Curl_easy *data, int cleanup);
void Curl_cookie_cleanup(struct CookieInfo *); void Curl_cookie_cleanup(struct CookieInfo *);
struct CookieInfo *Curl_cookie_init(struct SessionHandle *data, struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
const char *, struct CookieInfo *, bool); const char *, struct CookieInfo *, bool);
struct curl_slist *Curl_cookie_list(struct SessionHandle *data); struct curl_slist *Curl_cookie_list(struct Curl_easy *data);
void Curl_cookie_loadfiles(struct SessionHandle *data); void Curl_cookie_loadfiles(struct Curl_easy *data);
#endif #endif
#endif /* HEADER_CURL_COOKIE_H */ #endif /* HEADER_CURL_COOKIE_H */

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -50,10 +50,9 @@
#include "curl_addrinfo.h" #include "curl_addrinfo.h"
#include "inet_pton.h" #include "inet_pton.h"
#include "warnless.h" #include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
/* /*
@ -521,7 +520,11 @@ void
curl_dofreeaddrinfo(struct addrinfo *freethis, curl_dofreeaddrinfo(struct addrinfo *freethis,
int line, const char *source) int line, const char *source)
{ {
#ifdef USE_LWIPSOCK
lwip_freeaddrinfo(freethis);
#else
(freeaddrinfo)(freethis); (freeaddrinfo)(freethis);
#endif
curl_memlog("ADDR %s:%d freeaddrinfo(%p)\n", curl_memlog("ADDR %s:%d freeaddrinfo(%p)\n",
source, line, (void *)freethis); source, line, (void *)freethis);
} }
@ -544,7 +547,11 @@ curl_dogetaddrinfo(const char *hostname,
struct addrinfo **result, struct addrinfo **result,
int line, const char *source) int line, const char *source)
{ {
#ifdef USE_LWIPSOCK
int res=lwip_getaddrinfo(hostname, service, hints, result);
#else
int res=(getaddrinfo)(hostname, service, hints, result); int res=(getaddrinfo)(hostname, service, hints, result);
#endif
if(0 == res) if(0 == res)
/* success */ /* success */
curl_memlog("ADDR %s:%d getaddrinfo() = %p\n", curl_memlog("ADDR %s:%d getaddrinfo() = %p\n",
@ -556,3 +563,32 @@ curl_dogetaddrinfo(const char *hostname,
} }
#endif /* defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) */ #endif /* defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) */
#if defined(HAVE_GETADDRINFO) && defined(USE_RESOLVE_ON_IPS)
/*
* Work-arounds the sin6_port is always zero bug on iOS 9.3.2 and Mac OS X
* 10.11.5.
*/
void Curl_addrinfo_set_port(Curl_addrinfo *addrinfo, int port)
{
Curl_addrinfo *ca;
struct sockaddr_in *addr;
#ifdef ENABLE_IPV6
struct sockaddr_in6 *addr6;
#endif
for(ca = addrinfo; ca != NULL; ca = ca->ai_next) {
switch (ca->ai_family) {
case AF_INET:
addr = (void *)ca->ai_addr; /* storage area for this info */
addr->sin_port = htons((unsigned short)port);
break;
#ifdef ENABLE_IPV6
case AF_INET6:
addr6 = (void *)ca->ai_addr; /* storage area for this info */
addr6->sin6_port = htons((unsigned short)port);
break;
#endif
}
}
}
#endif

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -83,7 +83,8 @@ Curl_addrinfo *Curl_str2addr(char *dotted, int port);
Curl_addrinfo *Curl_unix2addr(const char *path); Curl_addrinfo *Curl_unix2addr(const char *path);
#endif #endif
#if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
defined(HAVE_FREEADDRINFO)
void void
curl_dofreeaddrinfo(struct addrinfo *freethis, curl_dofreeaddrinfo(struct addrinfo *freethis,
int line, const char *source); int line, const char *source);
@ -98,4 +99,12 @@ curl_dogetaddrinfo(const char *hostname,
int line, const char *source); int line, const char *source);
#endif #endif
#ifdef HAVE_GETADDRINFO
#ifdef USE_RESOLVE_ON_IPS
void Curl_addrinfo_set_port(Curl_addrinfo *addrinfo, int port);
#else
#define Curl_addrinfo_set_port(x,y)
#endif
#endif
#endif /* HEADER_CURL_ADDRINFO_H */ #endif /* HEADER_CURL_ADDRINFO_H */

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,10 +22,10 @@
* *
***************************************************************************/ ***************************************************************************/
CURLcode Curl_base64_encode(struct SessionHandle *data, CURLcode Curl_base64_encode(struct Curl_easy *data,
const char *inputbuff, size_t insize, const char *inputbuff, size_t insize,
char **outptr, size_t *outlen); char **outptr, size_t *outlen);
CURLcode Curl_base64url_encode(struct SessionHandle *data, CURLcode Curl_base64url_encode(struct Curl_easy *data,
const char *inputbuff, size_t insize, const char *inputbuff, size_t insize,
char **outptr, size_t *outlen); char **outptr, size_t *outlen);

View File

@ -18,6 +18,12 @@
/* to disable FTP */ /* to disable FTP */
#cmakedefine CURL_DISABLE_FTP 1 #cmakedefine CURL_DISABLE_FTP 1
/* to disable GOPHER */
#cmakedefine CURL_DISABLE_GOPHER 1
/* to disable IMAP */
#cmakedefine CURL_DISABLE_IMAP 1
/* to disable HTTP */ /* to disable HTTP */
#cmakedefine CURL_DISABLE_HTTP 1 #cmakedefine CURL_DISABLE_HTTP 1
@ -27,9 +33,24 @@
/* to disable LDAPS */ /* to disable LDAPS */
#cmakedefine CURL_DISABLE_LDAPS 1 #cmakedefine CURL_DISABLE_LDAPS 1
/* to disable POP3 */
#cmakedefine CURL_DISABLE_POP3 1
/* to disable proxies */ /* to disable proxies */
#cmakedefine CURL_DISABLE_PROXY 1 #cmakedefine CURL_DISABLE_PROXY 1
/* to disable RTSP */
#cmakedefine CURL_DISABLE_RTSP 1
/* to disable RTMP */
#cmakedefine CURL_DISABLE_RTMP 1
/* to disable SMB */
#cmakedefine CURL_DISABLE_SMB 1
/* to disable SMTP */
#cmakedefine CURL_DISABLE_SMTP 1
/* to disable TELNET */ /* to disable TELNET */
#cmakedefine CURL_DISABLE_TELNET 1 #cmakedefine CURL_DISABLE_TELNET 1
@ -888,6 +909,9 @@
/* if PolarSSL is enabled */ /* if PolarSSL is enabled */
#cmakedefine USE_POLARSSL 1 #cmakedefine USE_POLARSSL 1
/* if mbedTLS is enabled */
#cmakedefine USE_MBEDTLS 1
/* if libSSH2 is in use */ /* if libSSH2 is in use */
#cmakedefine USE_LIBSSH2 1 #cmakedefine USE_LIBSSH2 1
@ -909,6 +933,9 @@
/* to enable SSPI support */ /* to enable SSPI support */
#cmakedefine USE_WINDOWS_SSPI 1 #cmakedefine USE_WINDOWS_SSPI 1
/* to enable Windows SSL */
#cmakedefine USE_SCHANNEL 1
/* Define to 1 if using yaSSL in OpenSSL compatibility mode. */ /* Define to 1 if using yaSSL in OpenSSL compatibility mode. */
#cmakedefine USE_YASSLEMUL 1 #cmakedefine USE_YASSLEMUL 1

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,7 +22,7 @@
#include "curl_setup.h" #include "curl_setup.h"
#if defined(USE_NTLM) && (!defined(USE_OPENSSL) || defined(HAVE_BORINGSSL)) #if defined(USE_NTLM) && !defined(USE_OPENSSL)
#include "curl_des.h" #include "curl_des.h"
@ -60,4 +60,4 @@ void Curl_des_set_odd_parity(unsigned char *bytes, size_t len)
} }
} }
#endif /* USE_NTLM && (!USE_OPENSSL || HAVE_BORINGSSL) */ #endif /* USE_NTLM && !USE_OPENSSL */

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -24,11 +24,11 @@
#include "curl_setup.h" #include "curl_setup.h"
#if defined(USE_NTLM) && (!defined(USE_OPENSSL) || defined(HAVE_BORINGSSL)) #if defined(USE_NTLM) && !defined(USE_OPENSSL)
/* Applies odd parity to the given byte array */ /* Applies odd parity to the given byte array */
void Curl_des_set_odd_parity(unsigned char *bytes, size_t length); void Curl_des_set_odd_parity(unsigned char *bytes, size_t length);
#endif /* USE_NTLM && (!USE_OPENSSL || HAVE_BORINGSSL) */ #endif /* USE_NTLM && !USE_OPENSSL */
#endif /* HEADER_CURL_DES_H */ #endif /* HEADER_CURL_DES_H */

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,6 +22,8 @@
#include "curl_setup.h" #include "curl_setup.h"
#include <curl/curl.h>
#include "curl_fnmatch.h" #include "curl_fnmatch.h"
#include "curl_memory.h" #include "curl_memory.h"

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2011 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2011 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -33,7 +33,7 @@ static char krb5_oid_bytes[] = "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02";
gss_OID_desc Curl_krb5_mech_oid = { 9, &krb5_oid_bytes }; gss_OID_desc Curl_krb5_mech_oid = { 9, &krb5_oid_bytes };
OM_uint32 Curl_gss_init_sec_context( OM_uint32 Curl_gss_init_sec_context(
struct SessionHandle *data, struct Curl_easy *data,
OM_uint32 *minor_status, OM_uint32 *minor_status,
gss_ctx_id_t *context, gss_ctx_id_t *context,
gss_name_t target_name, gss_name_t target_name,
@ -76,6 +76,32 @@ OM_uint32 Curl_gss_init_sec_context(
NULL /* time_rec */); NULL /* time_rec */);
} }
#define GSS_LOG_BUFFER_LEN 1024
static size_t display_gss_error(OM_uint32 status, int type,
char *buf, size_t len) {
OM_uint32 maj_stat;
OM_uint32 min_stat;
OM_uint32 msg_ctx = 0;
gss_buffer_desc status_string;
do {
maj_stat = gss_display_status(&min_stat,
status,
type,
GSS_C_NO_OID,
&msg_ctx,
&status_string);
if(GSS_LOG_BUFFER_LEN > len + status_string.length + 3) {
len += snprintf(buf + len, GSS_LOG_BUFFER_LEN - len,
"%.*s. ", (int)status_string.length,
(char*)status_string.value);
}
gss_release_buffer(&min_stat, &status_string);
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
return len;
}
/* /*
* Curl_gss_log_error() * Curl_gss_log_error()
* *
@ -84,37 +110,22 @@ OM_uint32 Curl_gss_init_sec_context(
* Parameters: * Parameters:
* *
* data [in] - The session handle. * data [in] - The session handle.
* status [in] - The status code.
* prefix [in] - The prefix of the log message. * prefix [in] - The prefix of the log message.
* major [in] - The major status code.
* minor [in] - The minor status code.
*/ */
void Curl_gss_log_error(struct SessionHandle *data, OM_uint32 status, void Curl_gss_log_error(struct Curl_easy *data, const char *prefix,
const char *prefix) OM_uint32 major, OM_uint32 minor)
{ {
OM_uint32 maj_stat; char buf[GSS_LOG_BUFFER_LEN];
OM_uint32 min_stat; size_t len = 0;
OM_uint32 msg_ctx = 0;
gss_buffer_desc status_string;
char buf[1024];
size_t len;
snprintf(buf, sizeof(buf), "%s", prefix); if(major != GSS_S_FAILURE)
len = strlen(buf); len = display_gss_error(major, GSS_C_GSS_CODE, buf, len);
do {
maj_stat = gss_display_status(&min_stat,
status,
GSS_C_MECH_CODE,
GSS_C_NO_OID,
&msg_ctx,
&status_string);
if(sizeof(buf) > len + status_string.length + 1) {
snprintf(buf + len, sizeof(buf) - len,
": %s", (char*)status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
infof(data, "%s\n", buf); display_gss_error(minor, GSS_C_MECH_CODE, buf, len);
infof(data, "%s%s\n", prefix, buf);
} }
#endif /* HAVE_GSSAPI */ #endif /* HAVE_GSSAPI */

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -44,7 +44,7 @@ extern gss_OID_desc Curl_krb5_mech_oid;
/* Common method for using GSS-API */ /* Common method for using GSS-API */
OM_uint32 Curl_gss_init_sec_context( OM_uint32 Curl_gss_init_sec_context(
struct SessionHandle *data, struct Curl_easy *data,
OM_uint32 *minor_status, OM_uint32 *minor_status,
gss_ctx_id_t *context, gss_ctx_id_t *context,
gss_name_t target_name, gss_name_t target_name,
@ -56,8 +56,8 @@ OM_uint32 Curl_gss_init_sec_context(
OM_uint32 *ret_flags); OM_uint32 *ret_flags);
/* Helper to log a GSS-API error status */ /* Helper to log a GSS-API error status */
void Curl_gss_log_error(struct SessionHandle *data, OM_uint32 status, void Curl_gss_log_error(struct Curl_easy *data, const char *prefix,
const char *prefix); OM_uint32 major, OM_uint32 minor);
/* Provide some definitions missing in old headers */ /* Provide some definitions missing in old headers */
#ifdef HAVE_OLD_GSSMIT #ifdef HAVE_OLD_GSSMIT

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -83,7 +83,20 @@
#ifndef CURLX_NO_MEMORY_CALLBACKS #ifndef CURLX_NO_MEMORY_CALLBACKS
#include <curl/curl.h> /* for the callback typedefs */ #ifndef CURL_DID_MEMORY_FUNC_TYPEDEFS /* only if not already done */
/*
* The following memory function replacement typedef's are COPIED from
* curl/curl.h and MUST match the originals. We copy them to avoid having to
* include curl/curl.h here. We avoid that include since it includes stdio.h
* and other headers that may get messed up with defines done here.
*/
typedef void *(*curl_malloc_callback)(size_t size);
typedef void (*curl_free_callback)(void *ptr);
typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
typedef char *(*curl_strdup_callback)(const char *str);
typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
#define CURL_DID_MEMORY_FUNC_TYPEDEFS
#endif
extern curl_malloc_callback Curl_cmalloc; extern curl_malloc_callback Curl_cmalloc;
extern curl_free_callback Curl_cfree; extern curl_free_callback Curl_cfree;

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -21,6 +21,9 @@
***************************************************************************/ ***************************************************************************/
#include "curl_setup.h" #include "curl_setup.h"
#include <curl/curl.h>
#include "curl_memrchr.h" #include "curl_memrchr.h"
#include "curl_memory.h" #include "curl_memory.h"

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,6 +22,8 @@
#include "curl_setup.h" #include "curl_setup.h"
#include <curl/curl.h>
#if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \ #if defined(USE_WIN32_IDN) || ((defined(USE_WINDOWS_SSPI) || \
defined(USE_WIN32_LDAP)) && defined(UNICODE)) defined(USE_WIN32_LDAP)) && defined(UNICODE))

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -28,7 +28,7 @@
* NTLM details: * NTLM details:
* *
* http://davenport.sourceforge.net/ntlm.html * http://davenport.sourceforge.net/ntlm.html
* http://www.innovation.ch/java/ntlm.html * https://www.innovation.ch/java/ntlm.html
*/ */
#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO) #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
@ -107,9 +107,8 @@
#include "warnless.h" #include "warnless.h"
#include "curl_endian.h" #include "curl_endian.h"
#include "curl_des.h" #include "curl_des.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -143,14 +142,10 @@ static void setup_des_key(const unsigned char *key_56,
DES_cblock key; DES_cblock key;
/* Expand the 56-bit key to 64-bits */ /* Expand the 56-bit key to 64-bits */
extend_key_56_to_64(key_56, (char *) key); extend_key_56_to_64(key_56, (char *) &key);
/* Set the key parity to odd */ /* Set the key parity to odd */
#if defined(HAVE_BORINGSSL)
Curl_des_set_odd_parity((unsigned char *) &key, sizeof(key));
#else
DES_set_odd_parity(&key); DES_set_odd_parity(&key);
#endif
/* Set the key */ /* Set the key */
DES_set_key(&key, ks); DES_set_key(&key, ks);
@ -416,7 +411,7 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys,
/* /*
* Set up lanmanager hashed password * Set up lanmanager hashed password
*/ */
CURLcode Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
const char *password, const char *password,
unsigned char *lmbuffer /* 21 bytes */) unsigned char *lmbuffer /* 21 bytes */)
{ {
@ -510,7 +505,7 @@ static void ascii_uppercase_to_unicode_le(unsigned char *dest,
* Set up nt hashed passwords * Set up nt hashed passwords
* @unittest: 1600 * @unittest: 1600
*/ */
CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
const char *password, const char *password,
unsigned char *ntbuffer /* 21 bytes */) unsigned char *ntbuffer /* 21 bytes */)
{ {
@ -664,21 +659,22 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
unsigned int len = 0; unsigned int len = 0;
unsigned char *ptr = NULL; unsigned char *ptr = NULL;
unsigned char hmac_output[NTLM_HMAC_MD5_LEN]; unsigned char hmac_output[NTLM_HMAC_MD5_LEN];
#if defined(HAVE_LONGLONG) curl_off_t tw;
long long tw;
#else
__int64 tw;
#endif
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
#if CURL_SIZEOF_CURL_OFF_T < 8
#error "this section needs 64bit support to work"
#endif
/* Calculate the timestamp */ /* Calculate the timestamp */
#ifdef DEBUGBUILD #ifdef DEBUGBUILD
char *force_timestamp = getenv("CURL_FORCETIME"); char *force_timestamp = getenv("CURL_FORCETIME");
if(force_timestamp) if(force_timestamp)
tw = 11644473600ULL * 10000000ULL; tw = CURL_OFF_T_C(11644473600) * 10000000;
else else
#endif #endif
tw = ((long long)time(NULL) + 11644473600ULL) * 10000000ULL; tw = ((curl_off_t)time(NULL) + CURL_OFF_T_C(11644473600)) * 10000000;
/* Calculate the response len */ /* Calculate the response len */
len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN; len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -64,12 +64,12 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys,
const unsigned char *plaintext, const unsigned char *plaintext,
unsigned char *results); unsigned char *results);
CURLcode Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data, CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
const char *password, const char *password,
unsigned char *lmbuffer /* 21 bytes */); unsigned char *lmbuffer /* 21 bytes */);
#if USE_NTRESPONSES #if USE_NTRESPONSES
CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data, CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
const char *password, const char *password,
unsigned char *ntbuffer /* 21 bytes */); unsigned char *ntbuffer /* 21 bytes */);

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -29,7 +29,7 @@
* NTLM details: * NTLM details:
* *
* http://davenport.sourceforge.net/ntlm.html * http://davenport.sourceforge.net/ntlm.html
* http://www.innovation.ch/java/ntlm.html * https://www.innovation.ch/java/ntlm.html
*/ */
#define DEBUG_ME 0 #define DEBUG_ME 0
@ -47,13 +47,12 @@
#include "urldata.h" #include "urldata.h"
#include "sendf.h" #include "sendf.h"
#include "select.h" #include "select.h"
#include "curl_ntlm_msgs.h" #include "vauth/ntlm.h"
#include "curl_ntlm_wb.h" #include "curl_ntlm_wb.h"
#include "url.h" #include "url.h"
#include "strerror.h" #include "strerror.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -373,8 +372,8 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
* by delegating the NTLM challenge/response protocal to a helper * by delegating the NTLM challenge/response protocal to a helper
* in ntlm_auth. * in ntlm_auth.
* http://devel.squid-cache.org/ntlm/squid_helper_protocol.html * http://devel.squid-cache.org/ntlm/squid_helper_protocol.html
* http://www.samba.org/samba/docs/man/manpages-3/winbindd.8.html * https://www.samba.org/samba/docs/man/manpages-3/winbindd.8.html
* http://www.samba.org/samba/docs/man/manpages-3/ntlm_auth.1.html * https://www.samba.org/samba/docs/man/manpages-3/ntlm_auth.1.html
* Preprocessor symbol 'NTLM_WB_ENABLED' is defined when this * Preprocessor symbol 'NTLM_WB_ENABLED' is defined when this
* feature is enabled and 'NTLM_WB_FILE' symbol holds absolute * feature is enabled and 'NTLM_WB_FILE' symbol holds absolute
* filename of ntlm_auth helper. * filename of ntlm_auth helper.

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -10,7 +10,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -55,7 +55,7 @@ static Curl_recv rtmp_recv;
static Curl_send rtmp_send; static Curl_send rtmp_send;
/* /*
* RTMP protocol handler.h, based on http://rtmpdump.mplayerhq.hu * RTMP protocol handler.h, based on https://rtmpdump.mplayerhq.hu
*/ */
const struct Curl_handler Curl_handler_rtmp = { const struct Curl_handler Curl_handler_rtmp = {

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2012 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -24,21 +24,9 @@
#include <curl/curl.h> #include <curl/curl.h>
struct SessionHandle; struct Curl_easy;
struct connectdata; struct connectdata;
#if !defined(CURL_DISABLE_CRYPTO_AUTH)
struct digestdata;
#endif
#if defined(USE_NTLM)
struct ntlmdata;
#endif
#if defined(USE_KERBEROS5)
struct kerberos5data;
#endif
/* Authentication mechanism flags */ /* Authentication mechanism flags */
#define SASL_MECH_LOGIN (1 << 0) #define SASL_MECH_LOGIN (1 << 0)
#define SASL_MECH_PLAIN (1 << 1) #define SASL_MECH_PLAIN (1 << 1)
@ -48,32 +36,23 @@ struct kerberos5data;
#define SASL_MECH_EXTERNAL (1 << 5) #define SASL_MECH_EXTERNAL (1 << 5)
#define SASL_MECH_NTLM (1 << 6) #define SASL_MECH_NTLM (1 << 6)
#define SASL_MECH_XOAUTH2 (1 << 7) #define SASL_MECH_XOAUTH2 (1 << 7)
#define SASL_MECH_OAUTHBEARER (1 << 8)
/* Authentication mechanism values */ /* Authentication mechanism values */
#define SASL_AUTH_NONE 0 #define SASL_AUTH_NONE 0
#define SASL_AUTH_ANY ~0U #define SASL_AUTH_ANY ~0U
#define SASL_AUTH_DEFAULT (SASL_AUTH_ANY & \ #define SASL_AUTH_DEFAULT (SASL_AUTH_ANY & ~SASL_MECH_EXTERNAL)
~(SASL_MECH_EXTERNAL | SASL_MECH_XOAUTH2))
/* Authentication mechanism strings */ /* Authentication mechanism strings */
#define SASL_MECH_STRING_LOGIN "LOGIN" #define SASL_MECH_STRING_LOGIN "LOGIN"
#define SASL_MECH_STRING_PLAIN "PLAIN" #define SASL_MECH_STRING_PLAIN "PLAIN"
#define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5" #define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5"
#define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5" #define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5"
#define SASL_MECH_STRING_GSSAPI "GSSAPI" #define SASL_MECH_STRING_GSSAPI "GSSAPI"
#define SASL_MECH_STRING_EXTERNAL "EXTERNAL" #define SASL_MECH_STRING_EXTERNAL "EXTERNAL"
#define SASL_MECH_STRING_NTLM "NTLM" #define SASL_MECH_STRING_NTLM "NTLM"
#define SASL_MECH_STRING_XOAUTH2 "XOAUTH2" #define SASL_MECH_STRING_XOAUTH2 "XOAUTH2"
#define SASL_MECH_STRING_OAUTHBEARER "OAUTHBEARER"
#if !defined(CURL_DISABLE_CRYPTO_AUTH)
#define DIGEST_MAX_VALUE_LENGTH 256
#define DIGEST_MAX_CONTENT_LENGTH 1024
#endif
enum {
CURLDIGESTALGO_MD5,
CURLDIGESTALGO_MD5SESS
};
/* SASL machine states */ /* SASL machine states */
typedef enum { typedef enum {
@ -90,7 +69,8 @@ typedef enum {
SASL_GSSAPI, SASL_GSSAPI,
SASL_GSSAPI_TOKEN, SASL_GSSAPI_TOKEN,
SASL_GSSAPI_NO_DATA, SASL_GSSAPI_NO_DATA,
SASL_XOAUTH2, SASL_OAUTH2,
SASL_OAUTH2_RESP,
SASL_CANCEL, SASL_CANCEL,
SASL_FINAL SASL_FINAL
} saslstate; } saslstate;
@ -134,97 +114,6 @@ struct SASL {
(wordlen == (sizeof(mech) - 1) / sizeof(char) && \ (wordlen == (sizeof(mech) - 1) / sizeof(char) && \
!memcmp(line, mech, wordlen)) !memcmp(line, mech, wordlen))
/* This is used to build a SPN string */
#if !defined(USE_WINDOWS_SSPI)
char *Curl_sasl_build_spn(const char *service, const char *instance);
#else
TCHAR *Curl_sasl_build_spn(const char *service, const char *instance);
#endif
/* This is used to extract the realm from a challenge message */
int Curl_sasl_digest_get_pair(const char *str, char *value, char *content,
const char **endptr);
#if defined(HAVE_GSSAPI)
char *Curl_sasl_build_gssapi_spn(const char *service, const char *host);
#endif
#ifndef CURL_DISABLE_CRYPTO_AUTH
/* This is used to generate a base64 encoded DIGEST-MD5 response message */
CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
const char *chlg64,
const char *userp,
const char *passwdp,
const char *service,
char **outptr, size_t *outlen);
/* This is used to decode a HTTP DIGEST challenge message */
CURLcode Curl_sasl_decode_digest_http_message(const char *chlg,
struct digestdata *digest);
/* This is used to generate a HTTP DIGEST response message */
CURLcode Curl_sasl_create_digest_http_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
const unsigned char *request,
const unsigned char *uri,
struct digestdata *digest,
char **outptr, size_t *outlen);
/* This is used to clean up the digest specific data */
void Curl_sasl_digest_cleanup(struct digestdata *digest);
#endif
#ifdef USE_NTLM
/* This is used to generate a base64 encoded NTLM type-1 message */
CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr,
size_t *outlen);
/* This is used to decode a base64 encoded NTLM type-2 message */
CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data,
const char *type2msg,
struct ntlmdata *ntlm);
/* This is used to generate a base64 encoded NTLM type-3 message */
CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr, size_t *outlen);
/* This is used to clean up the ntlm specific data */
void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm);
#endif /* USE_NTLM */
#if defined(USE_KERBEROS5)
/* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token
message */
CURLcode Curl_sasl_create_gssapi_user_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
const char *service,
const bool mutual,
const char *chlg64,
struct kerberos5data *krb5,
char **outptr, size_t *outlen);
/* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security
token message */
CURLcode Curl_sasl_create_gssapi_security_message(struct SessionHandle *data,
const char *input,
struct kerberos5data *krb5,
char **outptr,
size_t *outlen);
/* This is used to clean up the gssapi specific data */
void Curl_sasl_gssapi_cleanup(struct kerberos5data *krb5);
#endif /* USE_KERBEROS5 */
/* This is used to cleanup any libraries or curl modules used by the sasl /* This is used to cleanup any libraries or curl modules used by the sasl
functions */ functions */
void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused); void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused);

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -185,9 +185,6 @@
# ifndef CURL_DISABLE_SMTP # ifndef CURL_DISABLE_SMTP
# define CURL_DISABLE_SMTP # define CURL_DISABLE_SMTP
# endif # endif
# ifndef CURL_DISABLE_RTSP
# define CURL_DISABLE_RTSP
# endif
# ifndef CURL_DISABLE_RTMP # ifndef CURL_DISABLE_RTMP
# define CURL_DISABLE_RTMP # define CURL_DISABLE_RTMP
# endif # endif
@ -228,6 +225,15 @@
# include "setup-vms.h" # include "setup-vms.h"
#endif #endif
/*
* Use getaddrinfo to resolve the IPv4 address literal. If the current network
* interface doesnt support IPv4, but supports IPv6, NAT64, and DNS64,
* performing this task will result in a synthesized IPv6 address.
*/
#ifdef __APPLE__
#define USE_RESOLVE_ON_IPS 1
#endif
/* /*
* Include header files for windows builds before redefining anything. * Include header files for windows builds before redefining anything.
* Use this preprocessor block only to include or exclude windows.h, * Use this preprocessor block only to include or exclude windows.h,
@ -253,7 +259,7 @@
# ifdef HAVE_WINSOCK2_H # ifdef HAVE_WINSOCK2_H
# include <winsock2.h> # include <winsock2.h>
# ifdef HAVE_WS2TCPIP_H # ifdef HAVE_WS2TCPIP_H
# include <ws2tcpip.h> # include <ws2tcpip.h>
# endif # endif
# else # else
# ifdef HAVE_WINSOCK_H # ifdef HAVE_WINSOCK_H
@ -491,7 +497,7 @@
# endif # endif
# ifndef fileno /* sunos 4 have this as a macro! */ # ifndef fileno /* sunos 4 have this as a macro! */
int fileno( FILE *stream); int fileno(FILE *stream);
# endif # endif
#endif /* WIN32 */ #endif /* WIN32 */
@ -499,9 +505,10 @@
/* /*
* msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
* defined in ws2tcpip.h as well as to provide IPv6 support. * defined in ws2tcpip.h as well as to provide IPv6 support.
* Does not apply if lwIP is used.
*/ */
#if defined(_MSC_VER) && !defined(__POCC__) #if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK)
# if !defined(HAVE_WS2TCPIP_H) || \ # if !defined(HAVE_WS2TCPIP_H) || \
((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN)) ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
# undef HAVE_GETADDRINFO_THREADSAFE # undef HAVE_GETADDRINFO_THREADSAFE
@ -545,6 +552,7 @@
# define CURLRES_ARES # define CURLRES_ARES
/* now undef the stock libc functions just to avoid them being used */ /* now undef the stock libc functions just to avoid them being used */
# undef HAVE_GETADDRINFO # undef HAVE_GETADDRINFO
# undef HAVE_FREEADDRINFO
# undef HAVE_GETHOSTBYNAME # undef HAVE_GETHOSTBYNAME
#elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
# define CURLRES_ASYNCH # define CURLRES_ASYNCH
@ -620,7 +628,7 @@ int netware_init(void);
#define LIBIDN_REQUIRED_VERSION "0.4.1" #define LIBIDN_REQUIRED_VERSION "0.4.1"
#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \ #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
defined(USE_POLARSSL) || defined(USE_AXTLS) || \ defined(USE_POLARSSL) || defined(USE_AXTLS) || defined(USE_MBEDTLS) || \
defined(USE_CYASSL) || defined(USE_SCHANNEL) || \ defined(USE_CYASSL) || defined(USE_SCHANNEL) || \
defined(USE_DARWINSSL) || defined(USE_GSKIT) defined(USE_DARWINSSL) || defined(USE_GSKIT)
#define USE_SSL /* SSL support has been enabled */ #define USE_SSL /* SSL support has been enabled */
@ -644,13 +652,9 @@ int netware_init(void);
defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \ defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \
defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO)
#ifdef HAVE_BORINGSSL /* BoringSSL is not NTLM capable */
#undef USE_NTLM
#else
#define USE_NTLM #define USE_NTLM
#endif #endif
#endif #endif
#endif
/* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */ /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
#if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE) #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
@ -692,7 +696,7 @@ int netware_init(void);
* Ensure that Winsock and lwIP TCP/IP stacks are not mixed. * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
*/ */
#if defined(__LWIP_OPT_H__) #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
# if defined(SOCKET) || \ # if defined(SOCKET) || \
defined(USE_WINSOCK) || \ defined(USE_WINSOCK) || \
defined(HAVE_WINSOCK_H) || \ defined(HAVE_WINSOCK_H) || \
@ -723,7 +727,7 @@ int netware_init(void);
#endif #endif
/* In Windows the default file mode is text but an application can override it. /* In Windows the default file mode is text but an application can override it.
Therefore we specify it explicitly. https://github.com/bagder/curl/pull/258 Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
*/ */
#if defined(WIN32) || defined(MSDOS) #if defined(WIN32) || defined(MSDOS)
#define FOPEN_READTEXT "rt" #define FOPEN_READTEXT "rt"
@ -742,4 +746,19 @@ endings either CRLF or LF so 't' is appropriate.
#define FOPEN_WRITETEXT "w" #define FOPEN_WRITETEXT "w"
#endif #endif
/* WinSock destroys recv() buffer when send() failed.
* Enabled automatically for Windows and for Cygwin as Cygwin sockets are
* wrappers for WinSock sockets. https://github.com/curl/curl/issues/657
* Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround.
*/
#if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
# if defined(WIN32) || defined(__CYGWIN__)
# define USE_RECV_BEFORE_SEND_WORKAROUND
# endif
#else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
# ifdef USE_RECV_BEFORE_SEND_WORKAROUND
# undef USE_RECV_BEFORE_SEND_WORKAROUND
# endif
#endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
#endif /* HEADER_CURL_SETUP_H */ #endif /* HEADER_CURL_SETUP_H */

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -27,6 +27,7 @@
#include <curl/curl.h> #include <curl/curl.h>
#include "curl_sspi.h" #include "curl_sspi.h"
#include "curl_multibyte.h" #include "curl_multibyte.h"
#include "system_win32.h"
#include "warnless.h" #include "warnless.h"
/* The last #include files should be: */ /* The last #include files should be: */
@ -66,7 +67,6 @@ PSecurityFunctionTable s_pSecFn = NULL;
*/ */
CURLcode Curl_sspi_global_init(void) CURLcode Curl_sspi_global_init(void)
{ {
bool securityDll = FALSE;
INITSECURITYINTERFACE_FN pInitSecurityInterface; INITSECURITYINTERFACE_FN pInitSecurityInterface;
/* If security interface is not yet initialized try to do this */ /* If security interface is not yet initialized try to do this */
@ -74,52 +74,12 @@ CURLcode Curl_sspi_global_init(void)
/* Security Service Provider Interface (SSPI) functions are located in /* Security Service Provider Interface (SSPI) 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
* have both these DLLs (security.dll forwards calls to secur32.dll) */ * have both these DLLs (security.dll forwards calls to secur32.dll) */
DWORD majorVersion = 4;
DWORD platformId = VER_PLATFORM_WIN32_NT;
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
(_WIN32_WINNT < _WIN32_WINNT_WIN2K)
OSVERSIONINFO osver;
memset(&osver, 0, sizeof(osver));
osver.dwOSVersionInfoSize = sizeof(osver);
/* Find out Windows version */
if(!GetVersionEx(&osver))
return CURLE_FAILED_INIT;
/* Verify the major version number == 4 and platform id == WIN_NT */
if(osver.dwMajorVersion == majorVersion &&
osver.dwPlatformId == platformId)
securityDll = TRUE;
#else
ULONGLONG cm;
OSVERSIONINFOEX osver;
memset(&osver, 0, sizeof(osver));
osver.dwOSVersionInfoSize = sizeof(osver);
osver.dwMajorVersion = majorVersion;
osver.dwPlatformId = platformId;
cm = VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL);
cm = VerSetConditionMask(cm, VER_MINORVERSION, VER_GREATER_EQUAL);
cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
/* Verify the major version number == 4 and platform id == WIN_NT */
if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR |
VER_PLATFORMID),
cm))
securityDll = TRUE;
#endif
/* Load SSPI dll into the address space of the calling process */ /* Load SSPI dll into the address space of the calling process */
if(securityDll) if(Curl_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
s_hSecDll = LoadLibrary(TEXT("security.dll")); s_hSecDll = Curl_load_library(TEXT("security.dll"));
else else
s_hSecDll = LoadLibrary(TEXT("secur32.dll")); s_hSecDll = Curl_load_library(TEXT("secur32.dll"));
if(!s_hSecDll) if(!s_hSecDll)
return CURLE_FAILED_INIT; return CURLE_FAILED_INIT;

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -327,6 +327,10 @@ extern PSecurityFunctionTable s_pSecFn;
# define SEC_I_SIGNATURE_NEEDED ((HRESULT)0x0009035CL) # define SEC_I_SIGNATURE_NEEDED ((HRESULT)0x0009035CL)
#endif #endif
#ifndef CRYPT_E_REVOKED
# define CRYPT_E_REVOKED ((HRESULT)0x80092010L)
#endif
#ifdef UNICODE #ifdef UNICODE
# define SECFLAG_WINNT_AUTH_IDENTITY \ # define SECFLAG_WINNT_AUTH_IDENTITY \
(unsigned long)SEC_WINNT_AUTH_IDENTITY_UNICODE (unsigned long)SEC_WINNT_AUTH_IDENTITY_UNICODE

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,6 +22,8 @@
#include "curl_setup.h" #include "curl_setup.h"
#include <curl/curl.h>
#if defined(USE_THREADS_POSIX) #if defined(USE_THREADS_POSIX)
# ifdef HAVE_PTHREAD_H # ifdef HAVE_PTHREAD_H
# include <pthread.h> # include <pthread.h>

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -91,7 +91,7 @@ const struct Curl_handler Curl_handler_dict = {
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */ PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
}; };
static char *unescape_word(struct SessionHandle *data, const char *inputbuff) static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
{ {
char *newp; char *newp;
char *dictp; char *dictp;
@ -133,7 +133,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
char *nthdef = NULL; /* This is not part of the protocol, but required char *nthdef = NULL; /* This is not part of the protocol, but required
by RFC 2229 */ by RFC 2229 */
CURLcode result=CURLE_OK; CURLcode result=CURLE_OK;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
char *path = data->state.path; char *path = data->state.path;

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,19 +22,22 @@
#include "curl_setup.h" #include "curl_setup.h"
#include "dotdot.h" #include <curl/curl.h>
#include "dotdot.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */ /* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
/* /*
* "Remove Dot Segments" * "Remove Dot Segments"
* http://tools.ietf.org/html/rfc3986#section-5.2.4 * https://tools.ietf.org/html/rfc3986#section-5.2.4
*/ */
/* /*
* Curl_dedotdotify() * Curl_dedotdotify()
* @unittest: 1395
* *
* This function gets a zero-terminated path with dot and dotdot sequences * This function gets a zero-terminated path with dot and dotdot sequences
* passed in and strips them off according to the rules in RFC 3986 section * passed in and strips them off according to the rules in RFC 3986 section
@ -68,6 +71,12 @@ char *Curl_dedotdotify(const char *input)
orgclone = clone; orgclone = clone;
outptr = out; outptr = out;
if(!*clone) {
/* zero length string, return that */
free(out);
return clone;
}
/* /*
* To handle query-parts properly, we must find it and remove it during the * To handle query-parts properly, we must find it and remove it during the
* dotdot-operation and then append it again at the end to the output * dotdot-operation and then append it again at the end to the output

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -64,7 +64,6 @@
#include "easyif.h" #include "easyif.h"
#include "select.h" #include "select.h"
#include "sendf.h" /* for failf function prototype */ #include "sendf.h" /* for failf function prototype */
#include "curl_ntlm.h"
#include "connect.h" /* for Curl_getconnectinfo */ #include "connect.h" /* for Curl_getconnectinfo */
#include "slist.h" #include "slist.h"
#include "amigaos.h" #include "amigaos.h"
@ -74,12 +73,13 @@
#include "multiif.h" #include "multiif.h"
#include "sigpipe.h" #include "sigpipe.h"
#include "ssh.h" #include "ssh.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
void Curl_version_init(void);
/* win32_cleanup() is for win32 socket cleanup functionality, the opposite /* win32_cleanup() is for win32 socket cleanup functionality, the opposite
of win32_init() */ of win32_init() */
static void win32_cleanup(void) static void win32_cleanup(void)
@ -120,8 +120,8 @@ 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 */
/* winsock.dll. */ /* winsock.dll. */
@ -220,20 +220,22 @@ curl_calloc_callback Curl_ccalloc;
* curl_global_init() globally initializes cURL given a bitwise set of the * curl_global_init() globally initializes cURL given a bitwise set of the
* different features of what to initialize. * different features of what to initialize.
*/ */
CURLcode curl_global_init(long flags) static CURLcode global_init(long flags, bool memoryfuncs)
{ {
if(initialized++) if(initialized++)
return CURLE_OK; return CURLE_OK;
/* Setup the default memory functions here (again) */ if(memoryfuncs) {
Curl_cmalloc = (curl_malloc_callback)malloc; /* Setup the default memory functions here (again) */
Curl_cfree = (curl_free_callback)free; Curl_cmalloc = (curl_malloc_callback)malloc;
Curl_crealloc = (curl_realloc_callback)realloc; Curl_cfree = (curl_free_callback)free;
Curl_cstrdup = (curl_strdup_callback)system_strdup; Curl_crealloc = (curl_realloc_callback)realloc;
Curl_ccalloc = (curl_calloc_callback)calloc; Curl_cstrdup = (curl_strdup_callback)system_strdup;
Curl_ccalloc = (curl_calloc_callback)calloc;
#if defined(WIN32) && defined(UNICODE) #if defined(WIN32) && defined(UNICODE)
Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup; Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;
#endif #endif
}
if(flags & CURL_GLOBAL_SSL) if(flags & CURL_GLOBAL_SSL)
if(!Curl_ssl_init()) { if(!Curl_ssl_init()) {
@ -269,6 +271,8 @@ CURLcode curl_global_init(long flags)
return CURLE_FAILED_INIT; return CURLE_FAILED_INIT;
} }
(void)Curl_ipv6works();
#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT) #if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT)
if(libssh2_init(0)) { if(libssh2_init(0)) {
DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n")); DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n"));
@ -279,11 +283,23 @@ CURLcode curl_global_init(long flags)
if(flags & CURL_GLOBAL_ACK_EINTR) if(flags & CURL_GLOBAL_ACK_EINTR)
Curl_ack_eintr = 1; Curl_ack_eintr = 1;
init_flags = flags; init_flags = flags;
Curl_version_init();
return CURLE_OK; return CURLE_OK;
} }
/**
* curl_global_init() globally initializes cURL given a bitwise set of the
* different features of what to initialize.
*/
CURLcode curl_global_init(long flags)
{
return global_init(flags, TRUE);
}
/* /*
* curl_global_init_mem() globally initializes cURL and also registers the * curl_global_init_mem() globally initializes cURL and also registers the
* user provided callback routines. * user provided callback routines.
@ -292,8 +308,6 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
curl_free_callback f, curl_realloc_callback r, curl_free_callback f, curl_realloc_callback r,
curl_strdup_callback s, curl_calloc_callback c) curl_strdup_callback s, curl_calloc_callback c)
{ {
CURLcode result = 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;
@ -306,17 +320,16 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
return CURLE_OK; return CURLE_OK;
} }
/* Call the actual init function first */ /* set memory functions before global_init() in case it wants memory
result = curl_global_init(flags); functions */
if(!result) { Curl_cmalloc = m;
Curl_cmalloc = m; Curl_cfree = f;
Curl_cfree = f; Curl_cstrdup = s;
Curl_cstrdup = s; Curl_crealloc = r;
Curl_crealloc = r; Curl_ccalloc = c;
Curl_ccalloc = c;
}
return result; /* Call the actual init function, but without setting */
return global_init(flags, FALSE);
} }
/** /**
@ -354,10 +367,10 @@ void curl_global_cleanup(void)
* curl_easy_init() is the external interface to alloc, setup and init an * curl_easy_init() is the external interface to alloc, setup and init an
* easy handle that is returned. If anything goes wrong, NULL is returned. * easy handle that is returned. If anything goes wrong, NULL is returned.
*/ */
CURL *curl_easy_init(void) struct Curl_easy *curl_easy_init(void)
{ {
CURLcode result; CURLcode result;
struct SessionHandle *data; struct Curl_easy *data;
/* Make sure we inited the global SSL stuff */ /* Make sure we inited the global SSL stuff */
if(!initialized) { if(!initialized) {
@ -385,13 +398,12 @@ CURL *curl_easy_init(void)
*/ */
#undef curl_easy_setopt #undef curl_easy_setopt
CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...) CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
{ {
va_list arg; va_list arg;
struct SessionHandle *data = curl;
CURLcode result; CURLcode result;
if(!curl) if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_BAD_FUNCTION_ARGUMENT;
va_start(arg, tag); va_start(arg, tag);
@ -423,7 +435,7 @@ struct events {
* updated. * updated.
*/ */
static int events_timer(CURLM *multi, /* multi handle */ static int events_timer(struct Curl_multi *multi, /* multi handle */
long timeout_ms, /* see above */ long timeout_ms, /* see above */
void *userp) /* private callback pointer */ void *userp) /* private callback pointer */
{ {
@ -478,7 +490,7 @@ static short socketcb2poll(int pollmask)
* Callback that gets called with information about socket activity to * Callback that gets called with information about socket activity to
* monitor. * monitor.
*/ */
static int events_socket(CURL *easy, /* easy handle */ static int events_socket(struct Curl_easy *easy, /* easy handle */
curl_socket_t s, /* socket */ curl_socket_t s, /* socket */
int what, /* see above */ int what, /* see above */
void *userp, /* private callback void *userp, /* private callback
@ -532,14 +544,18 @@ static int events_socket(CURL *easy, /* easy handle */
} }
else { else {
m = malloc(sizeof(struct socketmonitor)); m = malloc(sizeof(struct socketmonitor));
m->next = ev->list; if(m) {
m->socket.fd = s; m->next = ev->list;
m->socket.events = socketcb2poll(what); m->socket.fd = s;
m->socket.revents = 0; m->socket.events = socketcb2poll(what);
ev->list = m; m->socket.revents = 0;
infof(easy, "socket cb: socket %d ADDED as %s%s\n", s, ev->list = m;
what&CURL_POLL_IN?"IN":"", infof(easy, "socket cb: socket %d ADDED as %s%s\n", s,
what&CURL_POLL_OUT?"OUT":""); what&CURL_POLL_IN?"IN":"",
what&CURL_POLL_OUT?"OUT":"");
}
else
return CURLE_OUT_OF_MEMORY;
} }
} }
@ -552,7 +568,7 @@ static int events_socket(CURL *easy, /* easy handle */
* *
* Do the multi handle setups that only event-based transfers need. * Do the multi handle setups that only event-based transfers need.
*/ */
static void events_setup(CURLM *multi, struct events *ev) static void events_setup(struct Curl_multi *multi, struct events *ev)
{ {
/* timer callback */ /* timer callback */
curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, events_timer); curl_multi_setopt(multi, CURLMOPT_TIMERFUNCTION, events_timer);
@ -609,7 +625,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
if(0 == pollrc) { if(0 == pollrc) {
/* timeout! */ /* timeout! */
ev->ms = 0; ev->ms = 0;
/* fprintf(stderr, "call curl_multi_socket_action( TIMEOUT )\n"); */ /* fprintf(stderr, "call curl_multi_socket_action(TIMEOUT)\n"); */
mcode = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, mcode = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0,
&ev->running_handles); &ev->running_handles);
} }
@ -619,7 +635,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
if(fds[i].revents) { if(fds[i].revents) {
/* socket activity, tell libcurl */ /* socket activity, tell libcurl */
int act = poll2cselect(fds[i].revents); /* convert */ int act = poll2cselect(fds[i].revents); /* convert */
infof(multi->easyp, "call curl_multi_socket_action( socket %d )\n", infof(multi->easyp, "call curl_multi_socket_action(socket %d)\n",
fds[i].fd); fds[i].fd);
mcode = curl_multi_socket_action(multi, fds[i].fd, act, mcode = curl_multi_socket_action(multi, fds[i].fd, act,
&ev->running_handles); &ev->running_handles);
@ -656,7 +672,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
* *
* Runs a transfer in a blocking manner using the events-based API * Runs a transfer in a blocking manner using the events-based API
*/ */
static CURLcode easy_events(CURLM *multi) static CURLcode easy_events(struct Curl_multi *multi)
{ {
struct events evs= {2, FALSE, 0, NULL, 0}; struct events evs= {2, FALSE, 0, NULL, 0};
@ -670,7 +686,7 @@ static CURLcode easy_events(CURLM *multi)
#define easy_events(x) CURLE_NOT_BUILT_IN #define easy_events(x) CURLE_NOT_BUILT_IN
#endif #endif
static CURLcode easy_transfer(CURLM *multi) static CURLcode easy_transfer(struct Curl_multi *multi)
{ {
bool done = FALSE; bool done = FALSE;
CURLMcode mcode = CURLM_OK; CURLMcode mcode = CURLM_OK;
@ -681,26 +697,22 @@ static CURLcode easy_transfer(CURLM *multi)
while(!done && !mcode) { while(!done && !mcode) {
int still_running = 0; int still_running = 0;
int ret; int rc;
before = curlx_tvnow(); before = curlx_tvnow();
mcode = curl_multi_wait(multi, NULL, 0, 1000, &ret); mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc);
if(mcode == CURLM_OK) { if(!mcode) {
if(ret == -1) { if(!rc) {
/* poll() failed not on EINTR, indicate a network problem */
result = CURLE_RECV_ERROR;
break;
}
else if(ret == 0) {
struct timeval after = curlx_tvnow(); struct timeval after = curlx_tvnow();
/* If it returns without any filedescriptor instantly, we need to /* If it returns without any filedescriptor instantly, we need to
avoid busy-looping during periods where it has nothing particular avoid busy-looping during periods where it has nothing particular
to wait for */ to wait for */
if(curlx_tvdiff(after, before) <= 10) { if(curlx_tvdiff(after, before) <= 10) {
without_fds++; without_fds++;
if(without_fds > 2) { if(without_fds > 2) {
int sleep_ms = without_fds < 10 ? (1 << (without_fds-1)): 1000; int sleep_ms = without_fds < 10 ? (1 << (without_fds - 1)) : 1000;
Curl_wait_ms(sleep_ms); Curl_wait_ms(sleep_ms);
} }
} }
@ -716,8 +728,7 @@ static CURLcode easy_transfer(CURLM *multi)
} }
/* only read 'still_running' if curl_multi_perform() return OK */ /* only read 'still_running' if curl_multi_perform() return OK */
if((mcode == CURLM_OK) && !still_running) { if(!mcode && !still_running) {
int rc;
CURLMsg *msg = curl_multi_info_read(multi, &rc); CURLMsg *msg = curl_multi_info_read(multi, &rc);
if(msg) { if(msg) {
result = msg->data.result; result = msg->data.result;
@ -728,10 +739,10 @@ static CURLcode easy_transfer(CURLM *multi)
/* Make sure to return some kind of error if there was a multi problem */ /* Make sure to return some kind of error if there was a multi problem */
if(mcode) { if(mcode) {
return (mcode == CURLM_OUT_OF_MEMORY) ? CURLE_OUT_OF_MEMORY : result = (mcode == CURLM_OUT_OF_MEMORY) ? CURLE_OUT_OF_MEMORY :
/* The other multi errors should never happen, so return /* The other multi errors should never happen, so return
something suitably generic */ something suitably generic */
CURLE_BAD_FUNCTION_ARGUMENT; CURLE_BAD_FUNCTION_ARGUMENT;
} }
return result; return result;
@ -755,9 +766,9 @@ static CURLcode easy_transfer(CURLM *multi)
* DEBUG: if 'events' is set TRUE, this function will use a replacement engine * DEBUG: if 'events' is set TRUE, this function will use a replacement engine
* instead of curl_multi_perform() and use curl_multi_socket_action(). * instead of curl_multi_perform() and use curl_multi_socket_action().
*/ */
static CURLcode easy_perform(struct SessionHandle *data, bool events) static CURLcode easy_perform(struct Curl_easy *data, bool events)
{ {
CURLM *multi; struct Curl_multi *multi;
CURLMcode mcode; CURLMcode mcode;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
SIGPIPE_VARIABLE(pipe_st); SIGPIPE_VARIABLE(pipe_st);
@ -817,9 +828,9 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events)
* curl_easy_perform() is the external interface that performs a blocking * curl_easy_perform() is the external interface that performs a blocking
* transfer as previously setup. * transfer as previously setup.
*/ */
CURLcode curl_easy_perform(CURL *easy) CURLcode curl_easy_perform(struct Curl_easy *data)
{ {
return easy_perform(easy, FALSE); return easy_perform(data, FALSE);
} }
#ifdef CURLDEBUG #ifdef CURLDEBUG
@ -827,9 +838,9 @@ CURLcode curl_easy_perform(CURL *easy)
* curl_easy_perform_ev() is the external interface that performs a blocking * curl_easy_perform_ev() is the external interface that performs a blocking
* transfer using the event-based API internally. * transfer using the event-based API internally.
*/ */
CURLcode curl_easy_perform_ev(CURL *easy) CURLcode curl_easy_perform_ev(struct Curl_easy *data)
{ {
return easy_perform(easy, TRUE); return easy_perform(data, TRUE);
} }
#endif #endif
@ -838,9 +849,8 @@ CURLcode curl_easy_perform_ev(CURL *easy)
* curl_easy_cleanup() is the external interface to cleaning/freeing the given * curl_easy_cleanup() is the external interface to cleaning/freeing the given
* easy handle. * easy handle.
*/ */
void curl_easy_cleanup(CURL *curl) void curl_easy_cleanup(struct Curl_easy *data)
{ {
struct SessionHandle *data = (struct SessionHandle *)curl;
SIGPIPE_VARIABLE(pipe_st); SIGPIPE_VARIABLE(pipe_st);
if(!data) if(!data)
@ -856,12 +866,11 @@ void curl_easy_cleanup(CURL *curl)
* information from a performed transfer and similar. * information from a performed transfer and similar.
*/ */
#undef curl_easy_getinfo #undef curl_easy_getinfo
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...) CURLcode curl_easy_getinfo(struct Curl_easy *data, CURLINFO info, ...)
{ {
va_list arg; va_list arg;
void *paramp; void *paramp;
CURLcode result; CURLcode result;
struct SessionHandle *data = (struct SessionHandle *)curl;
va_start(arg, info); va_start(arg, info);
paramp = va_arg(arg, void *); paramp = va_arg(arg, void *);
@ -877,11 +886,9 @@ CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
* given input easy handle. The returned handle will be a new working handle * given input easy handle. The returned handle will be a new working handle
* with all options set exactly as the input source handle. * with all options set exactly as the input source handle.
*/ */
CURL *curl_easy_duphandle(CURL *incurl) struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
{ {
struct SessionHandle *data=(struct SessionHandle *)incurl; struct Curl_easy *outcurl = calloc(1, sizeof(struct Curl_easy));
struct SessionHandle *outcurl = calloc(1, sizeof(struct SessionHandle));
if(NULL == outcurl) if(NULL == outcurl)
goto fail; goto fail;
@ -972,10 +979,8 @@ CURL *curl_easy_duphandle(CURL *incurl)
* curl_easy_reset() is an external interface that allows an app to re- * curl_easy_reset() is an external interface that allows an app to re-
* initialize a session handle to the default values. * initialize a session handle to the default values.
*/ */
void curl_easy_reset(CURL *curl) void curl_easy_reset(struct Curl_easy *data)
{ {
struct SessionHandle *data = (struct SessionHandle *)curl;
Curl_safefree(data->state.pathbuffer); Curl_safefree(data->state.pathbuffer);
data->state.path = NULL; data->state.path = NULL;
@ -1004,9 +1009,8 @@ void curl_easy_reset(CURL *curl)
* *
* Action is a bitmask consisting of CURLPAUSE_* bits in curl/curl.h * Action is a bitmask consisting of CURLPAUSE_* bits in curl/curl.h
*/ */
CURLcode curl_easy_pause(CURL *curl, int action) CURLcode curl_easy_pause(struct Curl_easy *data, int action)
{ {
struct SessionHandle *data = (struct SessionHandle *)curl;
struct SingleRequest *k = &data->req; struct SingleRequest *k = &data->req;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -1046,7 +1050,7 @@ CURLcode curl_easy_pause(CURL *curl, int action)
} }
static CURLcode easy_connection(struct SessionHandle *data, static CURLcode easy_connection(struct Curl_easy *data,
curl_socket_t *sfd, curl_socket_t *sfd,
struct connectdata **connp) struct connectdata **connp)
{ {
@ -1074,13 +1078,13 @@ static CURLcode easy_connection(struct SessionHandle *data,
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option. * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
* Returns CURLE_OK on success, error code on error. * Returns CURLE_OK on success, error code on error.
*/ */
CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n) CURLcode curl_easy_recv(struct Curl_easy *data, void *buffer, size_t buflen,
size_t *n)
{ {
curl_socket_t sfd; curl_socket_t sfd;
CURLcode result; CURLcode result;
ssize_t n1; ssize_t n1;
struct connectdata *c; struct connectdata *c;
struct SessionHandle *data = (struct SessionHandle *)curl;
result = easy_connection(data, &sfd, &c); result = easy_connection(data, &sfd, &c);
if(result) if(result)
@ -1101,14 +1105,13 @@ CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n)
* Sends data over the connected socket. Use after successful * Sends data over the connected socket. Use after successful
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option. * curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
*/ */
CURLcode curl_easy_send(CURL *curl, const void *buffer, size_t buflen, CURLcode curl_easy_send(struct Curl_easy *data, const void *buffer,
size_t *n) size_t buflen, size_t *n)
{ {
curl_socket_t sfd; curl_socket_t sfd;
CURLcode result; CURLcode result;
ssize_t n1; ssize_t n1;
struct connectdata *c = NULL; struct connectdata *c = NULL;
struct SessionHandle *data = (struct SessionHandle *)curl;
result = easy_connection(data, &sfd, &c); result = easy_connection(data, &sfd, &c);
if(result) if(result)

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -26,7 +26,7 @@
* Prototypes for library-wide functions provided by easy.c * Prototypes for library-wide functions provided by easy.c
*/ */
#ifdef CURLDEBUG #ifdef CURLDEBUG
CURL_EXTERN CURLcode curl_easy_perform_ev(CURL *easy); CURL_EXTERN CURLcode curl_easy_perform_ev(struct Curl_easy *easy);
#endif #endif
#endif /* HEADER_CURL_EASYIF_H */ #endif /* HEADER_CURL_EASYIF_H */

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -31,15 +31,14 @@
#include "warnless.h" #include "warnless.h"
#include "non-ascii.h" #include "non-ascii.h"
#include "escape.h" #include "escape.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
/* Portable character check (remember EBCDIC). Do not use isalnum() because /* Portable character check (remember EBCDIC). Do not use isalnum() because
its behavior is altered by the current locale. its behavior is altered by the current locale.
See http://tools.ietf.org/html/rfc3986#section-2.3 See https://tools.ietf.org/html/rfc3986#section-2.3
*/ */
static bool Curl_isunreserved(unsigned char in) static bool Curl_isunreserved(unsigned char in)
{ {
@ -76,7 +75,8 @@ char *curl_unescape(const char *string, int length)
return curl_easy_unescape(NULL, string, length, NULL); return curl_easy_unescape(NULL, string, length, NULL);
} }
char *curl_easy_escape(CURL *handle, const char *string, int inlength) char *curl_easy_escape(struct Curl_easy *data, const char *string,
int inlength)
{ {
size_t alloc = (inlength?(size_t)inlength:strlen(string))+1; size_t alloc = (inlength?(size_t)inlength:strlen(string))+1;
char *ns; char *ns;
@ -105,7 +105,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
alloc *= 2; alloc *= 2;
testing_ptr = realloc(ns, alloc); testing_ptr = realloc(ns, alloc);
if(!testing_ptr) { if(!testing_ptr) {
free( ns ); free(ns);
return NULL; return NULL;
} }
else { else {
@ -113,7 +113,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
} }
} }
result = Curl_convert_to_network(handle, &in, 1); result = Curl_convert_to_network(data, &in, 1);
if(result) { if(result) {
/* Curl_convert_to_network calls failf if unsuccessful */ /* Curl_convert_to_network calls failf if unsuccessful */
free(ns); free(ns);
@ -140,7 +140,7 @@ char *curl_easy_escape(CURL *handle, const char *string, int inlength)
* *olen. If length == 0, the length is assumed to be strlen(string). * *olen. If length == 0, the length is assumed to be strlen(string).
* *
*/ */
CURLcode Curl_urldecode(struct SessionHandle *data, CURLcode Curl_urldecode(struct Curl_easy *data,
const char *string, size_t length, const char *string, size_t length,
char **ostring, size_t *olen, char **ostring, size_t *olen,
bool reject_ctrl) bool reject_ctrl)
@ -207,13 +207,13 @@ CURLcode Curl_urldecode(struct SessionHandle *data,
* If length == 0, the length is assumed to be strlen(string). * If length == 0, the length is assumed to be strlen(string).
* If olen == NULL, no output length is stored. * If olen == NULL, no output length is stored.
*/ */
char *curl_easy_unescape(CURL *handle, const char *string, int length, char *curl_easy_unescape(struct Curl_easy *data, const char *string,
int *olen) int length, int *olen)
{ {
char *str = NULL; char *str = NULL;
size_t inputlen = length; size_t inputlen = length;
size_t outputlen; size_t outputlen;
CURLcode res = Curl_urldecode(handle, string, inputlen, &str, &outputlen, CURLcode res = Curl_urldecode(data, string, inputlen, &str, &outputlen,
FALSE); FALSE);
if(res) if(res)
return NULL; return NULL;

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -24,7 +24,7 @@
/* Escape and unescape URL encoding in strings. The functions return a new /* Escape and unescape URL encoding in strings. The functions return a new
* allocated string or NULL if an error occurred. */ * allocated string or NULL if an error occurred. */
CURLcode Curl_urldecode(struct SessionHandle *data, CURLcode Curl_urldecode(struct Curl_easy *data,
const char *string, size_t length, const char *string, size_t length,
char **ostring, size_t *olen, char **ostring, size_t *olen,
bool reject_crlf); bool reject_crlf);

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -61,9 +61,8 @@
#include "url.h" #include "url.h"
#include "parsedate.h" /* for the week day and month names */ #include "parsedate.h" /* for the week day and month names */
#include "warnless.h" #include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -136,7 +135,7 @@ static CURLcode file_range(struct connectdata *conn)
curl_off_t totalsize=-1; curl_off_t totalsize=-1;
char *ptr; char *ptr;
char *ptr2; char *ptr2;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
if(data->state.use_range && data->state.range) { if(data->state.use_range && data->state.range) {
from=curlx_strtoofft(data->state.range, &ptr, 0); from=curlx_strtoofft(data->state.range, &ptr, 0);
@ -186,7 +185,7 @@ static CURLcode file_range(struct connectdata *conn)
*/ */
static CURLcode file_connect(struct connectdata *conn, bool *done) static CURLcode file_connect(struct connectdata *conn, bool *done)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
char *real_path; char *real_path;
struct FILEPROTO *file = data->req.protop; struct FILEPROTO *file = data->req.protop;
int fd; int fd;
@ -228,15 +227,19 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
for(i=0; i < real_path_len; ++i) for(i=0; i < real_path_len; ++i)
if(actual_path[i] == '/') if(actual_path[i] == '/')
actual_path[i] = '\\'; actual_path[i] = '\\';
else if(!actual_path[i]) /* binary zero */ else if(!actual_path[i]) { /* binary zero */
Curl_safefree(real_path);
return CURLE_URL_MALFORMAT; return CURLE_URL_MALFORMAT;
}
fd = open_readonly(actual_path, O_RDONLY|O_BINARY); fd = open_readonly(actual_path, O_RDONLY|O_BINARY);
file->path = actual_path; file->path = actual_path;
#else #else
if(memchr(real_path, 0, real_path_len)) if(memchr(real_path, 0, real_path_len)) {
/* binary zeroes indicate foul play */ /* binary zeroes indicate foul play */
Curl_safefree(real_path);
return CURLE_URL_MALFORMAT; return CURLE_URL_MALFORMAT;
}
fd = open_readonly(real_path, O_RDONLY); fd = open_readonly(real_path, O_RDONLY);
file->path = real_path; file->path = real_path;
@ -302,7 +305,7 @@ static CURLcode file_upload(struct connectdata *conn)
int fd; int fd;
int mode; int mode;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
char *buf = data->state.buffer; char *buf = data->state.buffer;
size_t nread; size_t nread;
size_t nwrite; size_t nwrite;
@ -368,7 +371,7 @@ static CURLcode file_upload(struct connectdata *conn)
/*skip bytes before resume point*/ /*skip bytes before resume point*/
if(data->state.resume_from) { if(data->state.resume_from) {
if((curl_off_t)nread <= data->state.resume_from ) { if((curl_off_t)nread <= data->state.resume_from) {
data->state.resume_from -= nread; data->state.resume_from -= nread;
nread = 0; nread = 0;
buf2 = buf; buf2 = buf;
@ -426,9 +429,10 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
Windows version to have a different struct without Windows version to have a different struct without
having to redefine the simple word 'stat' */ having to redefine the simple word 'stat' */
curl_off_t expected_size=0; curl_off_t expected_size=0;
bool size_known;
bool fstated=FALSE; bool fstated=FALSE;
ssize_t nread; ssize_t nread;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
char *buf = data->state.buffer; char *buf = data->state.buffer;
curl_off_t bytecount = 0; curl_off_t bytecount = 0;
int fd; int fd;
@ -468,6 +472,9 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
information. Which for FILE can't be much more than the file size and information. Which for FILE can't be much more than the file size and
date. */ date. */
if(data->set.opt_no_body && data->set.include_header && fstated) { if(data->set.opt_no_body && data->set.include_header && fstated) {
time_t filetime;
struct tm buffer;
const struct tm *tm = &buffer;
snprintf(buf, sizeof(data->state.buffer), snprintf(buf, sizeof(data->state.buffer),
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size); "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
@ -479,29 +486,24 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
if(result) if(result)
return result; return result;
if(fstated) { filetime = (time_t)statbuf.st_mtime;
time_t filetime = (time_t)statbuf.st_mtime; result = Curl_gmtime(filetime, &buffer);
struct tm buffer; if(result)
const struct tm *tm = &buffer; return result;
result = Curl_gmtime(filetime, &buffer);
if(result)
return result;
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */ /* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
snprintf(buf, BUFSIZE-1, snprintf(buf, BUFSIZE-1,
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
Curl_wkday[tm->tm_wday?tm->tm_wday-1:6], Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
tm->tm_mday, tm->tm_mday,
Curl_month[tm->tm_mon], Curl_month[tm->tm_mon],
tm->tm_year + 1900, tm->tm_year + 1900,
tm->tm_hour, tm->tm_hour,
tm->tm_min, tm->tm_min,
tm->tm_sec); tm->tm_sec);
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0); result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
} if(!result)
/* if we fstat()ed the file, set the file size to make it available post- /* set the file size to make it available post transfer */
transfer */
if(fstated)
Curl_pgrsSetDownloadSize(data, expected_size); Curl_pgrsSetDownloadSize(data, expected_size);
return result; return result;
} }
@ -531,8 +533,10 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
if(data->req.maxdownload > 0) if(data->req.maxdownload > 0)
expected_size = data->req.maxdownload; expected_size = data->req.maxdownload;
if(fstated && (expected_size == 0)) if(!fstated || (expected_size == 0))
return CURLE_OK; size_known = FALSE;
else
size_known = TRUE;
/* The following is a shortcut implementation of file reading /* The following is a shortcut implementation of file reading
this is both more efficient than the former call to download() and this is both more efficient than the former call to download() and
@ -551,20 +555,27 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
while(!result) { while(!result) {
/* Don't fill a whole buffer if we want less than all data */ /* Don't fill a whole buffer if we want less than all data */
size_t bytestoread = size_t bytestoread;
(expected_size < CURL_OFF_T_C(BUFSIZE) - CURL_OFF_T_C(1)) ?
curlx_sotouz(expected_size) : BUFSIZE - 1; if(size_known) {
bytestoread =
(expected_size < CURL_OFF_T_C(BUFSIZE) - CURL_OFF_T_C(1)) ?
curlx_sotouz(expected_size) : BUFSIZE - 1;
}
else
bytestoread = BUFSIZE-1;
nread = read(fd, buf, bytestoread); nread = read(fd, buf, bytestoread);
if(nread > 0) if(nread > 0)
buf[nread] = 0; buf[nread] = 0;
if(nread <= 0 || expected_size == 0) if(nread <= 0 || (size_known && (expected_size == 0)))
break; break;
bytecount += nread; bytecount += nread;
expected_size -= nread; if(size_known)
expected_size -= nread;
result = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread); result = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread);
if(result) if(result)

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -30,15 +30,14 @@
#include <libgen.h> #include <libgen.h>
#endif #endif
#include "urldata.h" /* for struct SessionHandle */ #include "urldata.h" /* for struct Curl_easy */
#include "formdata.h" #include "formdata.h"
#include "vtls/vtls.h" #include "vtls/vtls.h"
#include "strequal.h" #include "strequal.h"
#include "sendf.h" #include "sendf.h"
#include "strdup.h" #include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
/* The last #include files should be: */
#include "curl_memory.h" #include "curl_memory.h"
#include "memdebug.h" #include "memdebug.h"
@ -48,7 +47,7 @@ static char *Curl_basename(char *path);
#endif #endif
static size_t readfromfile(struct Form *form, char *buffer, size_t size); static size_t readfromfile(struct Form *form, char *buffer, size_t size);
static char *formboundary(struct SessionHandle *data); static char *formboundary(struct Curl_easy *data);
/* What kind of Content-Type to use on un-specified files with unrecognized /* What kind of Content-Type to use on un-specified files with unrecognized
extensions. */ extensions. */
@ -57,6 +56,14 @@ static char *formboundary(struct SessionHandle *data);
#define FORM_FILE_SEPARATOR ',' #define FORM_FILE_SEPARATOR ','
#define FORM_TYPE_SEPARATOR ';' #define FORM_TYPE_SEPARATOR ';'
#define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME
#define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME
#define HTTPPOST_PTRCONTENTS CURL_HTTPPOST_PTRCONTENTS
#define HTTPPOST_READFILE CURL_HTTPPOST_READFILE
#define HTTPPOST_PTRBUFFER CURL_HTTPPOST_PTRBUFFER
#define HTTPPOST_CALLBACK CURL_HTTPPOST_CALLBACK
#define HTTPPOST_BUFFER CURL_HTTPPOST_BUFFER
/*************************************************************************** /***************************************************************************
* *
* AddHttpPost() * AddHttpPost()
@ -69,7 +76,7 @@ static char *formboundary(struct SessionHandle *data);
***************************************************************************/ ***************************************************************************/
static struct curl_httppost * static struct curl_httppost *
AddHttpPost(char *name, size_t namelength, AddHttpPost(char *name, size_t namelength,
char *value, size_t contentslength, char *value, curl_off_t contentslength,
char *buffer, size_t bufferlength, char *buffer, size_t bufferlength,
char *contenttype, char *contenttype,
long flags, long flags,
@ -85,14 +92,14 @@ AddHttpPost(char *name, size_t namelength,
post->name = name; post->name = name;
post->namelength = (long)(name?(namelength?namelength:strlen(name)):0); post->namelength = (long)(name?(namelength?namelength:strlen(name)):0);
post->contents = value; post->contents = value;
post->contentslength = (long)contentslength; post->contentlen = contentslength;
post->buffer = buffer; post->buffer = buffer;
post->bufferlength = (long)bufferlength; post->bufferlength = (long)bufferlength;
post->contenttype = contenttype; post->contenttype = contenttype;
post->contentheader = contentHeader; post->contentheader = contentHeader;
post->showfilename = showfilename; post->showfilename = showfilename;
post->userp = userp, post->userp = userp,
post->flags = flags; post->flags = flags | CURL_HTTPPOST_LARGE;
} }
else else
return NULL; return NULL;
@ -372,11 +379,14 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
} }
break; break;
case CURLFORM_CONTENTSLENGTH: case CURLFORM_CONTENTSLENGTH:
if(current_form->contentslength) current_form->contentslength =
return_value = CURL_FORMADD_OPTION_TWICE; array_state?(size_t)array_value:(size_t)va_arg(params, long);
else break;
current_form->contentslength =
array_state?(size_t)array_value:(size_t)va_arg(params, long); case CURLFORM_CONTENTLEN:
current_form->flags |= CURL_HTTPPOST_LARGE;
current_form->contentslength =
array_state?(curl_off_t)(size_t)array_value:va_arg(params, curl_off_t);
break; break;
/* Get contents from a given file name */ /* Get contents from a given file name */
@ -538,7 +548,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* this "cast increases required alignment of target type" but /* this "cast increases required alignment of target type" but
we consider it OK anyway */ we consider it OK anyway */
struct curl_slist* list = array_state? struct curl_slist* list = array_state?
(struct curl_slist*)array_value: (struct curl_slist*)(void*)array_value:
va_arg(params, struct curl_slist*); va_arg(params, struct curl_slist*);
if(current_form->contentheader) if(current_form->contentheader)
@ -621,7 +631,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
else { else {
if(((form->flags & HTTPPOST_FILENAME) || if(((form->flags & HTTPPOST_FILENAME) ||
(form->flags & HTTPPOST_BUFFER)) && (form->flags & HTTPPOST_BUFFER)) &&
!form->contenttype ) { !form->contenttype) {
char *f = form->flags & HTTPPOST_BUFFER? char *f = form->flags & HTTPPOST_BUFFER?
form->showfilename : form->value; form->showfilename : form->value;
@ -653,9 +663,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER | HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER |
HTTPPOST_CALLBACK)) && form->value) { HTTPPOST_CALLBACK)) && form->value) {
/* copy value (without strdup; possibly contains null characters) */ /* copy value (without strdup; possibly contains null characters) */
form->value = Curl_memdup(form->value, form->contentslength? size_t clen = (size_t) form->contentslength;
form->contentslength: if(!clen)
strlen(form->value)+1); clen = strlen(form->value)+1;
form->value = Curl_memdup(form->value, clen);
if(!form->value) { if(!form->value) {
return_value = CURL_FORMADD_MEMORY; return_value = CURL_FORMADD_MEMORY;
break; break;
@ -756,7 +769,7 @@ curl_off_t VmsRealFileSize(const char * name,
int ret_stat; int ret_stat;
FILE * file; FILE * file;
file = fopen(name, "r"); /* VMS */ file = fopen(name, FOPEN_READTEXT); /* VMS */
if(file == NULL) if(file == NULL)
return 0; return 0;
@ -808,10 +821,16 @@ static curl_off_t VmsSpecialSize(const char * name,
static CURLcode AddFormData(struct FormData **formp, static CURLcode AddFormData(struct FormData **formp,
enum formtype type, enum formtype type,
const void *line, const void *line,
size_t length, curl_off_t length,
curl_off_t *size) curl_off_t *size)
{ {
struct FormData *newform = malloc(sizeof(struct FormData)); struct FormData *newform;
char *alloc2 = NULL;
CURLcode result = CURLE_OK;
if(length < 0 || (size && *size < 0))
return CURLE_BAD_FUNCTION_ARGUMENT;
newform = malloc(sizeof(struct FormData));
if(!newform) if(!newform)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
newform->next = NULL; newform->next = NULL;
@ -820,15 +839,22 @@ static CURLcode AddFormData(struct FormData **formp,
/* we make it easier for plain strings: */ /* we make it easier for plain strings: */
if(!length) if(!length)
length = strlen((char *)line); length = strlen((char *)line);
#if (SIZEOF_SIZE_T < CURL_SIZEOF_CURL_OFF_T)
newform->line = malloc(length+1); else if(length >= (curl_off_t)(size_t)-1) {
if(!newform->line) { result = CURLE_BAD_FUNCTION_ARGUMENT;
free(newform); goto error;
return CURLE_OUT_OF_MEMORY;
} }
memcpy(newform->line, line, length); #endif
newform->length = length;
newform->line[length]=0; /* zero terminate for easier debugging */ newform->line = malloc((size_t)length+1);
if(!newform->line) {
result = CURLE_OUT_OF_MEMORY;
goto error;
}
alloc2 = newform->line;
memcpy(newform->line, line, (size_t)length);
newform->length = (size_t)length;
newform->line[(size_t)length]=0; /* zero terminate for easier debugging */
} }
else else
/* For callbacks and files we don't have any actual data so we just keep a /* For callbacks and files we don't have any actual data so we just keep a
@ -856,12 +882,20 @@ static CURLcode AddFormData(struct FormData **formp,
struct_stat file; struct_stat file;
if(!stat(newform->line, &file) && !S_ISDIR(file.st_mode)) if(!stat(newform->line, &file) && !S_ISDIR(file.st_mode))
*size += filesize(newform->line, file); *size += filesize(newform->line, file);
else else {
return CURLE_BAD_FUNCTION_ARGUMENT; result = CURLE_BAD_FUNCTION_ARGUMENT;
goto error;
}
} }
} }
} }
return CURLE_OK; return CURLE_OK;
error:
if(newform)
free(newform);
if(alloc2)
free(alloc2);
return result;
} }
/* /*
@ -1102,7 +1136,7 @@ static CURLcode formdata_add_filename(const struct curl_httppost *file,
* a NULL pointer in the 'data' argument. * a NULL pointer in the 'data' argument.
*/ */
CURLcode Curl_getformdata(struct SessionHandle *data, CURLcode Curl_getformdata(struct Curl_easy *data,
struct FormData **finalform, struct FormData **finalform,
struct curl_httppost *post, struct curl_httppost *post,
const char *custom_content_type, const char *custom_content_type,
@ -1238,7 +1272,7 @@ CURLcode Curl_getformdata(struct SessionHandle *data,
curList = file->contentheader; curList = file->contentheader;
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;
@ -1298,15 +1332,16 @@ CURLcode Curl_getformdata(struct SessionHandle *data,
result = AddFormData(&form, FORM_CONTENT, post->buffer, result = AddFormData(&form, FORM_CONTENT, post->buffer,
post->bufferlength, &size); post->bufferlength, &size);
else if(post->flags & HTTPPOST_CALLBACK) else if(post->flags & HTTPPOST_CALLBACK)
/* the contents should be read with the callback and the size /* the contents should be read with the callback and the size is set
is set with the contentslength */ with the contentslength */
result = AddFormData(&form, FORM_CALLBACK, post->userp, result = AddFormData(&form, FORM_CALLBACK, post->userp,
post->contentslength, &size); post->flags&CURL_HTTPPOST_LARGE?
post->contentlen:post->contentslength, &size);
else else
/* 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->flags&CURL_HTTPPOST_LARGE?
post->contentlen:post->contentslength, &size);
file = file->more; file = file->more;
} while(file && !result); /* for each specified file for this field */ } while(file && !result); /* for each specified file for this field */
@ -1350,7 +1385,7 @@ CURLcode Curl_getformdata(struct SessionHandle *data,
* Curl_FormInit() inits the struct 'form' points to with the 'formdata' * Curl_FormInit() inits the struct 'form' points to with the 'formdata'
* and resets the 'sent' counter. * and resets the 'sent' counter.
*/ */
int Curl_FormInit(struct Form *form, struct FormData *formdata ) int Curl_FormInit(struct Form *form, struct FormData *formdata)
{ {
if(!formdata) if(!formdata)
return 1; /* error */ return 1; /* error */
@ -1385,10 +1420,10 @@ static FILE * vmsfopenread(const char *file, const char *mode) {
case FAB$C_VAR: case FAB$C_VAR:
case FAB$C_VFC: case FAB$C_VFC:
case FAB$C_STMCR: case FAB$C_STMCR:
return fopen(file, "r"); /* VMS */ return fopen(file, FOPEN_READTEXT); /* VMS */
break; break;
default: default:
return fopen(file, "r", "rfm=stmlf", "ctx=stm"); return fopen(file, FOPEN_READTEXT, "rfm=stmlf", "ctx=stm");
} }
} }
#endif #endif
@ -1463,9 +1498,9 @@ size_t Curl_FormReader(char *buffer,
} }
do { do {
if((form->data->length - form->sent ) > wantedsize - gotsize) { if((form->data->length - form->sent) > wantedsize - gotsize) {
memcpy(buffer + gotsize , form->data->line + form->sent, memcpy(buffer + gotsize, form->data->line + form->sent,
wantedsize - gotsize); wantedsize - gotsize);
form->sent += wantedsize-gotsize; form->sent += wantedsize-gotsize;
@ -1514,7 +1549,7 @@ char *Curl_formpostheader(void *formp, size_t *len)
* formboundary() creates a suitable boundary string and returns an allocated * formboundary() creates a suitable boundary string and returns an allocated
* one. * one.
*/ */
static char *formboundary(struct SessionHandle *data) static char *formboundary(struct Curl_easy *data)
{ {
/* 24 dashes and 16 hexadecimal digits makes 64 bit (18446744073709551615) /* 24 dashes and 16 hexadecimal digits makes 64 bit (18446744073709551615)
combinations */ combinations */

View File

@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -54,7 +54,7 @@ typedef struct FormInfo {
size_t namelength; size_t namelength;
char *value; char *value;
bool value_alloc; bool value_alloc;
size_t contentslength; curl_off_t contentslength;
char *contenttype; char *contenttype;
bool contenttype_alloc; bool contenttype_alloc;
long flags; long flags;
@ -68,9 +68,9 @@ typedef struct FormInfo {
struct FormInfo *more; struct FormInfo *more;
} FormInfo; } FormInfo;
int Curl_FormInit(struct Form *form, struct FormData *formdata ); int Curl_FormInit(struct Form *form, struct FormData *formdata);
CURLcode Curl_getformdata(struct SessionHandle *data, CURLcode Curl_getformdata(struct Curl_easy *data,
struct FormData **, struct FormData **,
struct curl_httppost *post, struct curl_httppost *post,
const char *custom_contenttype, const char *custom_contenttype,
@ -93,6 +93,6 @@ char *Curl_FormBoundary(void);
void Curl_formclean(struct FormData **); void Curl_formclean(struct FormData **);
CURLcode Curl_formconvert(struct SessionHandle *, struct FormData *); CURLcode Curl_formconvert(struct Curl_easy *, struct FormData *);
#endif /* HEADER_CURL_FORMDATA_H */ #endif /* HEADER_CURL_FORMDATA_H */

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -77,10 +77,9 @@
#include "warnless.h" #include "warnless.h"
#include "http_proxy.h" #include "http_proxy.h"
#include "non-ascii.h" #include "non-ascii.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
#ifndef NI_MAXHOST #ifndef NI_MAXHOST
@ -155,8 +154,9 @@ static CURLcode ftp_dophase_done(struct connectdata *conn,
bool connected); bool connected);
/* easy-to-use macro: */ /* easy-to-use macro: */
#define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z))) \ #define PPSENDF(x,y,z) result = Curl_pp_sendf(x,y,z); \
return result if(result) \
return result
/* /*
@ -265,6 +265,15 @@ static const struct Curl_handler Curl_handler_ftps_proxy = {
#endif #endif
#endif #endif
static void close_secondarysocket(struct connectdata *conn)
{
if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) {
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
}
conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
conn->tunnel_state[SECONDARYSOCKET] = TUNNEL_INIT;
}
/* /*
* NOTE: back in the old days, we added code in the FTP code that made NOBODY * NOTE: back in the old days, we added code in the FTP code that made NOBODY
@ -318,7 +327,7 @@ static bool isBadFtpString(const char *string)
*/ */
static CURLcode AcceptServerConnect(struct connectdata *conn) static CURLcode AcceptServerConnect(struct connectdata *conn)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
curl_socket_t sock = conn->sock[SECONDARYSOCKET]; curl_socket_t sock = conn->sock[SECONDARYSOCKET];
curl_socket_t s = CURL_SOCKET_BAD; curl_socket_t s = CURL_SOCKET_BAD;
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
@ -340,6 +349,9 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
return CURLE_FTP_PORT_FAILED; return CURLE_FTP_PORT_FAILED;
} }
infof(data, "Connection accepted from server\n"); infof(data, "Connection accepted from server\n");
/* when this happens within the DO state it is important that we mark us as
not needing DO_MORE anymore */
conn->bits.do_more = FALSE;
conn->sock[SECONDARYSOCKET] = s; conn->sock[SECONDARYSOCKET] = s;
(void)curlx_nonblock(s, TRUE); /* enable non-blocking */ (void)curlx_nonblock(s, TRUE); /* enable non-blocking */
@ -354,8 +366,7 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
CURLSOCKTYPE_ACCEPT); CURLSOCKTYPE_ACCEPT);
if(error) { if(error) {
Curl_closesocket(conn, s); /* close the socket and bail out */ close_secondarysocket(conn);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
return CURLE_ABORTED_BY_CALLBACK; return CURLE_ABORTED_BY_CALLBACK;
} }
} }
@ -373,7 +384,7 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
* Curl_pgrsTime(..., TIMER_STARTACCEPT); * Curl_pgrsTime(..., TIMER_STARTACCEPT);
* *
*/ */
static long ftp_timeleft_accept(struct SessionHandle *data) static long ftp_timeleft_accept(struct Curl_easy *data)
{ {
long timeout_ms = DEFAULT_ACCEPT_TIMEOUT; long timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
long other; long other;
@ -413,7 +424,7 @@ static long ftp_timeleft_accept(struct SessionHandle *data)
*/ */
static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received) static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
curl_socket_t ctrl_sock = conn->sock[FIRSTSOCKET]; curl_socket_t ctrl_sock = conn->sock[FIRSTSOCKET];
curl_socket_t data_sock = conn->sock[SECONDARYSOCKET]; curl_socket_t data_sock = conn->sock[SECONDARYSOCKET];
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
@ -484,7 +495,7 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
*/ */
static CURLcode InitiateTransfer(struct connectdata *conn) static CURLcode InitiateTransfer(struct connectdata *conn)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -535,7 +546,7 @@ static CURLcode InitiateTransfer(struct connectdata *conn)
*/ */
static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected) static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
long timeout_ms; long timeout_ms;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -606,7 +617,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
size_t *size) /* size of the response */ size_t *size) /* size of the response */
{ {
struct connectdata *conn = pp->conn; struct connectdata *conn = pp->conn;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
#ifdef HAVE_GSSAPI #ifdef HAVE_GSSAPI
char * const buf = data->state.buffer; char * const buf = data->state.buffer;
#endif #endif
@ -678,7 +689,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
long timeout; /* timeout in milliseconds */ long timeout; /* timeout in milliseconds */
long interval_ms; long interval_ms;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
@ -698,7 +709,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
/* check and reset timeout value every lap */ /* check and reset timeout value every lap */
timeout = Curl_pp_state_timeout(pp); timeout = Curl_pp_state_timeout(pp);
if(timeout <=0 ) { if(timeout <=0) {
failf(data, "FTP response timeout"); failf(data, "FTP response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */ return CURLE_OPERATION_TIMEDOUT; /* already too little time */
} }
@ -969,7 +980,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
curl_socket_t portsock= CURL_SOCKET_BAD; curl_socket_t portsock= CURL_SOCKET_BAD;
char myhost[256] = ""; char myhost[256] = "";
@ -1024,7 +1035,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(*string_ftpport == '[') { if(*string_ftpport == '[') {
/* [ipv6]:port(-range) */ /* [ipv6]:port(-range) */
ip_start = string_ftpport + 1; ip_start = string_ftpport + 1;
if((ip_end = strchr(string_ftpport, ']')) != NULL ) if((ip_end = strchr(string_ftpport, ']')) != NULL)
strncpy(addr, ip_start, ip_end - ip_start); strncpy(addr, ip_start, ip_end - ip_start);
} }
else else
@ -1045,7 +1056,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else else
#endif #endif
/* (ipv4|domain|interface):port(-range) */ /* (ipv4|domain|interface):port(-range) */
strncpy(addr, string_ftpport, ip_end - ip_start ); strncpy(addr, string_ftpport, ip_end - ip_start);
} }
else else
/* ipv4|interface */ /* ipv4|interface */
@ -1065,11 +1076,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* correct errors like: /* correct errors like:
* :1234-1230 * :1234-1230
* :-4711 , in this case port_min is (unsigned)-1, * :-4711, in this case port_min is (unsigned)-1,
* therefore port_min > port_max for all cases * therefore port_min > port_max for all cases
* but port_max = (unsigned)-1 * but port_max = (unsigned)-1
*/ */
if(port_min > port_max ) if(port_min > port_max)
port_min = port_max = 0; port_min = port_max = 0;
@ -1322,11 +1333,11 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* store which command was sent */ /* store which command was sent */
ftpc->count1 = fcmd; ftpc->count1 = fcmd;
close_secondarysocket(conn);
/* we set the secondary socket variable to this for now, it is only so that /* we set the secondary socket variable to this for now, it is only so that
the cleanup function will close it in case we fail before the true the cleanup function will close it in case we fail before the true
secondary stuff is made */ secondary stuff is made */
if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET])
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = portsock; conn->sock[SECONDARYSOCKET] = portsock;
/* this tcpconnect assignment below is a hackish work-around to make the /* this tcpconnect assignment below is a hackish work-around to make the
@ -1392,7 +1403,7 @@ static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->req.protop; struct FTP *ftp = conn->data->req.protop;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
if(ftp->transfer != FTPTRANSFER_BODY) { if(ftp->transfer != FTPTRANSFER_BODY) {
/* doesn't transfer any data */ /* doesn't transfer any data */
@ -1475,7 +1486,7 @@ static CURLcode ftp_state_size(struct connectdata *conn)
static CURLcode ftp_state_list(struct connectdata *conn) static CURLcode ftp_state_list(struct connectdata *conn)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
/* If this output is to be machine-parsed, the NLST command might be better /* If this output is to be machine-parsed, the NLST command might be better
to use, since the LIST command output is not specified or standard in any to use, since the LIST command output is not specified or standard in any
@ -1513,12 +1524,12 @@ static CURLcode ftp_state_list(struct connectdata *conn)
} }
} }
cmd = aprintf( "%s%s%s", cmd = aprintf("%s%s%s",
data->set.str[STRING_CUSTOMREQUEST]? data->set.str[STRING_CUSTOMREQUEST]?
data->set.str[STRING_CUSTOMREQUEST]: data->set.str[STRING_CUSTOMREQUEST]:
(data->set.ftp_list_only?"NLST":"LIST"), (data->set.ftp_list_only?"NLST":"LIST"),
lstArg? " ": "", lstArg? " ": "",
lstArg? lstArg: "" ); lstArg? lstArg: "");
if(!cmd) { if(!cmd) {
free(lstArg); free(lstArg);
@ -1564,7 +1575,7 @@ static CURLcode ftp_state_type(struct connectdata *conn)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->req.protop; struct FTP *ftp = conn->data->req.protop;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
/* If we have selected NOBODY and HEADER, it means that we only want file /* If we have selected NOBODY and HEADER, it means that we only want file
@ -1596,7 +1607,7 @@ static CURLcode ftp_state_type(struct connectdata *conn)
static CURLcode ftp_state_mdtm(struct connectdata *conn) static CURLcode ftp_state_mdtm(struct connectdata *conn)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
/* Requested time of file or time-depended transfer? */ /* Requested time of file or time-depended transfer? */
@ -1621,7 +1632,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct FTP *ftp = conn->data->req.protop; struct FTP *ftp = conn->data->req.protop;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
int seekerr = CURL_SEEKFUNC_OK; int seekerr = CURL_SEEKFUNC_OK;
@ -1640,7 +1651,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
/* 4. lower the infilesize counter */ /* 4. lower the infilesize counter */
/* => transfer as usual */ /* => transfer as usual */
if(data->state.resume_from < 0 ) { if(data->state.resume_from < 0) {
/* Got no given size to start from, figure it out */ /* Got no given size to start from, figure it out */
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file);
state(conn, FTP_STOR_SIZE); state(conn, FTP_STOR_SIZE);
@ -1670,8 +1681,8 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
BUFSIZE : curlx_sotouz(data->state.resume_from - passed); BUFSIZE : curlx_sotouz(data->state.resume_from - passed);
size_t actuallyread = size_t actuallyread =
data->set.fread_func(data->state.buffer, 1, readthisamountnow, data->state.fread_func(data->state.buffer, 1, readthisamountnow,
data->set.in); data->state.in);
passed += actuallyread; passed += actuallyread;
if((actuallyread == 0) || (actuallyread > readthisamountnow)) { if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
@ -1717,7 +1728,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
bool quote=FALSE; bool quote=FALSE;
@ -1787,8 +1798,20 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
result = ftp_state_retr(conn, ftpc->known_filesize); result = ftp_state_retr(conn, ftpc->known_filesize);
} }
else { else {
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file); if(data->set.ignorecl) {
state(conn, FTP_RETR_SIZE); /* This code is to support download of growing files. It prevents
the state machine from requesting the file size from the
server. With an unknown file size the download continues until
the server terminates it, otherwise the client stops if the
received byte count exceeds the reported file size. Set option
CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable this behavior.*/
PPSENDF(&ftpc->pp, "RETR %s", ftpc->file);
state(conn, FTP_RETR);
}
else {
PPSENDF(&ftpc->pp, "SIZE %s", ftpc->file);
state(conn, FTP_RETR_SIZE);
}
} }
} }
break; break;
@ -1836,7 +1859,7 @@ static CURLcode proxy_magic(struct connectdata *conn,
bool *magicdone) bool *magicdone)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
#if defined(CURL_DISABLE_PROXY) #if defined(CURL_DISABLE_PROXY)
(void) newhost; (void) newhost;
@ -1927,7 +1950,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
{ {
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result; CURLcode result;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
struct Curl_dns_entry *addr=NULL; struct Curl_dns_entry *addr=NULL;
int rc; int rc;
unsigned short connectport; /* the local port connect() should use! */ unsigned short connectport; /* the local port connect() should use! */
@ -2102,7 +2125,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
static CURLcode ftp_state_port_resp(struct connectdata *conn, static CURLcode ftp_state_port_resp(struct connectdata *conn,
int ftpcode) int ftpcode)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
ftpport fcmd = (ftpport)ftpc->count1; ftpport fcmd = (ftpport)ftpc->count1;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
@ -2139,7 +2162,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
int ftpcode) int ftpcode)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
@ -2244,7 +2267,7 @@ static CURLcode ftp_state_type_resp(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
if(ftpcode/100 != 2) { if(ftpcode/100 != 2) {
/* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a /* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a
@ -2273,7 +2296,7 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
curl_off_t filesize) curl_off_t filesize)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
@ -2356,7 +2379,7 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
curl_off_t filesize; curl_off_t filesize;
char *buf = data->state.buffer; char *buf = data->state.buffer;
@ -2428,7 +2451,7 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,
int ftpcode, ftpstate instate) int ftpcode, ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
if(ftpcode>=400) { if(ftpcode>=400) {
failf(data, "Failed FTP upload: %0d", ftpcode); failf(data, "Failed FTP upload: %0d", ftpcode);
@ -2467,7 +2490,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
char *buf = data->state.buffer; char *buf = data->state.buffer;
@ -2624,7 +2647,7 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
ftpstate instate) ftpstate instate)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
(void)instate; /* no use for this yet */ (void)instate; /* no use for this yet */
@ -2679,7 +2702,7 @@ static CURLcode ftp_state_acct_resp(struct connectdata *conn,
int ftpcode) int ftpcode)
{ {
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
if(ftpcode != 230) { if(ftpcode != 230) {
failf(data, "ACCT rejected by server: %03d", ftpcode); failf(data, "ACCT rejected by server: %03d", ftpcode);
result = CURLE_FTP_WEIRD_PASS_REPLY; /* FIX */ result = CURLE_FTP_WEIRD_PASS_REPLY; /* FIX */
@ -2695,7 +2718,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
{ {
CURLcode result; CURLcode result;
curl_socket_t sock = conn->sock[FIRSTSOCKET]; curl_socket_t sock = conn->sock[FIRSTSOCKET];
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
int ftpcode; int ftpcode;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
@ -3218,9 +3241,9 @@ static CURLcode ftp_connect(struct connectdata *conn,
* Input argument is already checked for validity. * Input argument is already checked for validity.
*/ */
static CURLcode ftp_done(struct connectdata *conn, CURLcode status, static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
bool premature) bool premature)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp; struct pingpong *pp = &ftpc->pp;
@ -3232,11 +3255,6 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
const char *path_to_use = data->state.path; const char *path_to_use = data->state.path;
if(!ftp) if(!ftp)
/* When the easy handle is removed from the multi while libcurl is still
* trying to resolve the host name, it seems that the ftp struct is not
* yet initialized, but the removal action calls Curl_done() which calls
* this function. So we simply return success if no ftp pointer is set.
*/
return CURLE_OK; return CURLE_OK;
switch(status) { switch(status) {
@ -3345,11 +3363,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
/* Note that we keep "use" set to TRUE since that (next) connection is /* Note that we keep "use" set to TRUE since that (next) connection is
still requested to use SSL */ still requested to use SSL */
} }
if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) { close_secondarysocket(conn);
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
}
} }
if(!result && (ftp->transfer == FTPTRANSFER_BODY) && ftpc->ctl_valid && if(!result && (ftp->transfer == FTPTRANSFER_BODY) && ftpc->ctl_valid &&
@ -3573,7 +3587,7 @@ static CURLcode ftp_range(struct connectdata *conn)
curl_off_t from, to; curl_off_t from, to;
char *ptr; char *ptr;
char *ptr2; char *ptr2;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
if(data->state.use_range && data->state.range) { if(data->state.use_range && data->state.range) {
@ -3631,7 +3645,7 @@ static CURLcode ftp_range(struct connectdata *conn)
static CURLcode ftp_do_more(struct connectdata *conn, int *completep) static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
{ {
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result = CURLE_OK; CURLcode result = CURLE_OK;
bool connected = FALSE; bool connected = FALSE;
@ -3720,7 +3734,13 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
return result; return result;
result = ftp_multi_statemach(conn, &complete); result = ftp_multi_statemach(conn, &complete);
*completep = (int)complete; if(ftpc->wait_data_conn)
/* if we reach the end of the FTP state machine here, *complete will be
TRUE but so is ftpc->wait_data_conn, which says we need to wait for
the data connection and therefore we're not actually complete */
*completep = 0;
else
*completep = (int)complete;
} }
else { else {
/* download */ /* download */
@ -4190,7 +4210,7 @@ static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
(void)ftp_quit(conn); /* ignore errors on the QUIT */ (void)ftp_quit(conn); /* ignore errors on the QUIT */
if(ftpc->entrypath) { if(ftpc->entrypath) {
struct SessionHandle *data = conn->data; struct Curl_easy *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;
} }
@ -4223,7 +4243,7 @@ static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
static static
CURLcode ftp_parse_url_path(struct connectdata *conn) CURLcode ftp_parse_url_path(struct connectdata *conn)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
/* the ftp struct is already inited in ftp_connect() */ /* the ftp struct is already inited in ftp_connect() */
struct FTP *ftp = data->req.protop; struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
@ -4249,16 +4269,17 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
the first condition in the if() right here, is there just in case the first condition in the if() right here, is there just in case
someone decides to set path to NULL one day someone decides to set path to NULL one day
*/ */
if(data->state.path && if(path_to_use[0] &&
data->state.path[0] && (path_to_use[strlen(path_to_use) - 1] != '/') )
(data->state.path[strlen(data->state.path) - 1] != '/') ) filename = path_to_use; /* this is a full file path */
filename = data->state.path; /* this is a full file path */ /*
/* else {
ftpc->file is not used anywhere other than for operations on a file. ftpc->file is not used anywhere other than for operations on a file.
In other words, never for directory operations. In other words, never for directory operations.
So we can safely leave filename as NULL here and use it as a So we can safely leave filename as NULL here and use it as a
argument in dir/file decisions. argument in dir/file decisions.
*/ }
*/
break; break;
case FTPFILE_SINGLECWD: case FTPFILE_SINGLECWD:
@ -4423,11 +4444,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn,
CURLcode result = ftp_do_more(conn, &completed); CURLcode result = ftp_do_more(conn, &completed);
if(result) { if(result) {
if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { close_secondarysocket(conn);
/* close the second socket if it was created already */
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
}
return result; return result;
} }
} }
@ -4478,7 +4495,7 @@ CURLcode ftp_regular_transfer(struct connectdata *conn,
{ {
CURLcode result=CURLE_OK; CURLcode result=CURLE_OK;
bool connected=FALSE; bool connected=FALSE;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc; struct ftp_conn *ftpc = &conn->proto.ftpc;
data->req.size = -1; /* make sure this is unknown at this point */ data->req.size = -1; /* make sure this is unknown at this point */
@ -4512,7 +4529,7 @@ CURLcode ftp_regular_transfer(struct connectdata *conn,
static CURLcode ftp_setup_connection(struct connectdata *conn) static CURLcode ftp_setup_connection(struct connectdata *conn)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
char *type; char *type;
char command; char command;
struct FTP *ftp; struct FTP *ftp;

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -97,9 +97,9 @@ typedef enum {
file */ file */
} curl_ftpfile; } curl_ftpfile;
/* This FTP struct is used in the SessionHandle. All FTP data that is /* This FTP struct is used in the Curl_easy. All FTP data that is
connection-oriented must be in FTP_conn to properly deal with the fact that connection-oriented must be in FTP_conn to properly deal with the fact that
perhaps the SessionHandle is changed between the times the connection is perhaps the Curl_easy is changed between the times the connection is
used. */ used. */
struct FTP { struct FTP {
curl_off_t *bytecountp; curl_off_t *bytecountp;

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -275,26 +275,6 @@ static void PL_ERROR(struct connectdata *conn, CURLcode err)
parser->error = err; parser->error = err;
} }
static bool ftp_pl_gettime(struct ftp_parselist_data *parser, char *string)
{
(void)parser;
(void)string;
/* TODO
* There could be possible parse timestamp from server. Leaving unimplemented
* for now.
* If you want implement this, please add CURLFINFOFLAG_KNOWN_TIME flag to
* parser->file_data->flags
*
* Ftp servers are giving usually these formats:
* Apr 11 1998 (unknown time.. set it to 00:00:00?)
* Apr 11 12:21 (unknown year -> set it to NOW() time?)
* 08-05-09 02:49PM (ms-dos format)
* 20100421092538 -> for MLST/MLSD response
*/
return FALSE;
}
static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
struct curl_fileinfo *finfo) struct curl_fileinfo *finfo)
{ {
@ -715,9 +695,11 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
if(c == ' ') { if(c == ' ') {
finfo->b_data[parser->item_offset + parser->item_length -1] = 0; finfo->b_data[parser->item_offset + parser->item_length -1] = 0;
parser->offsets.time = parser->item_offset; parser->offsets.time = parser->item_offset;
if(ftp_pl_gettime(parser, finfo->b_data + parser->item_offset)) { /*
parser->file_data->flags |= CURLFINFOFLAG_KNOWN_TIME; if(ftp_pl_gettime(parser, finfo->b_data + parser->item_offset)) {
} parser->file_data->flags |= CURLFINFOFLAG_KNOWN_TIME;
}
*/
if(finfo->filetype == CURLFILETYPE_SYMLINK) { if(finfo->filetype == CURLFILETYPE_SYMLINK) {
parser->state.UNIX.main = PL_UNIX_SYMLINK; parser->state.UNIX.main = PL_UNIX_SYMLINK;
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_PRESPACE; parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_PRESPACE;
@ -746,7 +728,6 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
case PL_UNIX_FILENAME_NAME: case PL_UNIX_FILENAME_NAME:
parser->item_length++; parser->item_length++;
if(c == '\r') { if(c == '\r') {
parser->item_length--;
parser->state.UNIX.sub.filename = PL_UNIX_FILENAME_WINDOWSEOL; parser->state.UNIX.sub.filename = PL_UNIX_FILENAME_WINDOWSEOL;
} }
else if(c == '\n') { else if(c == '\n') {
@ -762,7 +743,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
break; break;
case PL_UNIX_FILENAME_WINDOWSEOL: case PL_UNIX_FILENAME_WINDOWSEOL:
if(c == '\n') { if(c == '\n') {
finfo->b_data[parser->item_offset + parser->item_length] = 0; finfo->b_data[parser->item_offset + parser->item_length - 1] = 0;
parser->offsets.filename = parser->item_offset; parser->offsets.filename = parser->item_offset;
parser->state.UNIX.main = PL_UNIX_FILETYPE; parser->state.UNIX.main = PL_UNIX_FILETYPE;
result = ftp_pl_insert_finfo(conn, finfo); result = ftp_pl_insert_finfo(conn, finfo);
@ -853,9 +834,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
} }
break; break;
case PL_UNIX_SYMLINK_TARGET: case PL_UNIX_SYMLINK_TARGET:
parser->item_length ++; parser->item_length++;
if(c == '\r') { if(c == '\r') {
parser->item_length --;
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_WINDOWSEOL; parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_WINDOWSEOL;
} }
else if(c == '\n') { else if(c == '\n') {

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -39,7 +39,7 @@
* This is supposed to be called in the beginning of a perform() session * This is supposed to be called in the beginning of a perform() session
* and should reset all session-info variables * and should reset all session-info variables
*/ */
CURLcode Curl_initinfo(struct SessionHandle *data) CURLcode Curl_initinfo(struct Curl_easy *data)
{ {
struct Progress *pro = &data->progress; struct Progress *pro = &data->progress;
struct PureInfo *info = &data->info; struct PureInfo *info = &data->info;
@ -73,7 +73,7 @@ CURLcode Curl_initinfo(struct SessionHandle *data)
return CURLE_OK; return CURLE_OK;
} }
static CURLcode getinfo_char(struct SessionHandle *data, CURLINFO info, static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
char **param_charp) char **param_charp)
{ {
switch(info) { switch(info) {
@ -113,13 +113,13 @@ static CURLcode getinfo_char(struct SessionHandle *data, CURLINFO info,
break; break;
default: default:
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_UNKNOWN_OPTION;
} }
return CURLE_OK; return CURLE_OK;
} }
static CURLcode getinfo_long(struct SessionHandle *data, CURLINFO info, static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
long *param_longp) long *param_longp)
{ {
curl_socket_t sockfd; curl_socket_t sockfd;
@ -198,15 +198,31 @@ static CURLcode getinfo_long(struct SessionHandle *data, CURLINFO info,
case CURLINFO_RTSP_CSEQ_RECV: case CURLINFO_RTSP_CSEQ_RECV:
*param_longp = data->state.rtsp_CSeq_recv; *param_longp = data->state.rtsp_CSeq_recv;
break; break;
case CURLINFO_HTTP_VERSION:
switch (data->info.httpversion) {
case 10:
*param_longp = CURL_HTTP_VERSION_1_0;
break;
case 11:
*param_longp = CURL_HTTP_VERSION_1_1;
break;
case 20:
*param_longp = CURL_HTTP_VERSION_2_0;
break;
default:
*param_longp = CURL_HTTP_VERSION_NONE;
break;
}
break;
default: default:
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_UNKNOWN_OPTION;
} }
return CURLE_OK; return CURLE_OK;
} }
static CURLcode getinfo_double(struct SessionHandle *data, CURLINFO info, static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
double *param_doublep) double *param_doublep)
{ {
switch(info) { switch(info) {
@ -253,13 +269,13 @@ static CURLcode getinfo_double(struct SessionHandle *data, CURLINFO info,
break; break;
default: default:
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_UNKNOWN_OPTION;
} }
return CURLE_OK; return CURLE_OK;
} }
static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info,
struct curl_slist **param_slistp) struct curl_slist **param_slistp)
{ {
union { union {
@ -281,69 +297,84 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info,
*param_slistp = ptr.to_slist; *param_slistp = ptr.to_slist;
break; break;
case CURLINFO_TLS_SESSION: case CURLINFO_TLS_SESSION:
case CURLINFO_TLS_SSL_PTR:
{ {
struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **) struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **)
param_slistp; param_slistp;
struct curl_tlssessioninfo *tsi = &data->tsi; struct curl_tlssessioninfo *tsi = &data->tsi;
struct connectdata *conn = data->easy_conn; struct connectdata *conn = data->easy_conn;
unsigned int sockindex = 0;
void *internals = NULL;
*tsip = tsi; *tsip = tsi;
tsi->backend = CURLSSLBACKEND_NONE; tsi->backend = Curl_ssl_backend();
tsi->internals = NULL; tsi->internals = NULL;
if(!conn) if(conn && tsi->backend != CURLSSLBACKEND_NONE) {
break; unsigned int i;
for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) {
/* Find the active ("in use") SSL connection, if any */ if(conn->ssl[i].use) {
while((sockindex < sizeof(conn->ssl) / sizeof(conn->ssl[0])) && #if defined(USE_AXTLS)
(!conn->ssl[sockindex].use)) tsi->internals = (void *)conn->ssl[i].ssl;
sockindex++; #elif defined(USE_CYASSL)
tsi->internals = (void *)conn->ssl[i].handle;
if(sockindex == sizeof(conn->ssl) / sizeof(conn->ssl[0])) #elif defined(USE_DARWINSSL)
break; /* no SSL session found */ tsi->internals = (void *)conn->ssl[i].ssl_ctx;
#elif defined(USE_GNUTLS)
/* Return the TLS session information from the relevant backend */ tsi->internals = (void *)conn->ssl[i].session;
#ifdef USE_OPENSSL #elif defined(USE_GSKIT)
internals = conn->ssl[sockindex].ctx; tsi->internals = (void *)conn->ssl[i].handle;
#elif defined(USE_MBEDTLS)
tsi->internals = (void *)&conn->ssl[i].ssl;
#elif defined(USE_NSS)
tsi->internals = (void *)conn->ssl[i].handle;
#elif defined(USE_OPENSSL)
/* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
tsi->internals = ((info == CURLINFO_TLS_SESSION) ?
(void *)conn->ssl[i].ctx :
(void *)conn->ssl[i].handle);
#elif defined(USE_POLARSSL)
tsi->internals = (void *)&conn->ssl[i].ssl;
#elif defined(USE_SCHANNEL)
tsi->internals = (void *)&conn->ssl[i].ctxt->ctxt_handle;
#elif defined(USE_SSL)
#error "SSL backend specific information missing for CURLINFO_TLS_SSL_PTR"
#endif #endif
#ifdef USE_GNUTLS break;
internals = conn->ssl[sockindex].session; }
#endif }
#ifdef USE_NSS
internals = conn->ssl[sockindex].handle;
#endif
#ifdef USE_GSKIT
internals = conn->ssl[sockindex].handle;
#endif
if(internals) {
tsi->backend = Curl_ssl_backend();
tsi->internals = internals;
} }
/* NOTE: For other SSL backends, it is not immediately clear what data
to return from 'struct ssl_connect_data'; thus, for now we keep the
backend as CURLSSLBACKEND_NONE in those cases, which should be
interpreted as "not supported" */
} }
break; break;
default: default:
return CURLE_BAD_FUNCTION_ARGUMENT; return CURLE_UNKNOWN_OPTION;
} }
return CURLE_OK; return CURLE_OK;
} }
CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...) static CURLcode getinfo_socket(struct Curl_easy *data, CURLINFO info,
curl_socket_t *param_socketp)
{
switch(info) {
case CURLINFO_ACTIVESOCKET:
*param_socketp = Curl_getconnectinfo(data, NULL);
break;
default:
return CURLE_UNKNOWN_OPTION;
}
return CURLE_OK;
}
CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
{ {
va_list arg; va_list arg;
long *param_longp = NULL; long *param_longp = NULL;
double *param_doublep = NULL; double *param_doublep = NULL;
char **param_charp = NULL; char **param_charp = NULL;
struct curl_slist **param_slistp = NULL; struct curl_slist **param_slistp = NULL;
curl_socket_t *param_socketp = NULL;
int type; int type;
/* default return code is to error out! */ CURLcode result = CURLE_UNKNOWN_OPTION;
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
if(!data) if(!data)
return result; return result;
@ -372,6 +403,11 @@ CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...)
if(param_slistp) if(param_slistp)
result = getinfo_slist(data, info, param_slistp); result = getinfo_slist(data, info, param_slistp);
break; break;
case CURLINFO_SOCKET:
param_socketp = va_arg(arg, curl_socket_t *);
if(param_socketp)
result = getinfo_socket(data, info, param_socketp);
break;
default: default:
break; break;
} }

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -21,7 +21,7 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
***************************************************************************/ ***************************************************************************/
CURLcode Curl_getinfo(struct SessionHandle *data, CURLINFO info, ...); CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...);
CURLcode Curl_initinfo(struct SessionHandle *data); CURLcode Curl_initinfo(struct Curl_easy *data);
#endif /* HEADER_CURL_GETINFO_H */ #endif /* HEADER_CURL_GETINFO_H */

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -75,7 +75,7 @@ const struct Curl_handler Curl_handler_gopher = {
static CURLcode gopher_do(struct connectdata *conn, bool *done) static CURLcode gopher_do(struct connectdata *conn, bool *done)
{ {
CURLcode result=CURLE_OK; CURLcode result=CURLE_OK;
struct SessionHandle *data=conn->data; struct Curl_easy *data=conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
curl_off_t *bytecount = &data->req.bytecount; curl_off_t *bytecount = &data->req.bytecount;
@ -83,16 +83,18 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
char *sel; char *sel;
char *sel_org = NULL; char *sel_org = NULL;
ssize_t amount, k; ssize_t amount, k;
int len;
*done = TRUE; /* unconditionally */ *done = TRUE; /* unconditionally */
/* Create selector. Degenerate cases: / and /1 => convert to "" */ /* Create selector. Degenerate cases: / and /1 => convert to "" */
if(strlen(path) <= 2) if(strlen(path) <= 2) {
sel = (char *)""; sel = (char *)"";
len = (int)strlen(sel);
}
else { else {
char *newp; char *newp;
size_t j, i; size_t j, i;
int len;
/* Otherwise, drop / and the first character (i.e., item type) ... */ /* Otherwise, drop / and the first character (i.e., item type) ... */
newp = path; newp = path;
@ -113,7 +115,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
/* We use Curl_write instead of Curl_sendf to make sure the entire buffer is /* We use Curl_write instead of Curl_sendf to make sure the entire buffer is
sent, which could be sizeable with long selectors. */ sent, which could be sizeable with long selectors. */
k = curlx_uztosz(strlen(sel)); k = curlx_uztosz(len);
for(;;) { for(;;) {
result = Curl_write(conn, sockfd, sel, k, &amount); result = Curl_write(conn, sockfd, sel, k, &amount);

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -22,9 +22,12 @@
#include "curl_setup.h" #include "curl_setup.h"
#include <curl/curl.h>
#include "hash.h" #include "hash.h"
#include "llist.h" #include "llist.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */ /* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
@ -46,7 +49,12 @@ hash_element_dtor(void *user, void *element)
free(e); free(e);
} }
/* return 1 on error, 0 is fine */ /* Initializes a hash structure.
* Return 1 on error, 0 is fine.
*
* @unittest: 1602
* @unittest: 1603
*/
int int
Curl_hash_init(struct curl_hash *h, Curl_hash_init(struct curl_hash *h,
int slots, int slots,
@ -119,6 +127,8 @@ mk_hash_element(const void *key, size_t key_len, const void *p)
* that data is replaced. * that data is replaced.
* *
* @unittest: 1305 * @unittest: 1305
* @unittest: 1602
* @unittest: 1603
*/ */
void * void *
Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p) Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
@ -155,7 +165,11 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
return NULL; /* failure */ return NULL; /* failure */
} }
/* remove the identified hash entry, returns non-zero on failure */ /* Remove the identified hash entry.
* Returns non-zero on failure.
*
* @unittest: 1603
*/
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len) int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
{ {
struct curl_llist_element *le; struct curl_llist_element *le;
@ -173,6 +187,10 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
return 1; return 1;
} }
/* Retrieves a hash element.
*
* @unittest: 1603
*/
void * void *
Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len) Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
{ {
@ -214,6 +232,10 @@ Curl_hash_apply(curl_hash *h, void *user,
/* Destroys all the entries in the given hash and resets its attributes, /* Destroys all the entries in the given hash and resets its attributes,
* prepping the given hash for [static|dynamic] deallocation. * prepping the given hash for [static|dynamic] deallocation.
*
* @unittest: 1305
* @unittest: 1602
* @unittest: 1603
*/ */
void void
Curl_hash_destroy(struct curl_hash *h) Curl_hash_destroy(struct curl_hash *h)

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -26,8 +26,11 @@
#ifndef CURL_DISABLE_CRYPTO_AUTH #ifndef CURL_DISABLE_CRYPTO_AUTH
#include <curl/curl.h>
#include "curl_hmac.h" #include "curl_hmac.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */ /* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -77,7 +77,7 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
if(CURL_ASYNC_SUCCESS == status) { if(CURL_ASYNC_SUCCESS == status) {
if(ai) { if(ai) {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
if(data->share) if(data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

View File

@ -9,7 +9,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -43,7 +43,7 @@
* "foo.host.com" matches "*.host.com". * "foo.host.com" matches "*.host.com".
* *
* We use the matching rule described in RFC6125, section 6.4.3. * We use the matching rule described in RFC6125, section 6.4.3.
* http://tools.ietf.org/html/rfc6125#section-6.4.3 * https://tools.ietf.org/html/rfc6125#section-6.4.3
* *
* In addition: ignore trailing dots in the host names and wildcards, so that * In addition: ignore trailing dots in the host names and wildcards, so that
* the names are used normalized. This is what the browsers do. * the names are used normalized. This is what the browsers do.

View File

@ -11,7 +11,7 @@
* *
* 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is

View File

@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
* are also available at http://curl.haxx.se/docs/copyright.html. * are also available at https://curl.haxx.se/docs/copyright.html.
* *
* You may opt to use, copy, modify, merge, publish, distribute and/or sell * You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is * copies of the Software, and permit persons to whom the Software is
@ -56,9 +56,9 @@
#include "url.h" #include "url.h"
#include "inet_ntop.h" #include "inet_ntop.h"
#include "warnless.h" #include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h" #include "curl_printf.h"
#include "curl_memory.h" #include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h" #include "memdebug.h"
#if defined(CURLRES_SYNCH) && \ #if defined(CURLRES_SYNCH) && \
@ -254,7 +254,7 @@ hostcache_prune(struct curl_hash *hostcache, long cache_timeout, time_t now)
* Library-wide function for pruning the DNS cache. This function takes and * Library-wide function for pruning the DNS cache. This function takes and
* returns the appropriate locks. * returns the appropriate locks.
*/ */
void Curl_hostcache_prune(struct SessionHandle *data) void Curl_hostcache_prune(struct Curl_easy *data)
{ {
time_t now; time_t now;
@ -293,7 +293,7 @@ fetch_addr(struct connectdata *conn,
char *entry_id = NULL; char *entry_id = NULL;
struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL;
size_t entry_len; size_t entry_len;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->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);
@ -345,7 +345,7 @@ Curl_fetch_addr(struct connectdata *conn,
const char *hostname, const char *hostname,
int port) int port)
{ {
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL;
if(data->share) if(data->share)
@ -353,7 +353,8 @@ Curl_fetch_addr(struct connectdata *conn,
dns = fetch_addr(conn, hostname, port); dns = fetch_addr(conn, hostname, port);
if(dns) dns->inuse++; /* we use it! */ if(dns)
dns->inuse++; /* we use it! */
if(data->share) if(data->share)
Curl_share_unlock(data, CURL_LOCK_DATA_DNS); Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
@ -371,7 +372,7 @@ Curl_fetch_addr(struct connectdata *conn,
* Returns the Curl_dns_entry entry pointer or NULL if the storage failed. * Returns the Curl_dns_entry entry pointer or NULL if the storage failed.
*/ */
struct Curl_dns_entry * struct Curl_dns_entry *
Curl_cache_addr(struct SessionHandle *data, Curl_cache_addr(struct Curl_easy *data,
Curl_addrinfo *addr, Curl_addrinfo *addr,
const char *hostname, const char *hostname,
int port) int port)
@ -446,7 +447,7 @@ int Curl_resolv(struct connectdata *conn,
struct Curl_dns_entry **entry) struct Curl_dns_entry **entry)
{ {
struct Curl_dns_entry *dns = NULL; struct Curl_dns_entry *dns = NULL;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
CURLcode result; CURLcode result;
int rc = CURLRESOLV_ERROR; /* default to failure */ int rc = CURLRESOLV_ERROR; /* default to failure */
@ -581,7 +582,7 @@ int Curl_resolv_timeout(struct connectdata *conn,
#endif /* HAVE_SIGACTION */ #endif /* HAVE_SIGACTION */
volatile long timeout; volatile long timeout;
volatile unsigned int prev_alarm = 0; volatile unsigned int prev_alarm = 0;
struct SessionHandle *data = conn->data; struct Curl_easy *data = conn->data;
#endif /* USE_ALARM_TIMEOUT */ #endif /* USE_ALARM_TIMEOUT */
int rc; int rc;
@ -715,7 +716,7 @@ clean_up:
* *
* May be called with 'data' == NULL for global cache. * May be called with 'data' == NULL for global cache.
*/ */
void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns) void Curl_resolv_unlock(struct Curl_easy *data, struct Curl_dns_entry *dns)
{ {
if(data && data->share) if(data && data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE); Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
@ -757,7 +758,7 @@ int Curl_mk_dnscache(struct curl_hash *hash)
* can be done! * can be done!
*/ */
void Curl_hostcache_clean(struct SessionHandle *data, void Curl_hostcache_clean(struct Curl_easy *data,
struct curl_hash *hash) struct curl_hash *hash)
{ {
if(data && data->share) if(data && data->share)
@ -770,14 +771,14 @@ void Curl_hostcache_clean(struct SessionHandle *data,
} }
CURLcode Curl_loadhostpairs(struct SessionHandle *data) CURLcode Curl_loadhostpairs(struct Curl_easy *data)
{ {
struct curl_slist *hostp; struct curl_slist *hostp;
char hostname[256]; char hostname[256];
char address[256]; char address[256];
int port; int port;
for(hostp = data->change.resolve; hostp; hostp = hostp->next ) { for(hostp = data->change.resolve; hostp; hostp = hostp->next) {
if(!hostp->data) if(!hostp->data)
continue; continue;
if(hostp->data[0] == '-') { if(hostp->data[0] == '-') {

Some files were not shown because too many files have changed in this diff Show More