mirror of
https://github.com/moparisthebest/curl
synced 2024-11-12 04:25:08 -05:00
connect.c: fix multiple possible dereferences of null pointers
In case the first address in the tempaddr array is NULL, the code would previously dereference an unchecked null pointer.
This commit is contained in:
parent
3f74e149f8
commit
7296fc9e7e
@ -545,7 +545,7 @@ static CURLcode trynextip(struct connectdata *conn,
|
|||||||
conn->tempsock[tempindex] = CURL_SOCKET_BAD;
|
conn->tempsock[tempindex] = CURL_SOCKET_BAD;
|
||||||
|
|
||||||
if(sockindex == FIRSTSOCKET) {
|
if(sockindex == FIRSTSOCKET) {
|
||||||
Curl_addrinfo *ai;
|
Curl_addrinfo *ai = NULL;
|
||||||
int family;
|
int family;
|
||||||
|
|
||||||
if(conn->tempaddr[tempindex]) {
|
if(conn->tempaddr[tempindex]) {
|
||||||
@ -553,7 +553,7 @@ static CURLcode trynextip(struct connectdata *conn,
|
|||||||
family = conn->tempaddr[tempindex]->ai_family;
|
family = conn->tempaddr[tempindex]->ai_family;
|
||||||
ai = conn->tempaddr[tempindex]->ai_next;
|
ai = conn->tempaddr[tempindex]->ai_next;
|
||||||
}
|
}
|
||||||
else {
|
else if(conn->tempaddr[0]) {
|
||||||
/* happy eyeballs - try the other protocol family */
|
/* happy eyeballs - try the other protocol family */
|
||||||
int firstfamily = conn->tempaddr[0]->ai_family;
|
int firstfamily = conn->tempaddr[0]->ai_family;
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
@ -811,14 +811,16 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
|||||||
char ipaddress[MAX_IPADR_LEN];
|
char ipaddress[MAX_IPADR_LEN];
|
||||||
data->state.os_errno = error;
|
data->state.os_errno = error;
|
||||||
SET_SOCKERRNO(error);
|
SET_SOCKERRNO(error);
|
||||||
Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN);
|
if(conn->tempaddr[i]) {
|
||||||
infof(data, "connect to %s port %ld failed: %s\n",
|
Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN);
|
||||||
ipaddress, conn->port, Curl_strerror(conn, error));
|
infof(data, "connect to %s port %ld failed: %s\n",
|
||||||
|
ipaddress, conn->port, Curl_strerror(conn, error));
|
||||||
|
|
||||||
conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
|
conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
|
||||||
allow : allow / 2;
|
allow : allow / 2;
|
||||||
|
|
||||||
code = trynextip(conn, sockindex, i);
|
code = trynextip(conn, sockindex, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user