aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-24 04:45:22 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-24 04:45:22 +0200
commit9a512176686d5f1548dc1e1c610af440a3ee0d73 (patch)
tree06fe3e63ae4879e8efa4282203a4db6a8088e718 /networking
parent941e7a491971574e5d06227f8dc63806335b8745 (diff)
downloadbusybox-9a512176686d5f1548dc1e1c610af440a3ee0d73.tar.gz
dumpleases: make host names sanitized to shell-friendly condition
function old new delta add_lease 271 298 +27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/leases.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index 745340ad3..844bb60b1 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -65,10 +65,15 @@ struct dyn_lease* FAST_FUNC add_lease(
if (hostname_len > sizeof(oldest->hostname))
hostname_len = sizeof(oldest->hostname);
p = safe_strncpy(oldest->hostname, hostname, hostname_len);
- /* sanitization (s/non-ASCII/^/g) */
+ /*
+ * Sanitization (s/bad_char/./g).
+ * The intent is not to allow only "DNS-valid" hostnames,
+ * but merely make dumpleases output safe for shells to use.
+ * We accept "0-9A-Za-z._-", all other chars turn to dots.
+ */
while (*p) {
- if (*p < ' ' || *p > 126)
- *p = '^';
+ if (!isalnum(*p) && *p != '-' && *p != '_')
+ *p = '.';
p++;
}
}