NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

inet_ntoa error on NetBSD-4.0 amd64



I have a program as below
#if 1
#include <netinet/in.h>
#else
#include <arpa/inet.h>
#endif

#include <stdio.h>

struct in_addr in;
int main(void)
{
    char *s;
    in.s_addr = 0x01020304;
    s = inet_ntoa(in);
    printf("%p\n", s);
    printf("%s\n", s);
    return 0;
}

it run as below:
0xfffffffffdcf7a70
[1]   Segmentation fault (core dumped) ./a.out

if I use #if 0,
it run correctly.
0x7f7ffdcf7a70
4.3.2.1

I know I included an incorrect .h file.
But I don't understand:
why inet_ntoa return a bad address?
on NetBSD i386, it always return a valid address. why not here?
Since it can return a bad address, how can I know if it is a bad or
good?
Or is it a bug?




Home | Main Index | Thread Index | Old Index