From 5385450afd61328e7d24b50eeffc2b1571cd9e2f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 16 Jun 2017 11:30:36 +0200 Subject: curl: prevent binary output spewed to terminal ... unless "--output -" is used. Binary detection is done by simply checking for a binary zero in early data. Added test 1425 1426 to verify. Closes #1512 --- src/tool_operate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/tool_operate.c') diff --git a/src/tool_operate.c b/src/tool_operate.c index 6f1525e8b..b80a77118 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -862,6 +862,9 @@ static CURLcode operate_do(struct GlobalConfig *global, set_binmode(stdout); } + /* explicitly passed to stdout means okaying binary gunk */ + config->terminal_binary_ok = (outfile && !strcmp(outfile, "-")); + if(!config->tcp_nodelay) my_setopt(curl, CURLOPT_TCP_NODELAY, 0L); @@ -1764,7 +1767,10 @@ static CURLcode operate_do(struct GlobalConfig *global, } else #endif - if(result && global->showerror) { + if(config->synthetic_error) { + ; + } + 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) -- cgit v1.2.3