diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2018-08-22 11:45:53 +0200 |
---|---|---|
committer | Hans Dedecker <hans.dedecker@technicolor.com> | 2018-09-05 10:35:42 +0200 |
commit | 881f66b0c2526bff6a2a51b30d314c512df813b4 (patch) | |
tree | 234850b1775f67884468265dd15485881d69cdbb /src/dhcpv4.c | |
parent | 3e17fd926ff0f8feae97ff7c86dd5ce282315490 (diff) |
odhcpd: detect broken hostnames
Check hostnames contain valid characters as defined in RFC 952 and RFC 1123.
Invalid hostnames in uci configured host entries will result into a refusal
to create the static lease.
In case a client received hostname contains an invalid character no
<hostname> <IP address> entry will be added to the lease file.
In such case the leaseinfo description in the lease file will still contain
the hostname but preceded by the string broken\x20
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 3386abb..2cc6278 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -1095,6 +1095,11 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, if (a->hostname) { memcpy(a->hostname, hostname, hostname_len); a->hostname[hostname_len] = 0; + + if (odhcpd_valid_hostname(a->hostname)) + a->flags &= ~OAF_BROKEN_HOSTNAME; + else + a->flags |= OAF_BROKEN_HOSTNAME; } } |