summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordumbbell <dumbbell@FreeBSD.org>2011-12-30 14:33:08 +0000
committerdumbbell <dumbbell@FreeBSD.org>2011-12-30 14:33:08 +0000
commit5f51b7b385ca5b628c4c361761217aa1fe34b412 (patch)
tree8c5635f908c23500ee2bf41eac4ba092d78f00d4
parenta15eaa46ba0aac83cf6e919b45bb5fe91ad4145e (diff)
downloadFreeBSD-src-5f51b7b385ca5b628c4c361761217aa1fe34b412.zip
FreeBSD-src-5f51b7b385ca5b628c4c361761217aa1fe34b412.tar.gz
Invalid Domain Search option isn't considered as a fatal error
In the original Domain Search option patch, an invalid option value would cause the whole lease to be rejected. However, DHCP servers who emit such an invalid value are more common than I thought. With this new patch, just the option is rejected, not the entire lease. PR: bin/163431 Submitted by: Fabian Keil <fk@fabiankeil.de> (earlier version) Reviewed by: Fabian Keil <fk@fabiankeil.de> Sponsored by: Yakaz (http://www.yakaz.com)
-rw-r--r--sbin/dhclient/options.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index 3f87028..17643e7 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -211,7 +211,7 @@ parse_option_buffer(struct packet *packet,
void
expand_domain_search(struct packet *packet)
{
- int offset, expanded_len;
+ int offset, expanded_len, next_domain_len;
struct option_data *option;
unsigned char *domain_search, *cursor;
@@ -224,9 +224,13 @@ expand_domain_search(struct packet *packet)
expanded_len = 0;
offset = 0;
while (offset < option->len) {
+ next_domain_len = find_search_domain_name_len(option, &offset);
+ if (next_domain_len < 0)
+ /* The Domain Search option value is invalid. */
+ return;
+
/* We add 1 for the space between domain names. */
- expanded_len +=
- find_search_domain_name_len(option, &offset) + 1;
+ expanded_len += next_domain_len + 1;
}
if (expanded_len > 0)
/* Remove 1 for the superfluous trailing space. */
@@ -271,8 +275,9 @@ find_search_domain_name_len(struct option_data *option, int *offset)
/* This is a pointer to another list of labels. */
if (i + 1 >= option->len) {
/* The pointer is truncated. */
- error("Truncated pointer in DHCP Domain "
+ warning("Truncated pointer in DHCP Domain "
"Search option.");
+ return (-1);
}
pointer = ((label_len & ~(0xC0)) << 8) +
@@ -282,8 +287,9 @@ find_search_domain_name_len(struct option_data *option, int *offset)
* The pointer must indicates a prior
* occurance.
*/
- error("Invalid forward pointer in DHCP Domain "
- "Search option compression.");
+ warning("Invalid forward pointer in DHCP "
+ "Domain Search option compression.");
+ return (-1);
}
pointed_len = find_search_domain_name_len(option,
@@ -295,7 +301,9 @@ find_search_domain_name_len(struct option_data *option, int *offset)
}
if (i + label_len >= option->len) {
- error("Truncated label in DHCP Domain Search option.");
+ warning("Truncated label in DHCP Domain Search "
+ "option.");
+ return (-1);
}
/*
@@ -308,9 +316,9 @@ find_search_domain_name_len(struct option_data *option, int *offset)
i += label_len + 1;
}
- error("Truncated DHCP Domain Search option.");
+ warning("Truncated DHCP Domain Search option.");
- return (0);
+ return (-1);
}
void
OpenPOWER on IntegriCloud