abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit eef3b654d96dee18bc581d754545028e292926c0
parent e4a6b01fdc29cc6598d097e543f7462d448b06cb
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Tue, 17 Feb 2015 00:02:06 +0100

More error handling fixes

Diffstat:
server.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/server.c b/server.c @@ -40,16 +40,17 @@ static int server_create_socket(const char *name) { socklen_t socklen = offsetof(struct sockaddr_un, sun_path) + strlen(sockaddr.sun_path) + 1; mode_t mode = S_IRUSR|S_IWUSR; if (fchmod(fd, mode) == -1) - goto error; + goto error1; if (bind(fd, (struct sockaddr*)&sockaddr, socklen) == -1) - return -1; + goto error1; if (fchmod(fd, mode) == -1 || chmod(sockaddr.sun_path, mode) == -1) - goto error; + goto error2; if (listen(fd, 5) == -1) - goto error; + goto error2; return fd; -error: +error2: unlink(sockaddr.sun_path); +error1: close(fd); return -1; }