this analysis is as correct as thye provided diff, which has been
committed.

* Anirban Sinha <asi...@zeugmasystems.com> [2008-12-05 03:07]:
> Hi:
> 
> I am sort of digging my way through the OpenNTPD codebase for my work. I
> think I find a bug in the code. Please help me to understand the reason
> if this is not a bug.
> 
> In function ntp_main() (ntp.c), we poll() to check if there are any
> events of interest. We do this:
> 
> 1. Check internal fds (PIPE_MAIN)
> 2. Then check PIPE_DNS fds
> 3. Then check PIPE_HOTPLUG fds
> 
> Next, for the server, we check all the fds we are listening on. And then
> finally, for nfs clients, we check the fds for the remote servers. Now,
> there's the issue in this line;
> 
> for (j = 1; nfds > 0 && j < idx_peers; j++) {
> ...
> }
> 
> Shouldn't the index start with 3? That is, shouldn't we do this:
> 
> for (j = 3; nfds > 0 && j < idx_peers; j++)
> 
> since, indices 0,1 and 2 correspond to the three checks I have written
> above which are already done.
> 
> In other words, can we apply the following patch to fix the issue?
> 
> Index: ntpd/ntp.c
> ===================================================================
> --- ntpd.orig/ntp.c
> +++ ntpd/ntp.c
> @@ -344,7 +344,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_c
>                       sensor_hotplugevent(hotplugfd);
>               }
> 
> -             for (j = 1; nfds > 0 && j < idx_peers; j++)
> +             for (j = PFD_MAX; nfds > 0 && j < idx_peers; j++)
>                       if (pfd[j].revents & (POLLIN|POLLERR)) {
>                               nfds--;
>                               if (server_dispatch(pfd[j].fd, conf) ==
> -1)
> 
> 
> 
> Thanks,
> 
> Ani
> 

-- 
Henning Brauer, h...@bsws.de, henn...@openbsd.org
BS Web Services, http://bsws.de
Full-Service ISP - Secure Hosting, Mail and DNS Services
Dedicated Servers, Rootservers, Application Hosting - Hamburg & Amsterdam

Reply via email to