From: florian Date: Thu, 30 Jun 2016 10:17:18 +0000 (+0000) Subject: Prevent NULL deref, pointed out by llvm's scan-build. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e6fdc68cfcad2a388d1e53be8b3e1d2eb5972755;p=openbsd Prevent NULL deref, pointed out by llvm's scan-build. OK jca, millert --- 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");