diff options
author | Francesco Giudici <fgiudici@redhat.com> | 2019-09-02 17:30:59 +0200 |
---|---|---|
committer | Francesco Giudici <fgiudici@redhat.com> | 2019-09-06 12:30:39 +0200 |
commit | 462e927e4f34c1e35793c0146ab595ac28a95a11 (patch) | |
tree | 4af52c1ebe7bcd48c2e66972fde5a7294e7df523 | |
parent | 6645fde367bbe5a2d73eb9d1d77d31c21a9a28b6 (diff) | |
download | NetworkManager-462e927e4f34c1e35793c0146ab595ac28a95a11.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.c | 9 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-options.c | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c index 42717d0dcc..b26cf942b2 100644 --- a/src/dhcp/nm-dhcp-nettools.c +++ b/src/dhcp/nm-dhcp-nettools.c @@ -824,7 +824,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; @@ -833,11 +833,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 21963070af..15d77dd1e0 100644 --- a/src/dhcp/nm-dhcp-options.c +++ b/src/dhcp/nm-dhcp-options.c @@ -236,6 +236,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), |