After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 698877 - GProxyAddressEnumerator calls g_network_address_parse_uri without default port
GProxyAddressEnumerator calls g_network_address_parse_uri without default port
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-04-25 17:31 UTC by Alban Crequy
Modified: 2013-05-05 20:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (1.21 KB, text/x-csrc)
2013-04-25 17:31 UTC, Alban Crequy
Details

Description Alban Crequy 2013-04-25 17:31:27 UTC
Created attachment 242444 [details]
test case

When libsoup tries to connect to a website via a SOCKS proxy, it uses a GProxyAddressEnumerator but then the address built has always dest_port 0 so the SOCKS proxy fails to connect to the website. It might work on some http proxies but the "ssh -D" SOCKS proxy fails.

The source of the problem is calling g_network_address_parse_uri with default_port=0. Even if the uri contains well-known protocol like "http" or "https", g_network_address_parse_uri() does not default to 80 or 443 but to default_port=0. The calls are here:

gio/gproxyaddressenumerator.c g_proxy_address_enumerator_set_property:
>    conn = g_network_address_parse_uri (uri, 0, NULL);

gio/gproxyaddressenumerator.c next_enumerator
>    connectable = g_network_address_parse_uri (priv->proxy_uri, 0, &error);

The stack of my program when libsoup gets a bad dest_port:

  • #0 g_network_address_parse_uri
    at gnetworkaddress.c line 727
  • #1 g_proxy_address_enumerator_set_property
    at gproxyaddressenumerator.c line 624
  • #2 g_object_constructor
    from /usr/lib64/libgobject-2.0.so.0
  • #3 g_object_newv
    from /usr/lib64/libgobject-2.0.so.0
  • #4 g_object_new_valist
    from /usr/lib64/libgobject-2.0.so.0
  • #5 g_object_new
    from /usr/lib64/libgobject-2.0.so.0
  • #6 soup_address_connectable_proxy_enumerate
    at soup-address.c line 1214
  • #7 g_socket_client_connect_async
    at gsocketclient.c line 1705
  • #8 soup_socket_connect_async
    at soup-socket.c line 798

The attached program shows what I would like g_network_address_parse_uri to do.
Comment 1 Simon McVittie 2013-04-25 18:36:08 UTC
I'm not sure that GIO can be expected to maintain a big list of default ports for different URI schemes (although http and https are perhaps ubiquitous enough to make an exception).

Perhaps libsoup should be decomposing the real-http-URI, re-composing just the scheme, hostname and port to which it wants to connect into a minimal URI-like thing (http://foo.example.com:80), and passing those into GSocketClient?
Comment 2 Dan Winship 2013-04-25 19:09:26 UTC
so, this is already fixed in libsoup; a 2.42.2 tarball went out yesterday.

but I think we need to add a "default-port" property to GProxyAddressEnumerator as well, for it to pass to g_network_address_parse_uri() along with the URI.
Comment 3 Alban Crequy 2013-04-26 11:17:47 UTC
Thanks Dan!

Nicolas Dufresne (who wrote g_network_address_parse_uri) said "It's an application task to resolve the service." So I am marking this bug as duplicate of Bug #698163.

I'm quoting the fix in libsoup 2.42.2 for future reference:

>commit 3943610faed4922b739162f244f32e0b2393cba0
>Author: Dan Winship <danw@gnome.org>
>Date:   Thu Apr 18 10:30:32 2013 -0400
>
>    soup-address: fix proxy enumerator implementation
>    
>    When creating a GProxyAddressEnumerator, the destination URI passed to
>    it must include the port number, or the proxy may end up trying to
>    connect to port 0. libsoup was omitting the port number when it was
>    the default for the protocol.
>    
>    https://bugzilla.gnome.org/show_bug.cgi?id=698163

*** This bug has been marked as a duplicate of bug 698163 ***
Comment 4 Dan Winship 2013-04-26 14:06:02 UTC
it's an application task, but GProxyAddressEnumerator ought to let the application specify the URI and default-port separately, for the same reason that g_network_address_parse_uri() does.
Comment 5 Dan Winship 2013-05-05 20:52:54 UTC
fixed in master