diff options
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r-- | networking/udhcp/dhcpc.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index c2805a009..0310663e0 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -160,8 +160,8 @@ static int mton(uint32_t mask) | |||
160 | 160 | ||
161 | #if ENABLE_FEATURE_UDHCPC_SANITIZEOPT | 161 | #if ENABLE_FEATURE_UDHCPC_SANITIZEOPT |
162 | /* Check if a given label represents a valid DNS label | 162 | /* Check if a given label represents a valid DNS label |
163 | * Return pointer to the first character after the label upon success, | 163 | * Return pointer to the first character after the label |
164 | * NULL otherwise. | 164 | * (NUL or dot) upon success, NULL otherwise. |
165 | * See RFC1035, 2.3.1 | 165 | * See RFC1035, 2.3.1 |
166 | */ | 166 | */ |
167 | /* We don't need to be particularly anal. For example, allowing _, hyphen | 167 | /* We don't need to be particularly anal. For example, allowing _, hyphen |
@@ -173,8 +173,10 @@ static int mton(uint32_t mask) | |||
173 | static const char *valid_domain_label(const char *label) | 173 | static const char *valid_domain_label(const char *label) |
174 | { | 174 | { |
175 | unsigned char ch; | 175 | unsigned char ch; |
176 | unsigned pos = 0; | 176 | //unsigned pos = 0; |
177 | 177 | ||
178 | if (label[0] == '-') | ||
179 | return NULL; | ||
178 | for (;;) { | 180 | for (;;) { |
179 | ch = *label; | 181 | ch = *label; |
180 | if ((ch|0x20) < 'a' || (ch|0x20) > 'z') { | 182 | if ((ch|0x20) < 'a' || (ch|0x20) > 'z') { |
@@ -187,7 +189,7 @@ static const char *valid_domain_label(const char *label) | |||
187 | } | 189 | } |
188 | } | 190 | } |
189 | label++; | 191 | label++; |
190 | pos++; | 192 | //pos++; |
191 | //Do we want this? | 193 | //Do we want this? |
192 | //if (pos > 63) /* NS_MAXLABEL; labels must be 63 chars or less */ | 194 | //if (pos > 63) /* NS_MAXLABEL; labels must be 63 chars or less */ |
193 | // return NULL; | 195 | // return NULL; |
@@ -272,6 +274,12 @@ static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_ | |||
272 | case OPTION_STRING_HOST: | 274 | case OPTION_STRING_HOST: |
273 | memcpy(dest, option, len); | 275 | memcpy(dest, option, len); |
274 | dest[len] = '\0'; | 276 | dest[len] = '\0'; |
277 | //TODO: it appears option 15 DHCP_DOMAIN_NAME is often abused | ||
278 | //by DHCP admins to contain a space-separated list of domains, | ||
279 | //not one domain name (presumably, to work as list of search domains, | ||
280 | //instead of using proper option 119 DHCP_DOMAIN_SEARCH). | ||
281 | //Currently, good_hostname() balks on strings containing spaces. | ||
282 | //Do we need to allow it? Only for DHCP_DOMAIN_NAME option? | ||
275 | if (type == OPTION_STRING_HOST && !good_hostname(dest)) | 283 | if (type == OPTION_STRING_HOST && !good_hostname(dest)) |
276 | safe_strncpy(dest, "bad", len); | 284 | safe_strncpy(dest, "bad", len); |
277 | return ret; | 285 | return ret; |