dhcp: accept IPv4-address options longer than expected

Some DHCP servers send duplicate options, and we concatenate them
according to RFC 3396 section 7. Therefore, it's possible that a
option carrying a IPv4 address has a length > 4.

See also commit 1cbf9d22a5 ('n-dhcp4: accept options that are longer
than requested') which did something similar in the nettools client.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/848
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1034
This commit is contained in:
Beniamino Galvani 2021-11-24 16:57:23 +01:00
parent 9a76b07f74
commit 7f8c8078a1

View file

@ -1010,7 +1010,11 @@ nm_dhcp_lease_data_parse_in_addr(const guint8 *data, gsize n_data, in_addr_t *ou
* - option 28, https://tools.ietf.org/html/rfc2132#section-5.3
*/
if (n_data != 4)
/* Some DHCP servers send duplicate options, and we concatenate them
* according to RFC 3396 section 7. Therefore, it's possible that a
* option carrying a IPv4 address has a length > 4.
*/
if (n_data < 4)
return FALSE;
*out_val = unaligned_read_ne32(data);