1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

http client: Fix overwite of addrlen for connect if binding to iface

The addrlen argument to connect() was overwritten by the
lws_socket_bind() result, which is a port number.
Fixes https://github.com/warmcat/libwebsockets/issues/1817
This commit is contained in:
Christian Thießen 2020-01-10 02:05:15 +01:00 committed by Andy Green
parent 0cf41c06ac
commit 3179323afa

View file

@ -219,7 +219,7 @@ lws_client_connect_2(struct lws *wsi)
struct sockaddr_un sau;
char unix_skt = 0;
#endif
int n, port = 0;
int n, m, port = 0;
const char *cce = "", *iface;
const struct sockaddr *psa;
const char *meth = NULL;
@ -663,10 +663,10 @@ ads_known:
else
iface = lws_hdr_simple_ptr(wsi, _WSI_TOKEN_CLIENT_IFACE);
if (iface) {
n = lws_socket_bind(wsi->vhost, wsi->desc.sockfd, 0,
if (iface && *iface) {
m = lws_socket_bind(wsi->vhost, wsi->desc.sockfd, 0,
iface, wsi->ipv6);
if (n < 0) {
if (m < 0) {
cce = "unable to bind socket";
goto failed;
}