summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-17 16:22:26 +0100
committerThomas Haller <thaller@redhat.com>2020-02-18 13:23:50 +0100
commit82fb8b00b49f9f4ed9a6b709aea28c45037d194b (patch)
tree89fa506ff5195dfe0b0931f5f7be0bd122ea2346
parented5a647ad17833a10c325661d28af41a07995c3c (diff)
downloadNetworkManager-82fb8b00b49f9f4ed9a6b709aea28c45037d194b.tar.gz
shared: check for valid UTF-8 in nm_utils_ifname_valid()
The interface name might come from the command line or from a filename (like during nm_vpn_wireguard_import()). It's not clear that this is valid UTF-8. Asserting against that requires the caller to ensure that the encoding is valid. That is cumbersome, especially since we anyway check. Just report a regular error.
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c
index b6f260f527..2ea1a57de3 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -4127,7 +4127,11 @@ nm_utils_ifname_valid (const char* name,
return FALSE;
}
- g_return_val_if_fail (g_utf8_validate (name, -1, NULL), FALSE);
+ if (!g_utf8_validate (name, -1, NULL)) {
+ g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
+ _("interface name must be UTF-8 encoded"));
+ return FALSE;
+ }
switch (type) {
case NMU_IFACE_KERNEL: