Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jul 2014 15:17:12 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-doc@FreeBSD.org
Subject:   [Bug 189268] 3 getaddrinfo(3) - hostanme="localhost", but it returns IN_ADDR_ANY (0.0.0.0)
Message-ID:  <bug-189268-9-mU4wLudu2E@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-189268-9@https.bugs.freebsd.org/bugzilla/>
References:  <bug-189268-9@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=189268

--- Comment #9 from dreamcat4@gmail.com ---
(In reply to Benjamin Kaduk from comment #8)
> I do not see why it is believed to be correct behavior to blindly cast
> addrinfo->ai_addr to type 'struct sockaddr_in *' without first checking that
> addrinfo->ai_family is PF_INET (or that the sockaddr's sa_family is
> AFS_INET); such a cast is expected to yield "nonsense" results when
> ai_family is PF_INET6.

I made the change you suggested.

https://gist.github.com/dreamcat4/86706bba25c468fc0ecc

For PF_INET6 hints, the returned structure says it is of type ai_family '0x1C'
(which is '28' in decimal base 10).

If we look in the header file '/usr/include/sys/socket.h', we see that returned
type is: AF_ISDN

:/

Maybe that aught to be a returned value of type '30' (0x1E) for PF_INET6. Since
that was the type we actually requested?


#define pseudo_AF_PIP    25        /* Help Identify PIP packets */
#ifdef __APPLE__
/*define pseudo_AF_BLUE    26       Identify packets for Blue Box - Not used */
#define AF_NDRV        27        /* Network Driver 'raw' access */
#endif
#define    AF_ISDN        28        /* Integrated Services Digital Network*/
#define    AF_E164        AF_ISDN        /* CCITT E.164 recommendation */
#define    pseudo_AF_KEY    29        /* Internal key-management function */
#endif    /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
#define    AF_INET6    30        /* IPv6 */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define    AF_NATM        31        /* native ATM access */
#ifdef __APPLE__
#define AF_SYSTEM    32        /* Kernel event messages */

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-189268-9-mU4wLudu2E>