summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2004-10-07 10:12:37 +0000
committerDamien Miller <djm@cvs.openbsd.org>2004-10-07 10:12:37 +0000
commitda0e482bc9f0d1253e4ffe16911313564578c44d (patch)
treef60d16a1b918426701f6b49b6ceac75906d6ff8b /usr.bin
parentf6484dfc8c246297769388162dc737be99e9602a (diff)
don't unlink agent socket when bind() fails, spotted by rich AT rich-paul.net
ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-agent.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 515dcc972ec..18dc1db12d5 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -35,7 +35,7 @@
#include "includes.h"
#include <sys/queue.h>
-RCSID("$OpenBSD: ssh-agent.c,v 1.120 2004/08/11 21:43:05 avsm Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.121 2004/10/07 10:12:36 djm Exp $");
#include <openssl/evp.h>
#include <openssl/md5.h>
@@ -1106,6 +1106,7 @@ main(int ac, char **av)
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
perror("socket");
+ *socket_name = '\0'; /* Don't unlink any existing file */
cleanup_exit(1);
}
memset(&sunaddr, 0, sizeof(sunaddr));
@@ -1113,6 +1114,7 @@ main(int ac, char **av)
strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path));
if (bind(sock, (struct sockaddr *) & sunaddr, sizeof(sunaddr)) < 0) {
perror("bind");
+ *socket_name = '\0'; /* Don't unlink any existing file */
cleanup_exit(1);
}
if (listen(sock, SSH_LISTEN_BACKLOG) < 0) {