From: Roy Marples Date: Wed, 27 May 2020 20:49:05 +0000 (+0100) Subject: DHCP6: Use interface vendorclassid rather than context X-Git-Tag: v9.1.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d9b53be4a50074ba4cc27ec51fcc0d8d87565b3;p=thirdparty%2Fdhcpcd.git DHCP6: Use interface vendorclassid rather than context This allows the vendor class to be turned off as well. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index ad0f9b54..578f2834 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -262,21 +262,22 @@ dhcp6_makevendor(void *data, const struct interface *ifp) size_t len, vlen, i; uint8_t *p; const struct vivco *vivco; - char vendor[VENDORCLASSID_MAX_LEN]; struct dhcp6_option o; ifo = ifp->options; len = sizeof(uint32_t); /* IANA PEN */ if (ifo->vivco_en) { + vlen = 0; for (i = 0, vivco = ifo->vivco; i < ifo->vivco_len; i++, vivco++) - len += sizeof(uint16_t) + vivco->len; - vlen = 0; /* silence bogus gcc warning */ - } else { - vlen = strlcpy(vendor, ifp->ctx->vendor, sizeof(vendor)); + vlen += sizeof(uint16_t) + vivco->len; + len += vlen; + } else if (ifo->vendorclassid[0] != '\0') { + vlen = (size_t)ifo->vendorclassid[0]; len += sizeof(uint16_t) + vlen; - } + } else + return 0; if (len > UINT16_MAX) { logerrx("%s: DHCPv6 Vendor Class too big", ifp->name); @@ -307,11 +308,11 @@ dhcp6_makevendor(void *data, const struct interface *ifp) memcpy(p, vivco->data, vivco->len); p += vivco->len; } - } else if (vlen) { + } else if (ifo->vendorclassid[0] != '\0') { hvlen = htons((uint16_t)vlen); memcpy(p, &hvlen, sizeof(hvlen)); p += sizeof(hvlen); - memcpy(p, vendor, (size_t)vlen); + memcpy(p, ifo->vendorclassid + 1, (size_t)vlen); } }