This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: glibc: inet6_rth_init returned an abnormal address?
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: wangyufen <wangyufen at huawei dot com>
- Cc: libc-alpha at sourceware dot org, drepper at redhat dot com
- Date: Thu, 11 Dec 2014 11:41:42 +0100
- Subject: Re: glibc: inet6_rth_init returned an abnormal address?
- Authentication-results: sourceware.org; auth=none
- References: <5489640C dot 2050400 at huawei dot com>
On Thu, Dec 11, 2014 at 05:29:48PM +0800, wangyufen wrote:
> Hi,
>
> I did some test on inet6_rth_init, inet6_rth_init returnned a invalid address;
> But I used inet6_rth_init_ww (the same implementation as inet6_rth_init) in my test code, It returnned a valid address.
> Dose anyone konw why?
>
Because you used implicit prototype. Compiler then assumes that prototype is
int inet6_rth_init (void *bp, socklen_t bp_len, int type, int segments)
and then sign-extends result, creating invalid pointer.