Bug 10567 - getaddrinfo() hints==NULL (ai_flags) deviates from POSIX.1
Summary: getaddrinfo() hints==NULL (ai_flags) deviates from POSIX.1
Status: RESOLVED WONTFIX
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.10
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-27 10:07 UTC by Michael Kerrisk
Modified: 2014-07-01 06:55 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kerrisk 2009-08-27 10:07:13 UTC
POSIX.1-2001 and 2008 say that if the hints argument of getaddrinfo() is NULL, then 

       the behavior shall be as if it referred  to  a  structure
       containing  the value zero for the ai_flags, ai_socktype,
       and ai_protocol fields, and AF_UNSPEC for  the  ai_family
       field.

However, glibc defines ai_flags as AI_V4MAPPED | AI_ADDRCONFIG for this case. Is
this deviation from POSIX.1 intentional? Should it be fixed?
Comment 1 Ulrich Drepper 2009-08-31 12:14:51 UTC
(In reply to comment #0)
> Should it be fixed?

No.  Like several other things in the getaddrinfo spec this is non-optimal at
best.  The defaults used in glibc are much better.
Comment 2 mtk.manpages@googlemail.com 2009-09-03 04:15:22 UTC
Subject: Re:  getaddrinfo() hints==NULL (ai_flags) deviates 
	from POSIX.1

On Mon, Aug 31, 2009 at 2:14 PM, drepper at redhat dot
com<sourceware-bugzilla@sourceware.org> wrote:
>
> ------- Additional Comments From drepper at redhat dot com  2009-08-31 12:14 -------
> (In reply to comment #0)
>> Should it be fixed?
>
> No.  Like several other things in the getaddrinfo spec this is non-optimal at
> best.  The defaults used in glibc are much better.

Thanks. I'll update the man page to make it clear that this choice is
deliberate.

Comment 3 Paul Fee 2009-10-09 22:08:26 UTC
Can some details be added as to why the glibc defaults are better than the POSIX standard.

The default only applies if hints==NULL.  If the POSIX defaults are non-optimal, then users of
other systems (e.g. Solaris) would find it useful to know that different settings are preferred. 
On Solaris 10, setting hints to NULL results in POSIX defined behaviour.

Are the reasons behind glibc's defaults unique to glibc or are they related to network effects
which would apply to any OS or C resolver library.  If the settings are valid everywhere then
getaddrinfo() users would benefit from using them on non-glibc platforms.

Thanks.