summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2016-06-30 10:17:19 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2016-06-30 10:17:19 +0000
commit2ab809fc68984d5e6f02c27e4019c0b51f77f3a8 (patch)
treea1e4ecf219f8888bb3eda8737f4c4ea7849434a0 /usr.sbin
parentd78ce9793c91e47a6f1542949d59d3e5be5e7a74 (diff)
Prevent NULL deref, pointed out by llvm's scan-build.
OK jca, millert
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rtadvd/rtadvd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index 19d914222ed..0c2065bad34 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtadvd.c,v 1.74 2016/06/29 14:19:38 jca Exp $ */
+/* $OpenBSD: rtadvd.c,v 1.75 2016/06/30 10:17:18 florian Exp $ */
/* $KAME: rtadvd.c,v 1.66 2002/05/29 14:18:36 itojun Exp $ */
/*
@@ -154,7 +154,7 @@ main(int argc, char *argv[])
struct pollfd pfd[2];
struct timeval *timeout;
struct passwd *pw;
- int i, ch, npfd;
+ int i, ch, npfd, tmout;
log_init(1); /* log to stderr until daemonized */
@@ -246,16 +246,19 @@ main(int argc, char *argv[])
/* timer expiration check and reset the timer */
timeout = rtadvd_check_timer();
- if (timeout != NULL)
+ if (timeout != NULL) {
+ tmout = timeout->tv_sec * 1000 + timeout->tv_usec /
+ 1000;
log_debug("set timer to %lld.%ld. waiting for "
"inputs or timeout",
(long long)timeout->tv_sec,
timeout->tv_usec);
- else
+ } else {
+ tmout = INFTIM;
log_debug("there's no timer. waiting for inputs");
+ }
- if ((i = poll(pfd, npfd,
- timeout->tv_sec * 1000 + timeout->tv_usec / 1000)) < 0) {
+ if ((i = poll(pfd, npfd, tmout)) < 0) {
/* EINTR would occur upon SIGUSR1 for status dump */
if (errno != EINTR)
log_warn("poll");