[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] bind: only set bindfd after successful listen
[Thread Prev] | [Thread Next]
- Subject: [PATCH] bind: only set bindfd after successful listen
- From: Jon Simons <jon@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 11 Feb 2014 17:22:08 -0800
- To: libssh@xxxxxxxxxx
Hi, Attached is a patch which ensures that 'bindfd' is not set to a bogus value for an error path in 'ssh_bind_listen'. -Jon
From abe6fb9b48fa0e417207246915efca6830b944b6 Mon Sep 17 00:00:00 2001 From: Jon Simons <jon@xxxxxxxxxxxxx> Date: Mon, 10 Feb 2014 18:20:19 -0800 Subject: [PATCH] bind: only set bindfd after successful listen In 'ssh_bind_listen', move setting of 'sshbind->bindfd' to only happen after the listen call: otherwise 'bindfd' can be set to a bogus descriptor for the case that listen fails. --- src/bind.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bind.c b/src/bind.c index 8d82d0d..adb2bef 100644 --- a/src/bind.c +++ b/src/bind.c @@ -254,7 +254,6 @@ int ssh_bind_listen(ssh_bind sshbind) { sshbind->rsa = NULL; return -1; } - sshbind->bindfd = fd; if (listen(fd, 10) < 0) { ssh_set_error(sshbind, SSH_FATAL, @@ -267,6 +266,8 @@ int ssh_bind_listen(ssh_bind sshbind) { sshbind->rsa = NULL; return -1; } + + sshbind->bindfd = fd; } else { SSH_LOG(SSH_LOG_INFO, "Using app-provided bind socket"); } -- 1.8.4.21.g992c386
Archive administrator: postmaster@lists.cynapses.org