aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/udhcp/Config.src11
-rw-r--r--networking/udhcp/dhcpc.c4
2 files changed, 15 insertions, 0 deletions
diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src
index 6bfa398ea..c34c8d6f0 100644
--- a/networking/udhcp/Config.src
+++ b/networking/udhcp/Config.src
@@ -84,6 +84,17 @@ config FEATURE_UDHCPC_ARPING
84 will DHCPDECLINE the offer if the address is in use, 84 will DHCPDECLINE the offer if the address is in use,
85 and restart the discover process. 85 and restart the discover process.
86 86
87config FEATURE_UDHCPC_SANITIZEOPT
88 bool "Do not pass malformed host and domain names"
89 default y
90 depends on UDHCPC
91 help
92 If selected, udhcpc will check some options (such as option 12 -
93 hostname) and if they don't look like valid hostnames
94 (for example, if they start with dash or contain spaces),
95 they will be replaced with string "bad" when exporting
96 to the environment.
97
87config FEATURE_UDHCP_PORT 98config FEATURE_UDHCP_PORT
88 bool "Enable '-P port' option for udhcpd and udhcpc" 99 bool "Enable '-P port' option for udhcpd and udhcpc"
89 default n 100 default n
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 7dfc160e2..e468b7bbb 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -136,6 +136,7 @@ static int mton(uint32_t mask)
136 return i; 136 return i;
137} 137}
138 138
139#if ENABLE_FEATURE_UDHCPC_SANITIZEOPT
139/* Check if a given label represents a valid DNS label 140/* Check if a given label represents a valid DNS label
140 * Return pointer to the first character after the label upon success, 141 * Return pointer to the first character after the label upon success,
141 * NULL otherwise. 142 * NULL otherwise.
@@ -192,6 +193,9 @@ static int good_hostname(const char *name)
192 name++; 193 name++;
193 } 194 }
194} 195}
196#else
197# define good_hostname(name) 1
198#endif
195 199
196/* Create "opt_name=opt_value" string */ 200/* Create "opt_name=opt_value" string */
197static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name) 201static NOINLINE char *xmalloc_optname_optval(uint8_t *option, const struct dhcp_optflag *optflag, const char *opt_name)