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 679957 - g_inet_address_new_from_string is not able to handle dots and numbers IPv4 addresses
g_inet_address_new_from_string is not able to handle dots and numbers IPv4 ad...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-07-15 12:05 UTC by Yann Soubeyrand
Modified: 2014-02-15 20:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make use of inet_aton for IPv4 addresses instead of inet_pton in g_address_new_from_string (1.12 KB, patch)
2012-07-15 12:05 UTC, Yann Soubeyrand
none Details | Review
Test case (316 bytes, text/plain)
2012-07-15 12:29 UTC, Yann Soubeyrand
  Details
gio: don't accept nonstandard IPv4 "numbers-and-dots" addresses (14.84 KB, patch)
2014-02-01 16:59 UTC, Dan Winship
committed Details | Review

Description Yann Soubeyrand 2012-07-15 12:05:59 UTC
Created attachment 218850 [details] [review]
Make use of inet_aton for IPv4 addresses instead of inet_pton in g_address_new_from_string

Hi,

g_inet_address_new_from_string is not able to handle dots and numbers IPv4 addresses and here is a patch to correct this.

Cheers
Comment 1 Colin Walters 2012-07-15 12:19:15 UTC
Review of attachment 218850 [details] [review]:

Needs a test case at a minimum.  "git annotate gio/ginetaddress.c" says this was added in:

68fc0556        (Dan Winship    2008-12-12 13:13:55 -0500).

Dan watches bugzilla so he should review this one.
Comment 2 Yann Soubeyrand 2012-07-15 12:28:51 UTC
The test case attached should print 127.0.0.1. Instead it currently prints Error.
Comment 3 Yann Soubeyrand 2012-07-15 12:29:21 UTC
Created attachment 218852 [details]
Test case
Comment 4 Colin Walters 2012-07-15 13:34:22 UTC
I meant adding a test case to gio/tests that would get run automatically.
Comment 5 Dan Winship 2012-07-15 14:50:22 UTC
The additional formats parsed by inet_aton() are not actually part of any standard, were not much used historically, and are only ever used now by phishers trying to obscure the domain name in URLs (eg, http://yourbank.com@1539136771/)
Comment 6 Yann Soubeyrand 2012-07-15 14:56:31 UTC
Dan, you're right but for my GSOC project (an anti-phishing daemon for GNOME) I use the Google Safe Browsing API which explicitly requires me to handle these formats, that's why I did this patch.
Comment 7 Dan Winship 2012-07-16 15:29:43 UTC
(In reply to comment #6)
> Dan, you're right but for my GSOC project (an anti-phishing daemon for GNOME) I
> use the Google Safe Browsing API which explicitly requires me to handle these
> formats

Well... I think at a higher level, the requirement is "you must be able to stop people from connecting to phishing sites via URLs using those formats". But since libsoup/gio don't support those formats at all, this is trivially achieved even without the use of the safe browsing API.

Put another way, it would be silly to add this feature to GInetAddress solely so that we could then block anyone who is trying to using it. :-)
Comment 8 Yann Soubeyrand 2012-07-16 16:58:41 UTC
(In reply to comment #7)
> Well... I think at a higher level, the requirement is "you must be able to stop
> people from connecting to phishing sites via URLs using those formats". But
> since libsoup/gio don't support those formats at all, this is trivially
> achieved even without the use of the safe browsing API.

Epiphany doesn't use libsoup? Because http://3584377034/ leads me to the GMX website as expected.

> 
> Put another way, it would be silly to add this feature to GInetAddress solely
> so that we could then block anyone who is trying to using it. :-)

Sure ;-) But I thought libsoup was handling that as Epiphany handles that.

Cheers
Comment 9 Dan Winship 2012-07-16 17:01:21 UTC
hm... it uses libsoup, but the URIs get passed through webkit code too... that must be getting resolved by webkit.

(either that or you're testing with your patched glib?)
Comment 10 Yann Soubeyrand 2012-07-16 17:03:09 UTC
(In reply to comment #9)
> hm... it uses libsoup, but the URIs get passed through webkit code too... that
> must be getting resolved by webkit.
> 
> (either that or you're testing with your patched glib?)

Hum, that was what I thought at first but I did sudo make uninstall so I guess it's good?
Comment 11 Yann Soubeyrand 2012-07-16 17:05:17 UTC
(In reply to comment #9)
> hm... it uses libsoup, but the URIs get passed through webkit code too... that
> must be getting resolved by webkit.

Maybe that should be solved by Webkit but beware that until it gets my daemon won't caught phishing tentatives that use this trick. And everything in GNOME uses libsoup or not to get web content?
Comment 12 Dan Winship 2012-07-17 14:44:25 UTC
Hm... looks like g_resolver_lookup_by_name() decides its not an IP address, so it eventually calls getaddrinfo() to resolve the hostname, but getaddrinfo() does recognize that format, so it parses it as an IP address.

I guess given that, maybe we do want the patch... still pondering.
Comment 13 Dan Winship 2014-02-01 16:59:09 UTC
Created attachment 267791 [details] [review]
gio: don't accept nonstandard IPv4 "numbers-and-dots" addresses

I'm planning to commit this if there are no objections
Comment 14 Dan Winship 2014-02-15 15:27:21 UTC
Attachment 267791 [details] pushed as 5575a3e - gio: don't accept nonstandard IPv4 "numbers-and-dots" addresses
Comment 15 Allison Karlitskaya (desrt) 2014-02-15 20:02:12 UTC
See bug 724434 for a regression.