diff options
author | Thomas Haller <thaller@redhat.com> | 2016-12-06 22:01:41 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-12-06 22:01:41 +0100 |
commit | 92ea1bdb06eda77f3ec5bf6b8cd3bb54da739c77 (patch) | |
tree | d63efcba34b6f1c23940fced1b3fd57bae097277 /libnm-core/nm-setting-proxy.c | |
parent | d7c48077378f9028ef777fc00b62a39506a0fcf8 (diff) | |
download | NetworkManager-92ea1bdb06eda77f3ec5bf6b8cd3bb54da739c77.tar.gz |
proxy: stricter validate the proxy pac script in NMSettingProxy
Diffstat (limited to 'libnm-core/nm-setting-proxy.c')
-rw-r--r-- | libnm-core/nm-setting-proxy.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/libnm-core/nm-setting-proxy.c b/libnm-core/nm-setting-proxy.c index 2e4dca1e65..907edb8f42 100644 --- a/libnm-core/nm-setting-proxy.c +++ b/libnm-core/nm-setting-proxy.c @@ -185,13 +185,31 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } - if (priv->pac_script && strlen (priv->pac_script) > 1*1024*1024) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("the script is too large")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT); - return FALSE; + if (priv->pac_script) { + if (strlen (priv->pac_script) > 1*1024*1024) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("the script is too large")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT); + return FALSE; + } + if (!g_utf8_validate (priv->pac_script, -1, NULL)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("the script is not valid utf8")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT); + return FALSE; + } + if (!strstr (priv->pac_script, "FindProxyForURL")) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("the script lacks FindProxyForURL function")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_PROXY_SETTING_NAME, NM_SETTING_PROXY_PAC_SCRIPT); + return FALSE; + } } return TRUE; |