openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

dhcpv4: fix uninitialized hostname in some ubus events #176

Closed mikma closed 2 years ago

mikma commented 2 years ago

Ubus events contain broken hostnames unless a valid hostname is provided by the DHCP client. Android 10 and later is one example of devices which follow "Anonymity Profiles for DHCP Clients" (https://datatracker.ietf.org/doc/html/rfc7844#section-3.7) and don't provide a hostname.

The bug can be reproduced with ubus subscribe dhcp.

dhcpv4: fix uninitialized hostname in some ubus events

The hostname buffer is uninitialized if the client doesn't provide
DHCPV4_OPT_HOSTNAME. Use hostname from the assignment which is present if
a static lease contains the hostname or if the client provides one, and
the hostname is valid. It's also used in the ubus ipv4leases method.
dedeckeh commented 2 years ago

Patch pushed to master (https://git.openwrt.org/?p=project/odhcpd.git;a=commit;h=01b4e6046f10e21809c3f380f2d33bf3fe59698d); thx