1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

failf: remove newline from formatting strings

... as failf adds one itself.

Also: add an assert() to failf() that triggers on a newline in the
format string!

Closes #6365
This commit is contained in:
Daniel Stenberg 2020-12-23 23:41:13 +01:00
parent 78617b48e4
commit aba01da639
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
24 changed files with 57 additions and 56 deletions

View File

@ -711,7 +711,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
return NULL;
}
failf(conn->data, "getaddrinfo() thread failed\n");
failf(conn->data, "getaddrinfo() thread failed");
return NULL;
}
@ -766,7 +766,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
return NULL;
}
failf(data, "getaddrinfo() thread failed to start\n");
failf(data, "getaddrinfo() thread failed to start");
return NULL;
}

View File

@ -340,7 +340,7 @@ static CURLcode hyperstream(struct Curl_easy *data,
h->init = TRUE;
*didwhat = KEEP_RECV;
if(!resp) {
failf(data, "hyperstream: couldn't get response\n");
failf(data, "hyperstream: couldn't get response");
return CURLE_RECV_ERROR;
}
@ -356,7 +356,7 @@ static CURLcode hyperstream(struct Curl_easy *data,
headers = hyper_response_headers(resp);
if(!headers) {
failf(data, "hyperstream: couldn't get response headers\n");
failf(data, "hyperstream: couldn't get response headers");
result = CURLE_RECV_ERROR;
break;
}
@ -369,20 +369,20 @@ static CURLcode hyperstream(struct Curl_easy *data,
}
if(empty_header(data)) {
failf(data, "hyperstream: couldn't pass blank header\n");
failf(data, "hyperstream: couldn't pass blank header");
result = CURLE_OUT_OF_MEMORY;
break;
}
resp_body = hyper_response_body(resp);
if(!resp_body) {
failf(data, "hyperstream: couldn't get response body\n");
failf(data, "hyperstream: couldn't get response body");
result = CURLE_RECV_ERROR;
break;
}
foreach = hyper_body_foreach(resp_body, hyper_body_chunk, data);
if(!foreach) {
failf(data, "hyperstream: body foreach failed\n");
failf(data, "hyperstream: body foreach failed");
result = CURLE_OUT_OF_MEMORY;
break;
}
@ -467,7 +467,7 @@ CURLcode Curl_hyper_header(struct Curl_easy *data, hyper_headers *headers,
if(HYPERE_OK != hyper_headers_add(headers, (uint8_t *)n, nlen,
(uint8_t *)v, vlen)) {
failf(data, "hyper_headers_add host\n");
failf(data, "hyper_headers_add host");
return CURLE_OUT_OF_MEMORY;
}
if(data->set.verbose) {
@ -505,7 +505,7 @@ static CURLcode request_target(struct Curl_easy *data,
if(hyper_request_set_uri(req, (uint8_t *)Curl_dyn_uptr(&r),
Curl_dyn_len(&r))) {
failf(data, "error setting path\n");
failf(data, "error setting path");
result = CURLE_OUT_OF_MEMORY;
}
else
@ -758,7 +758,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
headers = hyper_request_headers(req);
if(!headers) {
failf(data, "hyper_request_headers\n");
failf(data, "hyper_request_headers");
goto error;
}
@ -829,7 +829,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
data->req.upload_chunky = FALSE;
sendtask = hyper_clientconn_send(client, req);
if(!sendtask) {
failf(data, "hyper_clientconn_send\n");
failf(data, "hyper_clientconn_send");
goto error;
}

View File

@ -225,7 +225,7 @@ static CURLcode dohprobe(struct Curl_easy *data,
DOHcode d = doh_encode(host, dnstype, p->dohbuffer, sizeof(p->dohbuffer),
&p->dohlen);
if(d) {
failf(data, "Failed to encode DOH packet [%d]\n", d);
failf(data, "Failed to encode DOH packet [%d]", d);
return CURLE_OUT_OF_MEMORY;
}

View File

@ -1768,7 +1768,7 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn)
#endif
) {
/* We can't disable EPSV when doing IPv6, so this is instead a fail */
failf(conn->data, "Failed EPSV attempt, exiting\n");
failf(conn->data, "Failed EPSV attempt, exiting");
return CURLE_WEIRD_SERVER_REPLY;
}

View File

@ -3743,7 +3743,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
k->badheader = HEADER_ALLBAD;
streamclose(conn, "bad HTTP: No end-of-message indicator");
if(!data->set.http09_allowed) {
failf(data, "Received HTTP/0.9 when not allowed\n");
failf(data, "Received HTTP/0.9 when not allowed");
return CURLE_UNSUPPORTED_PROTOCOL;
}
break;
@ -3778,7 +3778,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
streamclose(conn, "bad HTTP: No end-of-message indicator");
/* this is not the beginning of a protocol first header line */
if(!data->set.http09_allowed) {
failf(data, "Received HTTP/0.9 when not allowed\n");
failf(data, "Received HTTP/0.9 when not allowed");
return CURLE_UNSUPPORTED_PROTOCOL;
}
k->header = FALSE;

View File

@ -542,7 +542,7 @@ static int push_promise(struct Curl_easy *data,
stream = data->req.p.http;
if(!stream) {
failf(data, "Internal NULL stream!\n");
failf(data, "Internal NULL stream!");
(void)Curl_close(&newhandle);
rv = CURL_PUSH_DENY;
goto fail;
@ -957,7 +957,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
stream = data_s->req.p.http;
if(!stream) {
failf(data_s, "Internal NULL stream! 5\n");
failf(data_s, "Internal NULL stream!");
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
@ -1341,7 +1341,7 @@ static int h2_process_pending_input(struct connectdata *conn,
if(rv < 0) {
failf(data,
"h2_process_pending_input: nghttp2_session_mem_recv() returned "
"%zd:%s\n", rv, nghttp2_strerror((int)rv));
"%zd:%s", rv, nghttp2_strerror((int)rv));
*err = CURLE_RECV_ERROR;
return -1;
}

View File

@ -769,7 +769,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
/* Check we know the size of the upload */
if(data->state.infilesize < 0) {
failf(data, "Cannot APPEND with unknown input file size\n");
failf(data, "Cannot APPEND with unknown input file size");
return CURLE_UPLOAD_FAILED;
}

View File

@ -267,6 +267,7 @@ void Curl_infof(struct Curl_easy *data, const char *fmt, ...)
void Curl_failf(struct Curl_easy *data, const char *fmt, ...)
{
DEBUGASSERT(!strchr(fmt, '\n'));
if(data->set.verbose || data->set.errorbuffer) {
va_list ap;
size_t len;

View File

@ -298,7 +298,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
}
else {
hp = NULL; /* fail! */
failf(data, "SOCKS4 connection to %s not supported\n", buf);
failf(data, "SOCKS4 connection to %s not supported", buf);
}
Curl_resolv_unlock(data, dns); /* not used anymore from now on */
@ -319,7 +319,7 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
if(proxy_user) {
size_t plen = strlen(proxy_user);
if(plen >= sizeof(sx->socksreq) - 8) {
failf(data, "Too long SOCKS proxy user name, can't use!\n");
failf(data, "Too long SOCKS proxy user name, can't use!");
return CURLPX_LONG_USER;
}
/* copy the proxy name WITH trailing zero */
@ -839,7 +839,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
#endif
else {
hp = NULL; /* fail! */
failf(data, "SOCKS5 connection to %s not supported\n", dest);
failf(data, "SOCKS5 connection to %s not supported", dest);
}
Curl_resolv_unlock(data, dns); /* not used anymore from now on */

View File

@ -92,7 +92,7 @@ static int check_gss_err(struct Curl_easy *data,
}
gss_release_buffer(&min_stat, &status_string);
}
failf(data, "GSS-API error: %s failed:\n%s", function, buf);
failf(data, "GSS-API error: %s failed: %s", function, buf);
return 1;
}

View File

@ -493,7 +493,7 @@ static CURLcode tftp_send_first(struct tftp_state_data *state,
return result;
if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
failf(data, "TFTP file name too long\n");
failf(data, "TFTP file name too long");
free(filename);
return CURLE_TFTP_ILLEGAL; /* too long file name field */
}

View File

@ -1550,7 +1550,7 @@ CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
host->name = host->encalloc;
}
else {
failf(data, "Failed to convert %s to ACE; %s\n", host->name,
failf(data, "Failed to convert %s to ACE; %s", host->name,
idn2_strerror(rc));
return CURLE_URL_MALFORMAT;
}
@ -1565,7 +1565,7 @@ CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
}
else {
char buffer[STRERROR_LEN];
failf(data, "Failed to convert %s to ACE; %s\n", host->name,
failf(data, "Failed to convert %s to ACE; %s", host->name,
Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
return CURLE_URL_MALFORMAT;
}

View File

@ -135,7 +135,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
if(status != SEC_E_OK) {
free(input_token);
failf(data, "SSPI: couldn't get auth info\n");
failf(data, "SSPI: couldn't get auth info");
return CURLE_AUTH_ERROR;
}
@ -439,7 +439,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_DIGEST),
&SecurityPackage);
if(status != SEC_E_OK) {
failf(data, "SSPI: couldn't get auth info\n");
failf(data, "SSPI: couldn't get auth info");
return CURLE_AUTH_ERROR;
}

View File

@ -125,7 +125,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
TEXT(SP_NAME_KERBEROS),
&SecurityPackage);
if(status != SEC_E_OK) {
failf(data, "SSPI: couldn't get auth info\n");
failf(data, "SSPI: couldn't get auth info");
return CURLE_AUTH_ERROR;
}

View File

@ -106,7 +106,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_NTLM),
&SecurityPackage);
if(status != SEC_E_OK) {
failf(data, "SSPI: couldn't get auth info\n");
failf(data, "SSPI: couldn't get auth info");
return CURLE_AUTH_ERROR;
}

View File

@ -130,7 +130,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
TEXT(SP_NAME_NEGOTIATE),
&SecurityPackage);
if(nego->status != SEC_E_OK) {
failf(data, "SSPI: couldn't get auth info\n");
failf(data, "SSPI: couldn't get auth info");
return CURLE_AUTH_ERROR;
}

View File

@ -587,7 +587,7 @@ static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags,
nconsumed =
nghttp3_conn_read_stream(qs->h3conn, stream_id, buf, buflen, fin);
if(nconsumed < 0) {
failf(qs->conn->data, "nghttp3_conn_read_stream returned error: %s\n",
failf(qs->conn->data, "nghttp3_conn_read_stream returned error: %s",
nghttp3_strerror((int)nconsumed));
return NGTCP2_ERR_CALLBACK_FAILURE;
}
@ -616,7 +616,7 @@ cb_acked_stream_data_offset(ngtcp2_conn *tconn, int64_t stream_id,
rv = nghttp3_conn_add_ack_offset(qs->h3conn, stream_id, datalen);
if(rv != 0) {
failf(qs->conn->data, "nghttp3_conn_add_ack_offset returned error: %s\n",
failf(qs->conn->data, "nghttp3_conn_add_ack_offset returned error: %s",
nghttp3_strerror(rv));
return NGTCP2_ERR_CALLBACK_FAILURE;
}
@ -637,7 +637,7 @@ static int cb_stream_close(ngtcp2_conn *tconn, int64_t stream_id,
rv = nghttp3_conn_close_stream(qs->h3conn, stream_id,
app_error_code);
if(rv != 0) {
failf(qs->conn->data, "nghttp3_conn_close_stream returned error: %s\n",
failf(qs->conn->data, "nghttp3_conn_close_stream returned error: %s",
nghttp3_strerror(rv));
return NGTCP2_ERR_CALLBACK_FAILURE;
}
@ -658,7 +658,7 @@ static int cb_stream_reset(ngtcp2_conn *tconn, int64_t stream_id,
rv = nghttp3_conn_reset_stream(qs->h3conn, stream_id);
if(rv != 0) {
failf(qs->conn->data, "nghttp3_conn_reset_stream returned error: %s\n",
failf(qs->conn->data, "nghttp3_conn_reset_stream returned error: %s",
nghttp3_strerror(rv));
return NGTCP2_ERR_CALLBACK_FAILURE;
}
@ -689,7 +689,7 @@ static int cb_extend_max_stream_data(ngtcp2_conn *tconn, int64_t stream_id,
rv = nghttp3_conn_unblock_stream(qs->h3conn, stream_id);
if(rv != 0) {
failf(qs->conn->data, "nghttp3_conn_unblock_stream returned error: %s\n",
failf(qs->conn->data, "nghttp3_conn_unblock_stream returned error: %s",
nghttp3_strerror(rv));
return NGTCP2_ERR_CALLBACK_FAILURE;
}
@ -1783,7 +1783,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
rv = ngtcp2_conn_handle_expiry(qs->qconn, ts);
if(rv != 0) {
failf(conn->data, "ngtcp2_conn_handle_expiry returned error: %s\n",
failf(conn->data, "ngtcp2_conn_handle_expiry returned error: %s",
ngtcp2_strerror(rv));
return CURLE_SEND_ERROR;
}
@ -1796,7 +1796,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
veccnt = nghttp3_conn_writev_stream(qs->h3conn, &stream_id, &fin, vec,
sizeof(vec) / sizeof(vec[0]));
if(veccnt < 0) {
failf(conn->data, "nghttp3_conn_writev_stream returned error: %s\n",
failf(conn->data, "nghttp3_conn_writev_stream returned error: %s",
nghttp3_strerror((int)veccnt));
return CURLE_SEND_ERROR;
}
@ -1838,7 +1838,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
}
else {
assert(ndatalen == -1);
failf(conn->data, "ngtcp2_conn_writev_stream returned error: %s\n",
failf(conn->data, "ngtcp2_conn_writev_stream returned error: %s",
ngtcp2_strerror((int)outlen));
return CURLE_SEND_ERROR;
}
@ -1852,7 +1852,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
outlen = ngtcp2_conn_write_pkt(qs->qconn, &ps.path, NULL,
out, pktlen, ts);
if(outlen < 0) {
failf(conn->data, "ngtcp2_conn_write_pkt returned error: %s\n",
failf(conn->data, "ngtcp2_conn_write_pkt returned error: %s",
ngtcp2_strerror((int)outlen));
return CURLE_SEND_ERROR;
}
@ -1871,7 +1871,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
break;
}
else {
failf(conn->data, "send() returned %zd (errno %d)\n", sent,
failf(conn->data, "send() returned %zd (errno %d)", sent,
SOCKERRNO);
return CURLE_SEND_ERROR;
}

View File

@ -399,14 +399,14 @@ static CURLcode flush_egress(struct connectdata *conn, int sockfd,
break;
if(sent < 0) {
failf(conn->data, "quiche_conn_send returned %zd\n",
failf(conn->data, "quiche_conn_send returned %zd",
sent);
return CURLE_SEND_ERROR;
}
sent = send(sockfd, out, sent, 0);
if(sent < 0) {
failf(conn->data, "send() returned %zd\n", sent);
failf(conn->data, "send() returned %zd", sent);
return CURLE_SEND_ERROR;
}
} while(1);

View File

@ -763,10 +763,10 @@ static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn)
hostkey_method = hostkey_method_ssh_dss;
break;
case LIBSSH2_KNOWNHOST_KEY_RSA1:
failf(data, "Found host key type RSA1 which is not supported\n");
failf(data, "Found host key type RSA1 which is not supported");
return CURLE_SSH;
default:
failf(data, "Unknown host key type: %i\n",
failf(data, "Unknown host key type: %i",
(store->typemask & LIBSSH2_KNOWNHOST_KEY_MASK));
return CURLE_SSH;
}

View File

@ -262,7 +262,7 @@ static ssize_t wsftp_send(struct connectdata *conn, int sockindex,
return -1;
}
if(rc < 0) {
failf(conn->data, "wolfSSH_SFTP_SendWritePacket returned %d\n", rc);
failf(conn->data, "wolfSSH_SFTP_SendWritePacket returned %d", rc);
return -1;
}
DEBUGASSERT(rc == (int)len);
@ -307,7 +307,7 @@ static ssize_t wsftp_recv(struct connectdata *conn, int sockindex,
DEBUGASSERT(rc <= (int)len);
if(rc < 0) {
failf(conn->data, "wolfSSH_SFTP_SendReadPacket returned %d\n", rc);
failf(conn->data, "wolfSSH_SFTP_SendReadPacket returned %d", rc);
return -1;
}
sshc->offset += len;

View File

@ -349,8 +349,8 @@ static CURLcode bearssl_connect_step1(struct connectdata *conn, int sockindex)
ret = load_cafile(ssl_cafile, &backend->anchors, &backend->anchors_len);
if(ret != CURLE_OK) {
if(verifypeer) {
failf(data, "error setting certificate verify locations:\n"
" CAfile: %s\n", ssl_cafile);
failf(data, "error setting certificate verify locations."
" CAfile: %s", ssl_cafile);
return ret;
}
infof(data, "error setting certificate verify locations,"

View File

@ -280,7 +280,7 @@ mbed_connect_step1(struct connectdata *conn,
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* MBEDTLS_ERROR_C */
failf(data, "Failed - mbedTLS: ctr_drbg_init returned (-0x%04X) %s\n",
failf(data, "Failed - mbedTLS: ctr_drbg_init returned (-0x%04X) %s",
-ret, errorbuf);
}
#else
@ -293,7 +293,7 @@ mbed_connect_step1(struct connectdata *conn,
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* MBEDTLS_ERROR_C */
failf(data, "Failed - mbedTLS: ctr_drbg_init returned (-0x%04X) %s\n",
failf(data, "Failed - mbedTLS: ctr_drbg_init returned (-0x%04X) %s",
-ret, errorbuf);
}
#endif /* THREADING_SUPPORT */
@ -868,7 +868,7 @@ static CURLcode Curl_mbedtls_random(struct Curl_easy *data,
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* MBEDTLS_ERROR_C */
failf(data, "Failed - mbedTLS: ctr_drbg_seed returned (-0x%04X) %s\n",
failf(data, "Failed - mbedTLS: ctr_drbg_seed returned (-0x%04X) %s",
-ret, errorbuf);
}
else {
@ -878,7 +878,7 @@ static CURLcode Curl_mbedtls_random(struct Curl_easy *data,
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* MBEDTLS_ERROR_C */
failf(data, "mbedTLS: ctr_drbg_init returned (-0x%04X) %s\n",
failf(data, "mbedTLS: ctr_drbg_init returned (-0x%04X) %s",
-ret, errorbuf);
}
}

View File

@ -1289,7 +1289,7 @@ static CURLcode Curl_ossl_set_engine(struct Curl_easy *data,
char buf[256];
ENGINE_free(e);
failf(data, "Failed to initialise SSL Engine '%s':\n%s",
failf(data, "Failed to initialise SSL Engine '%s': %s",
engine, ossl_strerror(ERR_get_error(), buf, sizeof(buf)));
return CURLE_SSL_ENGINE_INITFAILED;
}

View File

@ -608,7 +608,7 @@ wolfssl_connect_step2(struct connectdata *conn,
* as also mismatching CN fields */
else if(DOMAIN_NAME_MISMATCH == detail) {
#if 1
failf(data, "\tsubject alt name(s) or common name do not match \"%s\"\n",
failf(data, "\tsubject alt name(s) or common name do not match \"%s\"",
dispname);
return CURLE_PEER_FAILED_VERIFICATION;
#else
@ -635,7 +635,7 @@ wolfssl_connect_step2(struct connectdata *conn,
#if LIBWOLFSSL_VERSION_HEX >= 0x02007000 /* 2.7.0 */
else if(ASN_NO_SIGNER_E == detail) {
if(SSL_CONN_CONFIG(verifypeer)) {
failf(data, "\tCA signer not available for verification\n");
failf(data, "\tCA signer not available for verification");
return CURLE_SSL_CACERT_BADFILE;
}
else {