aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-05-28 08:36:21 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-05-28 09:18:52 +0200
commit7e344ca052a551985ef6819fa60f867d48e95b05 (patch)
tree861f2a8d2a74296c1dddf0dba445f286b679623c /examples
parent18a89c6ec2f5eaace644ff9cd5c663203b10d970 (diff)
downloadlibssh-7e344ca052a551985ef6819fa60f867d48e95b05.tar.gz
libssh-7e344ca052a551985ef6819fa60f867d48e95b05.tar.xz
libssh-7e344ca052a551985ef6819fa60f867d48e95b05.zip
examples: Fix a possible resource leak in sshd_direct-tcpip
CID 1398985 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/sshd_direct-tcpip.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/examples/sshd_direct-tcpip.c b/examples/sshd_direct-tcpip.c
index 23f59a4b..076933f1 100644
--- a/examples/sshd_direct-tcpip.c
+++ b/examples/sshd_direct-tcpip.c
@@ -380,6 +380,7 @@ static int open_tcp_socket(ssh_message msg) {
host = gethostbyname(dest_hostname);
if (host == NULL) {
+ close(forwardsock);
_ssh_log(SSH_LOG_WARNING, "=== open_tcp_socket", "ERROR, no such host: %s", dest_hostname);
return -1;
}
@@ -390,6 +391,7 @@ static int open_tcp_socket(ssh_message msg) {
sin.sin_port = htons(dest_port);
if (connect(forwardsock, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+ close(forwardsock);
_ssh_log(SSH_LOG_WARNING, "=== open_tcp_socket", "ERROR connecting: %s", strerror(errno));
return -1;
}