]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix vendor options a litle
authorRoy Marples <roy@marples.name>
Fri, 6 Dec 2013 19:15:06 +0000 (19:15 +0000)
committerRoy Marples <roy@marples.name>
Fri, 6 Dec 2013 19:15:06 +0000 (19:15 +0000)
dhcp-common.c
dhcp.c
if-options.c

index 96b8a7411eebb6e4a6e05100d74846ecfd55171c..7e69a2b6f9c0b9b499fad66dc928ea0978fd8a74 100644 (file)
@@ -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 1c87a9f504ecb3ec2473b0cdc8a96fcd957f31f3..cdc989a3b19501189c217bf6c4359ea8b8a49b6b 100644 (file)
--- 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);
+                               }
                        }
                }
        }
index bd596e255a1239aa09e4f30f2f171ff600ee0449..fc468ddf4108f8a33083876f3ebd881c53115e4b 100644 (file)
@@ -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;
                        }