summaryrefslogtreecommitdiffstats
path: root/sysdep/unix/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r--sysdep/unix/io.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index c7527c9..e9d78b6 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1140,7 +1140,7 @@ bad_no_log:
return -1;
}
-int
+void
sk_open_unix(sock *s, char *name)
{
int fd;
@@ -1149,15 +1149,13 @@ sk_open_unix(sock *s, char *name)
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
- die("sk_open_unix: socket: %m");
+ ERR("socket");
s->fd = fd;
if (err = sk_setup(s))
goto bad;
unlink(name);
-
- if (strlen(name) >= sizeof(sa.sun_path))
- die("sk_open_unix: path too long");
+ /* Path length checked in test_old_bird() */
sa.sun_family = AF_UNIX;
strcpy(sa.sun_path, name);
if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0)
@@ -1165,13 +1163,11 @@ sk_open_unix(sock *s, char *name)
if (listen(fd, 8))
ERR("listen");
sk_insert(s);
- return 0;
+ return;
-bad:
+ bad:
log(L_ERR "sk_open_unix: %s: %m", err);
- close(fd);
- s->fd = -1;
- return -1;
+ die("Unable to create control socket %s", name);
}
static inline void reset_tx_buffer(sock *s) { s->ttx = s->tpos = s->tbuf; }
@@ -1628,9 +1624,10 @@ test_old_bird(char *path)
struct sockaddr_un sa;
fd = socket(AF_UNIX, SOCK_STREAM, 0);
-
if (fd < 0)
die("Cannot create socket: %m");
+ if (strlen(path) >= sizeof(sa.sun_path))
+ die("Socket path too long");
bzero(&sa, sizeof(sa));
sa.sun_family = AF_UNIX;
strcpy(sa.sun_path, path);