From: Yu Watanabe Date: Mon, 7 Mar 2022 06:45:17 +0000 (+0900) Subject: network: refuse string which contains non-safe or non-ascii characters for Filename= X-Git-Tag: v251-rc1~165^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1aaab93621f5628ba6d8568771b2961282fe468f;p=thirdparty%2Fsystemd.git network: refuse string which contains non-safe or non-ascii characters for Filename= The string will be used when the client load additional config file to boot, and it must be a valid path or url. Hence, let's refuse non-safe or non-characters. --- diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 1636b838e14..0ba96d275c1 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -286,7 +286,7 @@ int sd_dhcp_server_set_next_server(sd_dhcp_server *server, const struct in_addr int sd_dhcp_server_set_filename(sd_dhcp_server *server, const char *filename) { assert_return(server, -EINVAL); - if (filename && !ascii_is_valid(filename)) + if (filename && (!string_is_safe(filename) || !ascii_is_valid(filename))) return -EINVAL; return free_and_strdup(&server->filename, filename); diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 5826a031409..3ae8b8f4600 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -306,7 +306,7 @@ DHCPServer.SendVendorOption, config_parse_dhcp_send_option, DHCPServer.SendOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_server_send_options) DHCPServer.BindToInterface, config_parse_bool, 0, offsetof(Network, dhcp_server_bind_to_interface) DHCPServer.NextServer, config_parse_in_addr_non_null, AF_INET, offsetof(Network, dhcp_server_next_server) -DHCPServer.Filename, config_parse_string, 0, offsetof(Network, dhcp_server_filename) +DHCPServer.Filename, config_parse_string, CONFIG_PARSE_STRING_SAFE_AND_ASCII, offsetof(Network, dhcp_server_filename) DHCPServerStaticLease.Address, config_parse_dhcp_static_lease_address, 0, 0 DHCPServerStaticLease.MACAddress, config_parse_dhcp_static_lease_hwaddr, 0, 0 Bridge.Cost, config_parse_uint32, 0, offsetof(Network, cost)