summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-02-21 11:05:40 +0100
committerGravatar Nikias Bassen2023-02-21 11:05:40 +0100
commitc797c2af6f4e2e8ae93b68f1c41abab1579563db (patch)
tree8a676b125867be34f2c417b8022afc23e4f8de62
parent9a5e78fe56267d6c721c92055c3ae9702bd25871 (diff)
downloadlibimobiledevice-c797c2af6f4e2e8ae93b68f1c41abab1579563db.tar.gz
libimobiledevice-c797c2af6f4e2e8ae93b68f1c41abab1579563db.tar.bz2
reverse_proxy: Fix use-after-free
-rw-r--r--src/reverse_proxy.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/reverse_proxy.c b/src/reverse_proxy.c
index 3f0a839..3ab1031 100644
--- a/src/reverse_proxy.c
+++ b/src/reverse_proxy.c
@@ -186,10 +186,10 @@ static int _reverse_proxy_handle_proxy_cmd(reverse_proxy_client_t client)
/* else wait for messages and forward them */
int sockfd = socket_connect(host, port);
- free(host);
if (sockfd < 0) {
free(buf);
_reverse_proxy_log(client, "ERROR: Connection to %s:%u failed: %s", host, port, strerror(errno));
+ free(host);
return -1;
}
@@ -259,6 +259,7 @@ static int _reverse_proxy_handle_proxy_cmd(reverse_proxy_client_t client)
}
}
socket_close(sockfd);
+ free(host);
free(buf);
_reverse_proxy_status(client, RP_STATUS_DISCONNECTED, "Disconnected (out: %u / in: %u)", sent_total, recv_total);