mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
examples: Fix a possible resource leak in sshd_direct-tcpip
CID 1398985 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user