summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-01-12 21:19:50 +0000
committerng0 <ng0@n0.is>2019-01-12 21:19:50 +0000
commit947fa3b58d652d0a84bd20bcc45ed21267b3ee52 (patch)
tree173cf355b53bba20ac6622104ab4042cb2858183 /src
parent5b22ac2fcff3090a1acc41647936b8fbc3d57b13 (diff)
parent4258dc02d86e7e4de9f795a1af3a0bc6732d4ab5 (diff)
downloadgnurl-947fa3b58d652d0a84bd20bcc45ed21267b3ee52.tar.gz
gnurl-947fa3b58d652d0a84bd20bcc45ed21267b3ee52.tar.bz2
gnurl-947fa3b58d652d0a84bd20bcc45ed21267b3ee52.zip
Merge tag 'curl-7_63_0'
7.63.0
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.netware22
-rw-r--r--src/curl.rc10
-rw-r--r--src/tool_cb_dbg.c6
-rw-r--r--src/tool_cb_hdr.c2
-rw-r--r--src/tool_cb_prg.c4
-rw-r--r--src/tool_cb_wrt.c38
-rw-r--r--src/tool_cfgable.h4
-rw-r--r--src/tool_dirhie.c4
-rw-r--r--src/tool_doswin.c55
-rw-r--r--src/tool_doswin.h1
-rw-r--r--src/tool_getparam.c56
-rw-r--r--src/tool_main.c27
-rw-r--r--src/tool_operate.c9
-rw-r--r--src/tool_operhlp.c4
-rw-r--r--src/tool_parsecfg.c14
-rw-r--r--src/tool_setopt.c22
-rw-r--r--src/tool_urlglob.c22
-rw-r--r--src/tool_writeout.c12
18 files changed, 204 insertions, 108 deletions
diff --git a/src/Makefile.netware b/src/Makefile.netware
index d8265dba3..64a0222fd 100644
--- a/src/Makefile.netware
+++ b/src/Makefile.netware
@@ -6,7 +6,7 @@
# \___|\___/|_| \_\_____|
#
# Copyright (C) 2004 - 2014, Guenter Knauf
-# Copyright (C) 2001 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 2001 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -49,11 +49,6 @@ ifndef LIBSSH2_PATH
LIBSSH2_PATH = ../../libssh2-1.5.0
endif
-# Edit the path below to point to the base of your axTLS package.
-ifndef AXTLS_PATH
-AXTLS_PATH = ../../axTLS-1.2.7
-endif
-
# Edit the path below to point to the base of your libidn package.
ifndef LIBIDN_PATH
LIBIDN_PATH = ../../libidn-1.18
@@ -239,14 +234,9 @@ WITH_SSH2 = 1
WITH_SSL = 1
WITH_ZLIB = 1
endif
-ifeq ($(findstring -axtls,$(CFG)),-axtls)
-WITH_AXTLS = 1
-WITH_SSL =
-else
ifeq ($(findstring -ssl,$(CFG)),-ssl)
WITH_SSL = 1
endif
-endif
ifeq ($(findstring -zlib,$(CFG)),-zlib)
WITH_ZLIB = 1
endif
@@ -293,16 +283,6 @@ ifdef WITH_SSL
LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/ssl.$(LIBEXT)
LDLIBS += $(OPENSSL_PATH)/out_nw_$(LIBARCH_L)/crypto.$(LIBEXT)
IMPORTS += GetProcessSwitchCount RunningProcess
-else
-ifdef WITH_AXTLS
- # INCLUDES += -I$(AXTLS_PATH)/inc
- ifdef LINK_STATIC
- LDLIBS += $(AXTLS_PATH)/lib/libaxtls.$(LIBEXT)
- else
- MODULES += libaxtls.nlm
- IMPORTS += $(AXTLS_PATH)/lib/libaxtls.imp
- endif
-endif
endif
ifdef WITH_ZLIB
INCLUDES += -I$(ZLIB_PATH)
diff --git a/src/curl.rc b/src/curl.rc
index d47f50635..4dac2ae70 100644
--- a/src/curl.rc
+++ b/src/curl.rc
@@ -22,22 +22,22 @@
#include <winver.h>
#include "tool_version.h"
-LANGUAGE 0x09,0x01
+LANGUAGE 0, 0
#define RC_VERSION CURL_VERSION_MAJOR, CURL_VERSION_MINOR, CURL_VERSION_PATCH, 0
VS_VERSION_INFO VERSIONINFO
FILEVERSION RC_VERSION
PRODUCTVERSION RC_VERSION
- FILEFLAGSMASK 0x3fL
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#if defined(DEBUGBUILD) || defined(_DEBUG)
- FILEFLAGS 1
+ FILEFLAGS VS_FF_DEBUG
#else
- FILEFLAGS 0
+ FILEFLAGS 0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
- FILESUBTYPE 0x0L
+ FILESUBTYPE 0L
BEGIN
BLOCK "StringFileInfo"
diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c
index a3e033977..bb8c2635b 100644
--- a/src/tool_cb_dbg.c
+++ b/src/tool_cb_dbg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -66,8 +66,8 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
}
secs = epoch_offset + tv.tv_sec;
now = localtime(&secs); /* not thread safe but we don't care */
- snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
- now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
+ msnprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
+ now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
}
else
timebuf[0] = 0;
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
index 7a7a836c4..84b0d9c87 100644
--- a/src/tool_cb_hdr.c
+++ b/src/tool_cb_hdr.c
@@ -274,7 +274,7 @@ static char *parse_filename(const char *ptr, size_t len)
char *tdir = curlx_getenv("CURL_TESTDIR");
if(tdir) {
char buffer[512]; /* suitably large */
- snprintf(buffer, sizeof(buffer), "%s/%s", tdir, copy);
+ msnprintf(buffer, sizeof(buffer), "%s/%s", tdir, copy);
Curl_safefree(copy);
copy = strdup(buffer); /* clone the buffer, we don't use the libcurl
aprintf() or similar since we want to use the
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c
index 3eb2c1255..15ff5b2fa 100644
--- a/src/tool_cb_prg.c
+++ b/src/tool_cb_prg.c
@@ -72,7 +72,7 @@ static void fly(struct ProgressData *bar, bool moved)
int pos;
int check = bar->width - 2;
- snprintf(buf, sizeof(buf), "%*s\r", bar->width-1, " ");
+ msnprintf(buf, sizeof(buf), "%*s\r", bar->width-1, " ");
memcpy(&buf[bar->bar], "-=O=-", 5);
pos = sinus[bar->tick%200] / (10000 / check);
@@ -166,7 +166,7 @@ int tool_progress_cb(void *clientp,
num = MAX_BARLENGTH;
memset(line, '#', num);
line[num] = '\0';
- snprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
+ msnprintf(format, sizeof(format), "\r%%-%ds %%5.1f%%%%", barwidth);
fprintf(bar->out, format, line, percent);
}
fflush(bar->out);
diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c
index 476fef9a4..2cb5e1b41 100644
--- a/src/tool_cb_wrt.c
+++ b/src/tool_cb_wrt.c
@@ -156,7 +156,43 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
}
}
- rc = fwrite(buffer, sz, nmemb, outs->stream);
+#ifdef _WIN32
+ if(isatty(fileno(outs->stream))) {
+ DWORD in_len = (DWORD)(sz * nmemb);
+ wchar_t* wc_buf;
+ DWORD wc_len;
+ intptr_t fhnd;
+
+ /* calculate buffer size for wide characters */
+ wc_len = MultiByteToWideChar(CP_UTF8, 0, buffer, in_len, NULL, 0);
+ wc_buf = (wchar_t*) malloc(wc_len * sizeof(wchar_t));
+ if(!wc_buf)
+ return failure;
+
+ /* calculate buffer size for multi-byte characters */
+ wc_len = MultiByteToWideChar(CP_UTF8, 0, buffer, in_len, wc_buf, wc_len);
+ if(!wc_len) {
+ free(wc_buf);
+ return failure;
+ }
+
+ fhnd = _get_osfhandle(fileno(outs->stream));
+
+ if(!WriteConsoleW(
+ (HANDLE) fhnd,
+ wc_buf,
+ wc_len,
+ &wc_len,
+ NULL)) {
+ free(wc_buf);
+ return failure;
+ }
+ free(wc_buf);
+ rc = bytes;
+ }
+ else
+#endif
+ rc = fwrite(buffer, sz, nmemb, outs->stream);
if(bytes == rc)
/* we added this amount of data to the output */
diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h
index b719fa219..501c96189 100644
--- a/src/tool_cfgable.h
+++ b/src/tool_cfgable.h
@@ -69,8 +69,8 @@ struct OperationConfig {
char *headerfile;
char *ftpport;
char *iface;
- int localport;
- int localportrange;
+ long localport;
+ long localportrange;
unsigned short porttouse;
char *range;
long low_speed_limit;
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c
index 24bbc4906..06b3c03e8 100644
--- a/src/tool_dirhie.c
+++ b/src/tool_dirhie.c
@@ -131,13 +131,13 @@ CURLcode create_dir_hierarchy(const char *outfile, FILE *errors)
if(tempdir2 != NULL) {
size_t dlen = strlen(dirbuildup);
if(dlen)
- snprintf(&dirbuildup[dlen], outlen - dlen, "%s%s", DIR_CHAR, tempdir);
+ msnprintf(&dirbuildup[dlen], outlen - dlen, "%s%s", DIR_CHAR, tempdir);
else {
if(outdup == tempdir)
/* the output string doesn't start with a separator */
strcpy(dirbuildup, tempdir);
else
- snprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir);
+ msnprintf(dirbuildup, outlen, "%s%s", DIR_CHAR, tempdir);
}
if((-1 == mkdir(dirbuildup, (mode_t)0000750)) && (errno != EEXIST)) {
show_dir_errno(errors, dirbuildup);
diff --git a/src/tool_doswin.c b/src/tool_doswin.c
index c3a8826ff..f360b92e6 100644
--- a/src/tool_doswin.c
+++ b/src/tool_doswin.c
@@ -28,6 +28,7 @@
#endif
#ifdef WIN32
+# include <tlhelp32.h>
# include "tool_cfgable.h"
# include "tool_libinfo.h"
#endif
@@ -670,6 +671,60 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
return result;
}
+
+/* Get a list of all loaded modules with full paths.
+ * Returns slist on success or NULL on error.
+ */
+struct curl_slist *GetLoadedModulePaths(void)
+{
+ HANDLE hnd = INVALID_HANDLE_VALUE;
+ MODULEENTRY32 mod = {0};
+ struct curl_slist *slist = NULL;
+
+ mod.dwSize = sizeof(MODULEENTRY32);
+
+ do {
+ hnd = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
+ } while(hnd == INVALID_HANDLE_VALUE && GetLastError() == ERROR_BAD_LENGTH);
+
+ if(hnd == INVALID_HANDLE_VALUE)
+ goto error;
+
+ if(!Module32First(hnd, &mod))
+ goto error;
+
+ do {
+ char *path; /* points to stack allocated buffer */
+ struct curl_slist *temp;
+
+#ifdef UNICODE
+ /* sizeof(mod.szExePath) is the max total bytes of wchars. the max total
+ bytes of multibyte chars won't be more than twice that. */
+ char buffer[sizeof(mod.szExePath) * 2];
+ if(!WideCharToMultiByte(CP_ACP, 0, mod.szExePath, -1,
+ buffer, sizeof(buffer), NULL, NULL))
+ goto error;
+ path = buffer;
+#else
+ path = mod.szExePath;
+#endif
+ temp = curl_slist_append(slist, path);
+ if(!temp)
+ goto error;
+ slist = temp;
+ } while(Module32Next(hnd, &mod));
+
+ goto cleanup;
+
+error:
+ curl_slist_free_all(slist);
+ slist = NULL;
+cleanup:
+ if(hnd != INVALID_HANDLE_VALUE)
+ CloseHandle(hnd);
+ return slist;
+}
+
#endif /* WIN32 */
#endif /* MSDOS || WIN32 */
diff --git a/src/tool_doswin.h b/src/tool_doswin.h
index 6398390f1..415fac27e 100644
--- a/src/tool_doswin.h
+++ b/src/tool_doswin.h
@@ -60,6 +60,7 @@ char **__crt0_glob_function(char *arg);
CURLcode FindWin32CACert(struct OperationConfig *config,
curl_sslbackend backend,
const char *bundle_file);
+struct curl_slist *GetLoadedModulePaths(void);
#endif /* WIN32 */
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 58f3f5827..c0d3a84f2 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -935,22 +935,35 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
case 'r': /* --ftp-method (undocumented at this point) */
config->ftp_filemethod = ftpfilemethod(config, nextarg);
break;
- case 's': /* --local-port */
- rc = sscanf(nextarg, "%d - %d",
- &config->localport,
- &config->localportrange);
- if(!rc)
+ case 's': { /* --local-port */
+ char lrange[7]; /* 16bit base 10 is 5 digits, but we allow 6 so that
+ this catches overflows, not just truncates */
+ char *p = nextarg;
+ while(ISDIGIT(*p))
+ p++;
+ if(*p) {
+ /* if there's anything more than a plain decimal number */
+ rc = sscanf(p, " - %6s", lrange);
+ *p = 0; /* zero terminate to make str2unum() work below */
+ }
+ else
+ rc = 0;
+
+ err = str2unum(&config->localport, nextarg);
+ if(err || (config->localport > 65535))
return PARAM_BAD_USE;
- if(rc == 1)
+ if(!rc)
config->localportrange = 1; /* default number of ports to try */
else {
- config->localportrange -= config->localport;
- if(config->localportrange < 1) {
- warnf(global, "bad range input\n");
+ err = str2unum(&config->localportrange, lrange);
+ if(err || (config->localportrange > 65535))
+ return PARAM_BAD_USE;
+ config->localportrange -= (config->localport-1);
+ if(config->localportrange < 1)
return PARAM_BAD_USE;
- }
}
break;
+ }
case 'u': /* --ftp-alternative-to-user */
GetStr(&config->ftp_alternative_to_user, nextarg);
break;
@@ -1338,7 +1351,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
return PARAM_NO_MEM;
}
if(nlen > 0) { /* only append '=' if we have a name */
- snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
+ msnprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
size = outlen-1;
}
else {
@@ -1467,7 +1480,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
GetFileAndPassword(nextarg, &config->cert, &config->key_passwd);
break;
case 'a': /* CA info PEM file */
- /* CA info PEM file */
GetStr(&config->cacert, nextarg);
break;
case 'b': /* cert file type */
@@ -1488,8 +1500,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
if(config->engine && curl_strequal(config->engine, "list"))
return PARAM_ENGINES_REQUESTED;
break;
- case 'g': /* CA info PEM file */
- /* CA cert directory */
+ case 'g': /* CA cert directory */
GetStr(&config->capath, nextarg);
break;
case 'h': /* --pubkey public key file */
@@ -1500,8 +1511,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
return PARAM_BAD_USE;
break;
- case 'j': /* CRL info PEM file */
- /* CRL file */
+ case 'j': /* CRL file */
GetStr(&config->crlfile, nextarg);
break;
case 'k': /* TLS username */
@@ -1535,7 +1545,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
break;
case 'p': /* Pinned public key DER file */
- /* Pinned public key DER file */
GetStr(&config->pinnedpubkey, nextarg);
break;
@@ -1610,8 +1619,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
GetStr(&config->proxy_cipher_list, nextarg);
break;
- case '3': /* CRL info PEM file for proxy */
- /* CRL file */
+ case '3': /* CRL file for proxy */
GetStr(&config->proxy_crlfile, nextarg);
break;
@@ -1625,12 +1633,10 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
break;
case '6': /* CA info PEM file for proxy */
- /* CA info PEM file */
GetStr(&config->proxy_cacert, nextarg);
break;
- case '7': /* CA info PEM file for proxy */
- /* CA cert directory */
+ case '7': /* CA cert directory for proxy */
GetStr(&config->proxy_capath, nextarg);
break;
@@ -1811,8 +1817,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
break;
case 'n':
switch(subletter) {
- case 'o': /* CA info PEM file */
- /* use .netrc or URL */
+ case 'o': /* use .netrc or URL */
config->netrc_opt = toggle;
break;
case 'e': /* netrc-file */
@@ -1930,7 +1935,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
warnf(global,
"A specified range MUST include at least one dash (-). "
"Appending one for you!\n");
- snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
+ msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
Curl_safefree(config->range);
config->range = strdup(buffer);
if(!config->range)
@@ -2061,6 +2066,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
fname = nextarg;
file = fopen(nextarg, FOPEN_READTEXT);
}
+ Curl_safefree(config->writeout);
err = file2string(&config->writeout, file);
if(file && (file != stdin))
fclose(file);
diff --git a/src/tool_main.c b/src/tool_main.c
index 612bfcb6a..c3a81e933 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -38,6 +38,7 @@
#include "tool_cfgable.h"
#include "tool_convert.h"
+#include "tool_doswin.h"
#include "tool_msgs.h"
#include "tool_operate.h"
#include "tool_panykey.h"
@@ -191,7 +192,7 @@ static CURLcode main_init(struct GlobalConfig *config)
return result;
}
-static void free_config_fields(struct GlobalConfig *config)
+static void free_globalconfig(struct GlobalConfig *config)
{
Curl_safefree(config->trace_dump);
@@ -228,7 +229,7 @@ static void main_free(struct GlobalConfig *config)
PR_Cleanup();
}
#endif
- free_config_fields(config);
+ free_globalconfig(config);
/* Free the config structures */
config_free(config->last);
@@ -241,13 +242,12 @@ static void main_free(struct GlobalConfig *config)
static struct TerminalSettings {
HANDLE hStdOut;
DWORD dwOutputMode;
- UINT nCodepage;
} TerminalSettings;
static void configure_terminal(void)
{
/*
- * If we're running Windows, enable VT output & set codepage to UTF-8.
+ * If we're running Windows, enable VT output.
* Note: VT mode flag can be set on any version of Windows, but VT
* processing only performed on Win10 >= Creators Update)
*/
@@ -257,10 +257,7 @@ static void configure_terminal(void)
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
- /* Cache current codepage (will restore on exit) & set codepage to UTF-8 */
memset(&TerminalSettings, 0, sizeof(TerminalSettings));
- TerminalSettings.nCodepage = GetConsoleOutputCP();
- SetConsoleOutputCP(65001);
/* Enable VT output */
TerminalSettings.hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -282,7 +279,6 @@ static void restore_terminal(void)
/* Restore Console output mode and codepage to whatever they were
* when Curl started */
SetConsoleMode(TerminalSettings.hStdOut, TerminalSettings.dwOutputMode);
- SetConsoleOutputCP(TerminalSettings.nCodepage);
#endif
}
@@ -310,6 +306,21 @@ int main(int argc, char *argv[])
/* Initialize the curl library - do not call any libcurl functions before
this point */
result = main_init(&global);
+
+#ifdef WIN32
+ /* Undocumented diagnostic option to list the full paths of all loaded
+ modules, regardless of whether or not initialization succeeded. */
+ if(argc == 2 && !strcmp(argv[1], "--dump-module-paths")) {
+ struct curl_slist *item, *head = GetLoadedModulePaths();
+ for(item = head; item; item = item->next) {
+ printf("%s\n", item->data);
+ }
+ curl_slist_free_all(head);
+ if(!result)
+ main_free(&global);
+ }
+ else
+#endif /* WIN32 */
if(!result) {
/* Start our curl operation */
result = operate(&global, argc, argv);
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 5a72b6a8c..e53a9d867 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -97,7 +97,7 @@ CURLcode curl_easy_perform_ev(CURL *easy);
static bool is_fatal_error(CURLcode code)
{
switch(code) {
- /* TODO: Should CURLE_SSL_CACERT be included as critical error ? */
+ /* TODO: Should CURLE_PEER_FAILED_VERIFICATION be a critical error? */
case CURLE_FAILED_INIT:
case CURLE_OUT_OF_MEMORY:
case CURLE_UNKNOWN_OPTION:
@@ -1371,9 +1371,8 @@ static CURLcode operate_do(struct GlobalConfig *global,
/* curl 7.15.2 */
if(config->localport) {
- my_setopt(curl, CURLOPT_LOCALPORT, (long)config->localport);
- my_setopt_str(curl, CURLOPT_LOCALPORTRANGE,
- (long)config->localportrange);
+ my_setopt(curl, CURLOPT_LOCALPORT, config->localport);
+ my_setopt_str(curl, CURLOPT_LOCALPORTRANGE, config->localportrange);
}
/* curl 7.15.5 */
@@ -1806,7 +1805,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
else if(result && global->showerror) {
fprintf(global->errors, "curl: (%d) %s\n", result, (errorbuffer[0]) ?
errorbuffer : curl_easy_strerror(result));
- if(result == CURLE_SSL_CACERT)
+ if(result == CURLE_PEER_FAILED_VERIFICATION)
fputs(CURL_CA_CERT_ERRORMSG, global->errors);
}
diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c
index 21b5ffe77..c3a826278 100644
--- a/src/tool_operhlp.c
+++ b/src/tool_operhlp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -176,7 +176,7 @@ CURLcode get_url_file_name(char **filename, const char *url)
char *tdir = curlx_getenv("CURL_TESTDIR");
if(tdir) {
char buffer[512]; /* suitably large */
- snprintf(buffer, sizeof(buffer), "%s/%s", tdir, *filename);
+ msnprintf(buffer, sizeof(buffer), "%s/%s", tdir, *filename);
Curl_safefree(*filename);
*filename = strdup(buffer); /* clone the buffer */
curl_free(tdir);
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index e57d76026..e36b06c23 100644
--- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,8 +60,8 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
filename = CURLRC; /* sensible default */
if(home) {
if(strlen(home) < (sizeof(filebuffer) - strlen(CURLRC))) {
- snprintf(filebuffer, sizeof(filebuffer),
- "%s%s%s", home, DIR_CHAR, CURLRC);
+ msnprintf(filebuffer, sizeof(filebuffer),
+ "%s%s%s", home, DIR_CHAR, CURLRC);
#ifdef WIN32
/* Check if the file exists - if not, try CURLRC in the same
@@ -87,11 +87,9 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
/* If we have enough space, build the RC filename */
remaining = sizeof(filebuffer) - strlen(filebuffer);
if(strlen(CURLRC) < remaining - 1) {
- snprintf(lastdirchar, remaining,
- "%s%s", DIR_CHAR, CURLRC);
- /* Don't bother checking if it exists - we do
- * that later
- */
+ msnprintf(lastdirchar, remaining,
+ "%s%s", DIR_CHAR, CURLRC);
+ /* Don't bother checking if it exists - we do that later */
filename = filebuffer;
}
}
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index fb2cb66d3..cd28ad829 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -251,7 +251,7 @@ static char *c_escape(const char *str, size_t len)
e += 2;
}
else if(! isprint(c)) {
- snprintf(e, 5, "\\%03o", (unsigned)c);
+ msnprintf(e, 5, "\\%03o", (unsigned)c);
e += 4;
}
else
@@ -311,8 +311,8 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
char preamble[80]; /* should accommodate any symbol name */
long rest = lval; /* bits not handled yet */
const NameValue *nv = NULL;
- snprintf(preamble, sizeof(preamble),
- "curl_easy_setopt(hnd, %s, ", name);
+ msnprintf(preamble, sizeof(preamble),
+ "curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */
@@ -322,7 +322,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
if(!rest)
break; /* handled them all */
/* replace with all spaces for continuation line */
- snprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
+ msnprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
}
}
/* If any bits have no definition, output an explicit value.
@@ -354,8 +354,8 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
char preamble[80];
unsigned long rest = (unsigned long)lval;
const NameValueUnsigned *nv = NULL;
- snprintf(preamble, sizeof(preamble),
- "curl_easy_setopt(hnd, %s, ", name);
+ msnprintf(preamble, sizeof(preamble),
+ "curl_easy_setopt(hnd, %s, ", name);
for(nv = nvlist; nv->name; nv++) {
if((nv->value & ~ rest) == 0) {
/* all value flags contained in rest */
@@ -365,7 +365,7 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
if(!rest)
break; /* handled them all */
/* replace with all spaces for continuation line */
- snprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
+ msnprintf(preamble, sizeof(preamble), "%*s", strlen(preamble), "");
}
}
/* If any bits have no definition, output an explicit value.
@@ -629,7 +629,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
}
}
- snprintf(buf, sizeof(buf), "%ldL", lval);
+ msnprintf(buf, sizeof(buf), "%ldL", lval);
value = buf;
ret = curl_easy_setopt(curl, tag, lval);
if(lval == defval)
@@ -666,8 +666,8 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *config,
else {
/* Value is expected to be curl_off_t */
curl_off_t oval = va_arg(arg, curl_off_t);
- snprintf(buf, sizeof(buf),
- "(curl_off_t)%" CURL_FORMAT_CURL_OFF_T, oval);
+ msnprintf(buf, sizeof(buf),
+ "(curl_off_t)%" CURL_FORMAT_CURL_OFF_T, oval);
value = buf;
ret = curl_easy_setopt(curl, tag, oval);
diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c
index e4a5c33db..babae0416 100644
--- a/src/tool_urlglob.c
+++ b/src/tool_urlglob.c
@@ -462,9 +462,9 @@ CURLcode glob_url(URLGlob **glob, char *url, unsigned long *urlnum,
char text[512];
const char *t;
if(glob_expand->pos) {
- snprintf(text, sizeof(text), "%s in URL position %zu:\n%s\n%*s^",
- glob_expand->error,
- glob_expand->pos, url, glob_expand->pos - 1, " ");
+ msnprintf(text, sizeof(text), "%s in URL position %zu:\n%s\n%*s^",
+ glob_expand->error,
+ glob_expand->pos, url, glob_expand->pos - 1, " ");
t = text;
}
else
@@ -563,8 +563,8 @@ CURLcode glob_next_url(char **globbed, URLGlob *glob)
switch(pat->type) {
case UPTSet:
if(pat->content.Set.elements) {
- snprintf(buf, buflen, "%s",
- pat->content.Set.elements[pat->content.Set.ptr_s]);
+ msnprintf(buf, buflen, "%s",
+ pat->content.Set.elements[pat->content.Set.ptr_s]);
len = strlen(buf);
buf += len;
buflen -= len;
@@ -578,9 +578,9 @@ CURLcode glob_next_url(char **globbed, URLGlob *glob)
}
break;
case UPTNumRange:
- snprintf(buf, buflen, "%0*lu",
- pat->content.NumRange.padlength,
- pat->content.NumRange.ptr_n);
+ msnprintf(buf, buflen, "%0*lu",
+ pat->content.NumRange.padlength,
+ pat->content.NumRange.ptr_n);
len = strlen(buf);
buf += len;
buflen -= len;
@@ -653,9 +653,9 @@ CURLcode glob_match_url(char **result, char *filename, URLGlob *glob)
appendlen = 1;
break;
case UPTNumRange:
- snprintf(numbuf, sizeof(numbuf), "%0*lu",
- pat->content.NumRange.padlength,
- pat->content.NumRange.ptr_n);
+ msnprintf(numbuf, sizeof(numbuf), "%0*lu",
+ pat->content.NumRange.padlength,
+ pat->content.NumRange.ptr_n);
appendthis = numbuf;
appendlen = strlen(numbuf);
break;
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index ffe47c633..d5b0bc44f 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,6 +60,8 @@ typedef enum {
VAR_LOCAL_PORT,
VAR_HTTP_VERSION,
VAR_SCHEME,
+ VAR_STDOUT,
+ VAR_STDERR,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@@ -101,6 +103,8 @@ static const struct variable replacements[]={
{"local_port", VAR_LOCAL_PORT},
{"http_version", VAR_HTTP_VERSION},
{"scheme", VAR_SCHEME},
+ {"stdout", VAR_STDOUT},
+ {"stderr", VAR_STDERR},
{NULL, VAR_NONE}
};
@@ -321,6 +325,12 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
&stringp))
fprintf(stream, "%s", stringp);
break;
+ case VAR_STDOUT:
+ stream = stdout;
+ break;
+ case VAR_STDERR:
+ stream = stderr;
+ break;
default:
break;
}