← Commit list

decd7e157c

Daniel Stenberg
Daniel Stenberg
2025-10-06
ERROR Duration: 387s

Subject

cf-socket: always check Curl_cf_socket_peek() return code

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/cf-socket.h+1 -1
@@ -158,7 +158,7 @@ CURLcode Curl_cf_socket_peek(struct Curl_cfilter *cf,
struct Curl_easy *data,
curl_socket_t *psock,
const struct Curl_sockaddr_ex **paddr,
- struct ip_quadruple *pip);
+ struct ip_quadruple *pip) WARN_UNUSED_RESULT;
extern struct Curl_cftype Curl_cft_tcp;
extern struct Curl_cftype Curl_cft_udp;
lib/vquic/curl_ngtcp2.c+4 -5
@@ -2480,8 +2480,7 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf,
if(result)
return result;
- Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL);
- if(!sockaddr)
+ if(Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL))
return CURLE_QUIC_CONNECT_ERROR;
ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr,
@@ -2633,9 +2632,9 @@ out:
if(result) {
struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
- infof(data, "QUIC connect to %s port %u failed: %s",
- ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
+ if(!Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip))
+ infof(data, "QUIC connect to %s port %u failed: %s",
+ ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
}
#endif
if(!result && ctx->qconn) {
lib/vquic/curl_osslq.c+9 -9
@@ -550,12 +550,12 @@ static CURLcode cf_osslq_ssl_err(struct Curl_cfilter *cf,
int sockerr = SOCKERRNO;
struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
if(sockerr && detail == SSL_ERROR_SYSCALL)
curlx_strerror(sockerr, extramsg, sizeof(extramsg));
- failf(data, "QUIC connect: %s in connection to %s:%d (%s)",
- extramsg[0] ? extramsg : osslq_SSL_ERROR_to_str(detail),
- ctx->peer.dispname, ip.remote_port, ip.remote_ip);
+ if(!Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip))
+ failf(data, "QUIC connect: %s in connection to %s:%d (%s)",
+ extramsg[0] ? extramsg : osslq_SSL_ERROR_to_str(detail),
+ ctx->peer.dispname, ip.remote_port, ip.remote_ip);
}
else {
/* Could be a CERT problem */
@@ -1177,8 +1177,8 @@ static CURLcode cf_osslq_ctx_start(struct Curl_cfilter *cf,
goto out;
result = CURLE_QUIC_CONNECT_ERROR;
- Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &peer_addr, NULL);
- if(!peer_addr)
+ if(Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &peer_addr, NULL) ||
+ !peer_addr)
goto out;
ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
@@ -1857,9 +1857,9 @@ out:
if(result) {
struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
- infof(data, "QUIC connect to %s port %u failed: %s",
- ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
+ if(!Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip))
+ infof(data, "QUIC connect to %s port %u failed: %s",
+ ip.remote_ip, ip.remote_port, curl_easy_strerror(result));
}
#endif
if(!result)
lib/vquic/curl_quiche.c+3 -1
@@ -1303,7 +1303,9 @@ static CURLcode cf_quiche_ctx_open(struct Curl_cfilter *cf,
if(result)
return result;
- Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL);
+ if(Curl_cf_socket_peek(cf->next, data, &ctx->q.sockfd, &sockaddr, NULL))
+ return CURLE_QUIC_CONNECT_ERROR;
+
ctx->q.local_addrlen = sizeof(ctx->q.local_addr);
rv = getsockname(ctx->q.sockfd, (struct sockaddr *)&ctx->q.local_addr,
&ctx->q.local_addrlen);
lib/vquic/vquic.c+9 -9
@@ -428,9 +428,9 @@ static CURLcode recvmmsg_packets(struct Curl_cfilter *cf,
}
if(!cf->connected && SOCKERRNO == SOCKECONNREFUSED) {
struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
- failf(data, "QUIC: connection to %s port %u refused",
- ip.remote_ip, ip.remote_port);
+ if(!Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip))
+ failf(data, "QUIC: connection to %s port %u refused",
+ ip.remote_ip, ip.remote_port);
result = CURLE_COULDNT_CONNECT;
goto out;
}
@@ -521,9 +521,9 @@ static CURLcode recvmsg_packets(struct Curl_cfilter *cf,
}
if(!cf->connected && SOCKERRNO == SOCKECONNREFUSED) {
struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
- failf(data, "QUIC: connection to %s port %u refused",
- ip.remote_ip, ip.remote_port);
+ if(!Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip))
+ failf(data, "QUIC: connection to %s port %u refused",
+ ip.remote_ip, ip.remote_port);
result = CURLE_COULDNT_CONNECT;
goto out;
}
@@ -596,9 +596,9 @@ static CURLcode recvfrom_packets(struct Curl_cfilter *cf,
}
if(!cf->connected && SOCKERRNO == SOCKECONNREFUSED) {
struct ip_quadruple ip;
- Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip);
- failf(data, "QUIC: connection to %s port %u refused",
- ip.remote_ip, ip.remote_port);
+ if(!Curl_cf_socket_peek(cf->next, data, NULL, NULL, &ip))
+ failf(data, "QUIC: connection to %s port %u refused",
+ ip.remote_ip, ip.remote_port);
result = CURLE_COULDNT_CONNECT;
goto out;
}