Imported Upstream version 2.72.3
[platform/upstream/glib.git] / gio / gsimpleproxyresolver.c
index 0dd3c4f..f19d567 100644 (file)
@@ -50,7 +50,7 @@
 
 typedef struct {
   gchar        *name;
-  gint          length;
+  gsize          length;
   gushort       port;
 } GSimpleProxyResolverDomain;
 
@@ -259,7 +259,8 @@ ignore_host (GSimpleProxyResolver *resolver,
   GSimpleProxyResolverPrivate *priv = resolver->priv;
   gchar *ascii_host = NULL;
   gboolean ignore = FALSE;
-  gint i, length, offset;
+  gsize offset, length;
+  guint i;
 
   if (priv->ignore_ips)
     {
@@ -297,6 +298,9 @@ ignore_host (GSimpleProxyResolver *resolver,
        {
          GSimpleProxyResolverDomain *domain = &priv->ignore_domains[i];
 
+          if (domain->length > length)
+            continue;
+
          offset = length - domain->length;
          if ((domain->port == 0 || domain->port == port) &&
              (offset == 0 || (offset > 0 && host[offset - 1] == '.')) &&
@@ -489,7 +493,7 @@ g_simple_proxy_resolver_iface_init (GProxyResolverInterface *iface)
  * g_simple_proxy_resolver_new:
  * @default_proxy: (nullable): the default proxy to use, eg
  *     "socks://192.168.1.1"
- * @ignore_hosts: (nullable): an optional list of hosts/IP addresses
+ * @ignore_hosts: (array zero-terminated=1) (nullable): an optional list of hosts/IP addresses
  *     to not use a proxy for.
  *
  * Creates a new #GSimpleProxyResolver. See
@@ -540,7 +544,7 @@ g_simple_proxy_resolver_set_default_proxy (GSimpleProxyResolver *resolver,
 /**
  * g_simple_proxy_resolver_set_ignore_hosts:
  * @resolver: a #GSimpleProxyResolver
- * @ignore_hosts: %NULL-terminated list of hosts/IP addresses
+ * @ignore_hosts: (array zero-terminated=1): %NULL-terminated list of hosts/IP addresses
  *     to not use a proxy for
  *
  * Sets the list of ignored hosts.