From: Roy Marples Date: Fri, 6 Dec 2013 19:15:06 +0000 (+0000) Subject: Fix vendor options a litle X-Git-Tag: v6.2.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f132acc347fcdc90211ff6464e57f9b15e11c56f;p=thirdparty%2Fdhcpcd.git Fix vendor options a litle --- diff --git a/dhcp-common.c b/dhcp-common.c index 96b8a741..7e69a2b6 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -643,11 +643,11 @@ dhcp_envoption(char **env, const char *prefix, if (oopt == NULL) /* Report error? */ continue; - eopt = oopt; } n += dhcp_envoption( env == NULL ? NULL : &env[n], pfx, - ifname, eopt, + ifname, + eopt->type & OPTION ? oopt : eopt, dgetopt, eod, eol); break; } diff --git a/dhcp.c b/dhcp.c index 1c87a9f5..cdc989a3 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1159,21 +1159,23 @@ dhcp_env(char **env, const char *prefix, const struct dhcp_message *dhcp, continue; if (dhcp_getoverride(ifo, opt->option)) continue; - if ((p = get_option(dhcp, opt->option, &pl))) + if ((p = get_option(dhcp, opt->option, &pl))) { ep += dhcp_envoption(ep, prefix, ifp->name, opt, dhcp_getoption, p, pl); - /* Grab the Vendor-Identifying Vendor Options, RFC 3925 */ - if (opt->option == DHO_VIVSO && pl > (int)sizeof(uint32_t)) { - memcpy(&en, p, sizeof(en)); - en = ntohl(en); - vo = vivso_find(en, ifp); - if (vo) { - /* Skip over en + total size */ - p += sizeof(en) + 1; - pl -= sizeof(en) + 1; - ep += dhcp_envoption(ep, prefix, ifp->name, - vo, dhcp_getoption, p, pl); - printf ("%p\n", ep); + if (opt->option == DHO_VIVSO && + pl > (int)sizeof(uint32_t)) + { + memcpy(&en, p, sizeof(en)); + en = ntohl(en); + vo = vivso_find(en, ifp); + if (vo) { + /* Skip over en + total size */ + p += sizeof(en) + 1; + pl -= sizeof(en) + 1; + ep += dhcp_envoption(ep, prefix, + ifp->name, + vo, dhcp_getoption, p, pl); + } } } } diff --git a/if-options.c b/if-options.c index bd596e25..fc468ddf 100644 --- a/if-options.c +++ b/if-options.c @@ -1404,19 +1404,22 @@ parse_option(struct if_options *ifo, int opt, const char *arg) return -1; } } - ndop = NULL; if (opt != O_EMBED) { - for (dl = 0; dl < *dop_len; dl++) { - ndop = &(*dop)[dl]; + for (dl = 0, ndop = *dop; dl < *dop_len; dl++, ndop++) + { /* type 0 seems freshly malloced struct * for us to use */ if (ndop->option == u || ndop->type == 0) break; } - } + if (dl == *dop_len) + ndop = NULL; + } else + ndop = NULL; if (ndop == NULL) { if ((ndop = realloc(*dop, - sizeof(**dop) * ((*dop_len) + 1))) == NULL) { + sizeof(**dop) * ((*dop_len) + 1))) == NULL) + { syslog(LOG_ERR, "%s: %m", __func__); return -1; }