[PATCH] Added support for timezones on dhcp6-client (RFC 4833)

Denys Vlasenko vda.linux at googlemail.com
Mon Jun 26 18:08:09 UTC 2017


On Wed, Jun 21, 2017 at 4:29 PM, tiggersWelt.net (Support)
<support at tiggerswelt.net> wrote:
>  static const char opt_req[] = {
>         (D6_OPT_ORO >> 8), (D6_OPT_ORO & 0xff),
> -       0, 6,
> +       0, 10,
>         (D6_OPT_DNS_SERVERS >> 8), (D6_OPT_DNS_SERVERS & 0xff),
>         (D6_OPT_DOMAIN_LIST >> 8), (D6_OPT_DOMAIN_LIST & 0xff),
> -       (D6_OPT_CLIENT_FQDN >> 8), (D6_OPT_CLIENT_FQDN & 0xff)
> +       (D6_OPT_CLIENT_FQDN >> 8), (D6_OPT_CLIENT_FQDN & 0xff),
> +       (D6_OPT_TZ_POSIX >> 8), (D6_OPT_TZ_POSIX & 0xff),
> +       (D6_OPT_TZ_NAME >> 8), (D6_OPT_TZ_NAME & 0xff)
>  };

Please explain what does this do, and why.

> +               /* RFC 4833 Timezones */
> +               case D6_OPT_TZ_POSIX:
> +                       dlist = xmalloc(option[3] + 3);
> +                       memcpy(dlist, "tz=", 3);
> +                       memcpy(dlist + 3, option + 4, option[3]);
> +                       *new_env() = dlist;

What makes sure there is a terminating NUL byte?
How about this instead:

    *new_env() = xasprintf("tz=%.*s", (int)option[3], (char*)option + 4);


> +                       break;
> +               case D6_OPT_TZ_NAME:
> +                       dlist = xmalloc(option[3] + 8);
> +                       memcpy(dlist, "tz_name=", 8);
> +                       memcpy(dlist + 8, option + 4, option[3]);
> +                       *new_env() = dlist;
> +                       break;
>                 }
>                 len_m4 -= 4 + option[3];
>                 option += 4 + option[3];


Applied with some changes, please try current git.


More information about the busybox mailing list