case 'i':
if (arg)
s = parse_string((char *)ifo->vendorclassid + 1,
- VENDORCLASSID_MAX_LEN, arg);
+ sizeof(ifo->vendorclassid) - 1, arg);
else
s = 0;
if (s == -1) {
if (p == arg) {
arg++;
s = parse_string((char *)ifo->vendor + 1,
- VENDOR_MAX_LEN, arg);
+ sizeof(ifo->vendor) - 1, arg);
if (s == -1) {
logerr("vendor");
return -1;
}
arg = p + 1;
- s = VENDOR_MAX_LEN - ifo->vendor[0] - 2;
+ s = sizeof(ifo->vendor) - 1 - ifo->vendor[0] - 2;
if (inet_aton(arg, &addr) == 1) {
if (s < 6) {
s = -1;
ifo->options |= DHCPCD_XID_HWADDR;
break;
case 'I':
- /* Strings have a type of 0 */;
- ifo->clientid[1] = 0;
if (arg)
+ /* If parse_hwaddr cannot decoded arg as a
+ * hardware address then the first byte
+ * in the clientid will be zero to indicate
+ * a string value. */
s = parse_hwaddr((char *)ifo->clientid + 1,
- CLIENTID_MAX_LEN, arg);
+ sizeof(ifo->clientid) - 1, arg);
else
s = 0;
if (s == -1) {
break;
case O_MUDURL:
ARG_REQUIRED;
- s = parse_string((char *)ifo->mudurl + 1, MUDURL_MAX_LEN, arg);
+ s = parse_string((char *)ifo->mudurl + 1,
+ sizeof(ifo->mudurl) - 1, arg);
if (s == -1) {
logerr("mudurl");
return -1;
#ifndef HOSTNAME_MAX_LEN
#define HOSTNAME_MAX_LEN 250 /* 255 - 3 (FQDN) - 2 (DNS enc) */
#endif
-#define VENDORCLASSID_MAX_LEN 255
-#define CLIENTID_MAX_LEN 48
-#define USERCLASS_MAX_LEN 255
-#define VENDOR_MAX_LEN 255
-#define MUDURL_MAX_LEN 255
+#define DHCP_OPTION_MAX_LEN 255
#define DHCPCD_ARP (1ULL << 0)
#define DHCPCD_RELEASE (1ULL << 1)
char **environ;
- char hostname[HOSTNAME_MAX_LEN + 1]; /* We don't store the length */
+ char hostname[HOSTNAME_MAX_LEN + 1]; /* NUL terminated */
uint8_t fqdn;
- uint8_t vendorclassid[VENDORCLASSID_MAX_LEN + 2];
- uint8_t clientid[CLIENTID_MAX_LEN + 2];
- uint8_t userclass[USERCLASS_MAX_LEN + 2];
- uint8_t vendor[VENDOR_MAX_LEN + 2];
- uint8_t mudurl[MUDURL_MAX_LEN + 2];
+ /* The first byte is the option length */
+ uint8_t vendorclassid[DHCP_OPTION_MAX_LEN + 1];
+ uint8_t clientid[DHCP_OPTION_MAX_LEN + 1];
+ uint8_t userclass[DHCP_OPTION_MAX_LEN + 1];
+ uint8_t vendor[DHCP_OPTION_MAX_LEN + 1];
+ uint8_t mudurl[DHCP_OPTION_MAX_LEN + 1];
size_t blacklist_len;
in_addr_t *blacklist;