mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-17 18:34:03 -05:00
WPS: Use a shared error path in http_client_addr()
This simplifies error processing by removing duplicated cleanup steps. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
63fc84acd7
commit
91d5a8e365
@ -146,24 +146,20 @@ struct http_client * http_client_addr(struct sockaddr_in *dst,
|
|||||||
c->cb_ctx = cb_ctx;
|
c->cb_ctx = cb_ctx;
|
||||||
|
|
||||||
c->sd = socket(AF_INET, SOCK_STREAM, 0);
|
c->sd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (c->sd < 0) {
|
if (c->sd < 0)
|
||||||
http_client_free(c);
|
goto fail;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fcntl(c->sd, F_SETFL, O_NONBLOCK) != 0) {
|
if (fcntl(c->sd, F_SETFL, O_NONBLOCK) != 0) {
|
||||||
wpa_printf(MSG_DEBUG, "HTTP: fnctl(O_NONBLOCK) failed: %s",
|
wpa_printf(MSG_DEBUG, "HTTP: fnctl(O_NONBLOCK) failed: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
http_client_free(c);
|
goto fail;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(c->sd, (struct sockaddr *) dst, sizeof(*dst))) {
|
if (connect(c->sd, (struct sockaddr *) dst, sizeof(*dst))) {
|
||||||
if (errno != EINPROGRESS) {
|
if (errno != EINPROGRESS) {
|
||||||
wpa_printf(MSG_DEBUG, "HTTP: Failed to connect: %s",
|
wpa_printf(MSG_DEBUG, "HTTP: Failed to connect: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
http_client_free(c);
|
goto fail;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -173,20 +169,18 @@ struct http_client * http_client_addr(struct sockaddr_in *dst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (eloop_register_sock(c->sd, EVENT_TYPE_WRITE, http_client_tx_ready,
|
if (eloop_register_sock(c->sd, EVENT_TYPE_WRITE, http_client_tx_ready,
|
||||||
c, NULL)) {
|
c, NULL) ||
|
||||||
http_client_free(c);
|
eloop_register_timeout(HTTP_CLIENT_TIMEOUT_SEC, 0,
|
||||||
return NULL;
|
http_client_timeout, c, NULL))
|
||||||
}
|
goto fail;
|
||||||
|
|
||||||
if (eloop_register_timeout(HTTP_CLIENT_TIMEOUT_SEC, 0,
|
|
||||||
http_client_timeout, c, NULL)) {
|
|
||||||
http_client_free(c);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
c->req = req;
|
c->req = req;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
http_client_free(c);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user