From: Markus Stenberg Date: Tue, 26 Mar 2013 13:15:25 +0000 (+0200) Subject: Fixed race condition - ra_init may already result in SIGIO, and without signal handle... X-Git-Tag: debian/1.1+git20160131-1~168^2 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=85cdc08d7249ec8f6d2e0b94ea3cd5ff2ee141ad;p=odhcp6c.git Fixed race condition - ra_init may already result in SIGIO, and without signal handler set, code goes boom. --- diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 6451312..88f2ae5 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -139,13 +139,6 @@ int main(_unused int argc, char* const argv[]) if (help || !ifname) return usage(); - if ((urandom_fd = open("/dev/urandom", O_CLOEXEC | O_RDONLY)) < 0 || - init_dhcpv6(ifname, request_pd) || ra_init(ifname) || - script_init(script, ifname)) { - syslog(LOG_ERR, "failed to initialize: %s", strerror(errno)); - return 3; - } - signal(SIGIO, sighandler); signal(SIGHUP, sighandler); signal(SIGINT, sighandler); @@ -154,6 +147,13 @@ int main(_unused int argc, char* const argv[]) signal(SIGUSR1, sighandler); signal(SIGUSR2, sighandler); + if ((urandom_fd = open("/dev/urandom", O_CLOEXEC | O_RDONLY)) < 0 || + init_dhcpv6(ifname, request_pd) || ra_init(ifname) || + script_init(script, ifname)) { + syslog(LOG_ERR, "failed to initialize: %s", strerror(errno)); + return 3; + } + if (daemonize) { openlog("odhcp6c", LOG_PID, LOG_DAEMON); // Disable LOG_PERROR if (daemon(0, 0)) {