Florian Obser <[email protected]> writes:

> rtadvd_check_timer() might return NULL if no timers need to run.
> I'm not 100% sure if it can happen in practice though, but still...

You can trigger it easily by running rtadvd on a single interface and
putting that interface down.

set timer to 4.979495. waiting for inputs or timeout
received a routing message (type = 14, len = 160)
interface msk0 becomes down. stop timer.
there's no timer. waiting for inputs
Segmentation fault


> Pointed out by llvm's scan-build.
> OK?

ok jca@

Note, however, that the next diff I plan to send will remove poll and
timer.[ch]

> diff --git rtadvd.c rtadvd.c
> index 0152045..1af402b 100644
> --- rtadvd.c
> +++ rtadvd.c
> @@ -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 */
>  
> @@ -247,16 +247,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");

-- 
jca | PGP: 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to