diff --git a/src/config.c b/src/config.c index 37c63d8c..2732ee39 100644 --- a/src/config.c +++ b/src/config.c @@ -85,8 +85,6 @@ static int add_site(char *addr_string, int type) site->family = AF_INET; site->type = type; - /* Make site_id start at a non-zero point. - * Perhaps use hash over string or address? */ strncpy(site->addr_string, addr_string, sizeof(site->addr_string)); diff --git a/src/main.c b/src/main.c index c23c1218..c6c09dcd 100644 --- a/src/main.c +++ b/src/main.c @@ -104,16 +104,11 @@ static void client_alloc(void) { int i; - if (!clients) { - clients = malloc(CLIENT_NALLOC * sizeof(struct client)); - pollfds = malloc(CLIENT_NALLOC * sizeof(struct pollfd)); - } else { - clients = realloc(clients, (client_size + CLIENT_NALLOC) * - sizeof(struct client)); - pollfds = realloc(pollfds, (client_size + CLIENT_NALLOC) * - sizeof(struct pollfd)); - } - if (!clients || !pollfds) { + if (!(clients = realloc( + clients, (client_size + CLIENT_NALLOC) * sizeof(*clients)) + ) || !(pollfds = realloc( + pollfds, (client_size + CLIENT_NALLOC) * sizeof(*pollfds)) + )) { log_error("can't alloc for client array"); exit(1); } @@ -306,7 +301,8 @@ static int read_authkey() return -1; } if (booth_conf->authstat.st_mode & (S_IRGRP | S_IROTH)) { - log_error("%s: file can be readable only for the owner", booth_conf->authfile); + log_error("%s: file shall not be readable for anyone but the owner", + booth_conf->authfile); return -1; } fd = open(booth_conf->authfile, O_RDONLY); diff --git a/src/transport.c b/src/transport.c index 07b63473..d9c89513 100644 --- a/src/transport.c +++ b/src/transport.c @@ -509,6 +509,7 @@ int setup_tcp_listener(int test_only) rv = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)); if (rv == -1) { + close(s); log_error("failed to set the SO_REUSEADDR option"); return rv; } @@ -521,12 +522,14 @@ int setup_tcp_listener(int test_only) } if (rv == -1) { + close(s); log_error("failed to bind socket %s", strerror(errno)); return rv; } rv = listen(s, 5); if (rv == -1) { + close(s); log_error("failed to listen on socket %s", strerror(errno)); return rv; }