]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: refuse string which contains non-safe or non-ascii characters for Filename=
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Mar 2022 06:45:17 +0000 (15:45 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Mar 2022 05:43:48 +0000 (14:43 +0900)
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.

src/libsystemd-network/sd-dhcp-server.c
src/network/networkd-network-gperf.gperf

index 1636b838e14bb7abd7dbaddbd53d4dd7e72c9f6c..0ba96d275c118976edd30e3a65f7cd3d876d0c23 100644 (file)
@@ -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);
index 5826a03140925e9e7fefc09fe867ea2f146ef993..3ae8b8f4600d9cace03b9892e9dadec35cd9ef5a 100644 (file)
@@ -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)