Bug 3253 - all addresses of getaddrinfo() result should be tried
Summary: all addresses of getaddrinfo() result should be tried
Status: RESOLVED FIXED
Alias: None
Product: Claws Mail (GTK 2)
Classification: Unclassified
Component: Other (show other bugs)
Version: 3.10.1
Hardware: PC Linux
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2014-08-21 05:31 UTC by Timo Teräs
Modified: 2016-04-13 08:38 UTC (History)
0 users

See Also:


Attachments
Use getattrinfo instead of gethostbyname (8.84 KB, patch)
2015-08-18 19:19 UTC, Andrej Kacian
no flags Details | Diff

Description Timo Teräs 2014-08-21 05:31:50 UTC
If I have multiple A and/or AAAA records for hostname, only the first result returned by getaddrinfo() for which a socket can be created is tried. This means if that IP-address is not responsive (timeouts), the others are not tried.

E.g. imap.gmail.com has two A records, and one AAAA record. It has happened sometimes that the first A result timeouts, but the second A works. In these instances it is not possible to connect.
Comment 1 Andrej Kacian 2015-08-18 19:19:02 UTC
Created attachment 1559 [details]
Use getattrinfo instead of gethostbyname

Attached patch attempts to improve the situation by using getaddrinfo() instead of deprecated gethostbyname(), and trying each resolved address (skipping ipv6 addresses if ipv6 support is disabled).

Of course, review and testing needed, especially by people on ipv6.
Comment 2 users 2015-08-20 06:29:02 UTC
Changes related to this bug have been committed.
Please check latest Git and update the bug accordingly.
You can also get the patch from:
http://git.claws-mail.org/

++ ChangeLog	2015-08-20 08:29:02.732280727 +0200
http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=99c3faf9573e885cac1fd625ce799d1f0acb6f04
Merge: d4741c3 8f4236e
Author: Colin Leroy <colin@colino.net>
Date:   Thu Aug 20 08:29:02 2015 +0200

    Merge branch 'master' of file:///home/git/claws

http://git.claws-mail.org/?p=claws.git;a=commitdiff;h=8f4236e282d3252ecf9f3920e2e5c312d2cf50fc
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Wed Oct 1 22:00:06 2014 +0200

    Use getaddrinfo() instead of gethostbyname() in socket.c.
    
    Closes bug #3253, as we're trying all resolved addresses.
    This should also make IPv6 work on Windows, bug #3495.
Comment 3 Ricardo Mones 2016-04-13 08:38:23 UTC
Fix already released in 3.13.0.

Note You need to log in before you can comment on or make changes to this bug.