dhcp-option: refuse control and non-UTF8 characters in string option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Mar 2024 16:32:03 +0000 (01:32 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Mar 2024 16:57:17 +0000 (01:57 +0900)
commitfa3357b9e8d9d7a486902d0b6d4b4015fc10aac0
treef6e6489985466faf7120e4c9efb819ed71894813
parentc84a5f5eaf6a929505a76acfebfe63cdd6152de8
dhcp-option: refuse control and non-UTF8 characters in string option

We oftem save parsed DHCP options into a file, or expose them
through DBus or Varlink. In such case, control characters or non-UTF8
characters may cause many kind of unexpected errors. In general, a DHCP
message that have string options with spurious characters is mostly
malformed or broken. Let's refuse them.

This also makes dhcp_option_parse_string() do not free 'ret' argument,
to follow our usual coding style. So, callers now need to free the
pre-exisitng string if necessary.

Fixes #31708.
src/libsystemd-network/dhcp-option.c
src/libsystemd-network/sd-dhcp-lease.c