[PATCH] ntpd: improve postponed hostname resolution

Denys Vlasenko vda.linux at googlemail.com
Fri Jan 6 14:06:39 UTC 2017


On Fri, Jan 6, 2017 at 12:13 PM, Natanael Copa <ncopa at alpinelinux.org> wrote:
> Run the namelookup from the main loop so a misspelled first ntp server
> name does not block everything forever.
>
> This fixes the following situation which would block forever:
>   $ sudo ./busybox ntpd -dn -p foobar  -p pool.ntp.org
>   ntpd: bad address 'foobar'
>   ntpd: bad address 'foobar'
>   ntpd: bad address 'foobar'
>   ...

The commit message would be more helpful if it also says
what is the new behavior.

>  typedef struct {
>         len_and_sockaddr *p_lsa;
> +       char             *p_hostname;
>         char             *p_dotted;
>         int              p_fd;
>         int              datapoint_idx;
> @@ -318,7 +320,6 @@ typedef struct {
>         datapoint_t      filter_datapoint[NUM_DATAPOINTS];
>         /* last sent packet: */
>         msg_t            p_xmt_msg;
> -       char             p_hostname[1];
>  } peer_t;
...
> -       p = xzalloc(sizeof(*p) + strlen(s));
> -       strcpy(p->p_hostname, s);
> +       p = xzalloc(sizeof(*p));
> +       p->p_hostname = xstrdup(s);

Why this change?


More information about the busybox mailing list