From cb8c9199524d888bc2e354bbc05a5603b205d322 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 7 Dec 2016 17:34:02 +0100 Subject: [PATCH] simpleproxyresolver: Don't crash on invalid hostname Check for g_hostname_to_ascii() failure, rather than crashing when checking whether an invalid hostname should go through the proxy. The HTTP library should report the error about the invalid hostname once we actually try to connect to it. https://bugzilla.gnome.org/show_bug.cgi?id=772989 --- gio/gsimpleproxyresolver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gio/gsimpleproxyresolver.c b/gio/gsimpleproxyresolver.c index 145bd5e8c..8a6fb38df 100644 --- a/gio/gsimpleproxyresolver.c +++ b/gio/gsimpleproxyresolver.c @@ -287,11 +287,13 @@ ignore_host (GSimpleProxyResolver *resolver, if (priv->ignore_domains) { + length = 0; if (g_hostname_is_non_ascii (host)) host = ascii_host = g_hostname_to_ascii (host); - length = strlen (host); + if (host) + length = strlen (host); - for (i = 0; priv->ignore_domains[i].length; i++) + for (i = 0; length > 0 && priv->ignore_domains[i].length; i++) { GSimpleProxyResolverDomain *domain = &priv->ignore_domains[i];