summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2019-09-02 17:30:59 +0200
committerFrancesco Giudici <fgiudici@redhat.com>2019-09-13 18:44:32 +0200
commit86973eae1f86fd7f36e23ade9fe8892efd8c1846 (patch)
treeb13b36ab44f8851bc0aa15b9b9a1871dc6dba129
parent3a10c477864ed4d07d0e4c67537b67add52926f0 (diff)
downloadNetworkManager-86973eae1f86fd7f36e23ade9fe8892efd8c1846.tar.gz
dhcp: nettools: add utf8 checking on the wpad option
and assert values exported as dhcp options are utf8 compliant
-rw-r--r--src/dhcp/nm-dhcp-nettools.c9
-rw-r--r--src/dhcp/nm-dhcp-options.c1
2 files changed, 7 insertions, 3 deletions
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index 594145a84d..12b14c28ca 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -811,7 +811,7 @@ static void
lease_parse_wpad (NDhcp4ClientLease *lease,
GHashTable *options)
{
- nm_auto_free_gstring GString *str = NULL;
+ gs_free char *wpad = NULL;
uint8_t *data;
size_t n_data;
int r;
@@ -820,11 +820,14 @@ lease_parse_wpad (NDhcp4ClientLease *lease,
if (r)
return;
- str = g_string_new_len ((char *)data, n_data);
+ nm_utils_buf_utf8safe_escape ((char *)data, n_data, 0, &wpad);
+ if (wpad == NULL)
+ wpad = g_strndup ((char *)data, n_data);
+
nm_dhcp_option_add_option (options,
_nm_dhcp_option_dhcp4_options,
NM_DHCP_OPTION_DHCP4_PRIVATE_PROXY_AUTODISCOVERY,
- str->str);
+ wpad);
}
static void
diff --git a/src/dhcp/nm-dhcp-options.c b/src/dhcp/nm-dhcp-options.c
index 0cefd51b1e..b41ca2c941 100644
--- a/src/dhcp/nm-dhcp-options.c
+++ b/src/dhcp/nm-dhcp-options.c
@@ -222,6 +222,7 @@ nm_dhcp_option_take_option (GHashTable *options,
nm_assert (options);
nm_assert (requests);
nm_assert (value);
+ nm_assert (g_utf8_validate (value, -1, NULL));
g_hash_table_insert (options,
(gpointer) nm_dhcp_option_request_string (requests, option),