diff options
-rw-r--r-- | networking/udhcp/leases.c | 11 |
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( | |||
65 | if (hostname_len > sizeof(oldest->hostname)) | 65 | if (hostname_len > sizeof(oldest->hostname)) |
66 | hostname_len = sizeof(oldest->hostname); | 66 | hostname_len = sizeof(oldest->hostname); |
67 | p = safe_strncpy(oldest->hostname, hostname, hostname_len); | 67 | p = safe_strncpy(oldest->hostname, hostname, hostname_len); |
68 | /* sanitization (s/non-ASCII/^/g) */ | 68 | /* |
69 | * Sanitization (s/bad_char/./g). | ||
70 | * The intent is not to allow only "DNS-valid" hostnames, | ||
71 | * but merely make dumpleases output safe for shells to use. | ||
72 | * We accept "0-9A-Za-z._-", all other chars turn to dots. | ||
73 | */ | ||
69 | while (*p) { | 74 | while (*p) { |
70 | if (*p < ' ' || *p > 126) | 75 | if (!isalnum(*p) && *p != '-' && *p != '_') |
71 | *p = '^'; | 76 | *p = '.'; |
72 | p++; | 77 | p++; |
73 | } | 78 | } |
74 | } | 79 | } |