// configure:16975: checking for getaddrinfo // configure:17005: gcc -o conftest -O2 -I/usr/include -I/usr/pkg/include/db4 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/db4 -I/usr/pkg/include -L/usr/src/HEAD/pkgsrc/wip_cl/python25/work/Python-2.5.2 -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib conftest.c -lsocket -ldb4 >&5 // configure:17011: $? = 0 // configure:17018: result: yes // configure:17020: checking getaddrinfo bug // configure:17127: gcc -o conftest -O2 -I/usr/include -I/usr/pkg/include/db4 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/db4 -I/usr/pkg/include -L/usr/src/HEAD/pkgsrc/wip_cl/python25/work/Python-2.5.2 -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib conftest.c -lsocket -ldb4 >&5 // conftest.c: In function `main': // conftest.c:185: error: storage size of `hints' isn't known // conftest.c:191: error: `AI_PASSIVE' undeclared (first use in this function) // conftest.c:191: error: (Each undeclared identifier is reported only once // conftest.c:191: error: for each function it appears in.) // conftest.c:194: warning: passing arg 4 of `getaddrinfo' from incompatible pointer type // conftest.c:198: error: dereferencing pointer to incomplete type // conftest.c:199: error: dereferencing pointer to incomplete type // conftest.c:200: error: dereferencing pointer to incomplete type // conftest.c:201: error: dereferencing pointer to incomplete type // conftest.c:201: error: dereferencing pointer to incomplete type // conftest.c:203: error: `NI_NUMERICHOST' undeclared (first use in this function) // conftest.c:203: error: `NI_NUMERICSERV' undeclared (first use in this function) // conftest.c:206: error: dereferencing pointer to incomplete type // conftest.c:253: warning: passing arg 1 of `freeaddrinfo' from incompatible pointer type // conftest.c:258: warning: passing arg 1 of `freeaddrinfo' from incompatible pointer type // configure:17130: $? = 1 // configure: program exited with status 1 // configure: failed program was: // | /* confdefs.h. */ // | #define _GNU_SOURCE 1 // | #define _NETBSD_SOURCE 1 // | #define __BSD_VISIBLE 1 // | #define _BSD_TYPES 1 // | #define _XOPEN_SOURCE 600 // | #define _XOPEN_SOURCE_EXTENDED 1 // | #define _POSIX_C_SOURCE 200112L // | #define Py_ENABLE_SHARED 1 // | #define STDC_HEADERS 1 // | #define HAVE_SYS_TYPES_H 1 // | #define HAVE_SYS_STAT_H 1 // | #define HAVE_STDLIB_H 1 // | #define HAVE_STRING_H 1 // | #define HAVE_MEMORY_H 1 // | #define HAVE_STRINGS_H 1 // | #define HAVE_INTTYPES_H 1 // | #define HAVE_STDINT_H 1 // | #define HAVE_UNISTD_H 1 // | #define HAVE_CURSES_H 1 // | #define HAVE_DLFCN_H 1 // | #define HAVE_ERRNO_H 1 // | #define HAVE_FCNTL_H 1 // | #define HAVE_GRP_H 1 // | #define HAVE_LIBINTL_H 1 // | #define HAVE_NCURSES_H 1 // | #define HAVE_POLL_H 1 // | #define HAVE_PROCESS_H 1 // | #define HAVE_PTHREAD_H 1 // | #define HAVE_SHADOW_H 1 // | #define HAVE_SIGNAL_H 1 // | #define HAVE_STDINT_H 1 // | #define HAVE_TERMIOS_H 1 // | #define HAVE_UNISTD_H 1 // | #define HAVE_UTIME_H 1 // | #define HAVE_SYS_FILE_H 1 // | #define HAVE_SYS_MODEM_H 1 // | #define HAVE_SYS_PARAM_H 1 // | #define HAVE_SYS_POLL_H 1 // | #define HAVE_SYS_SELECT_H 1 // | #define HAVE_SYS_SOCKET_H 1 // | #define HAVE_SYS_STATVFS_H 1 // | #define HAVE_SYS_STAT_H 1 // | #define HAVE_SYS_TIME_H 1 // | #define HAVE_SYS_TIMES_H 1 // | #define HAVE_SYS_TYPES_H 1 // | #define HAVE_SYS_UN_H 1 // | #define HAVE_SYS_UTSNAME_H 1 // | #define HAVE_SYS_WAIT_H 1 // | #define HAVE_SYS_RESOURCE_H 1 // | #define HAVE_DIRENT_H 1 // | #define _LARGEFILE_SOURCE 1 // | #define _FILE_OFFSET_BITS 64 // | #if defined(SCO_DS) // | #undef _OFF_T // | #endif // | #define RETSIGTYPE void // | #define HAVE_SSIZE_T 1 // | #define SIZEOF_INT 4 // | #define SIZEOF_LONG 4 // | #define SIZEOF_VOID_P 4 // | #define SIZEOF_SHORT 2 // | #define SIZEOF_FLOAT 4 // | #define SIZEOF_DOUBLE 8 // | #define SIZEOF_FPOS_T 16 // | #define SIZEOF_SIZE_T 4 // | #define HAVE_LONG_LONG 1 // | #define SIZEOF_LONG_LONG 8 // | #define HAVE_UINTPTR_T 1 // | #define SIZEOF_UINTPTR_T 4 // | #define SIZEOF_OFF_T 8 // | #define HAVE_LARGEFILE_SUPPORT 1 // | #define SIZEOF_TIME_T 4 // | #define SIZEOF_PTHREAD_T 4 // | #define SHLIB_EXT ".so" // | #define WITH_LIBINTL 1 // | #define WITH_THREAD 1 // | #define _REENTRANT 1 // | #define PTHREAD_SYSTEM_SCHED_SUPPORTED 1 // | #define HAVE_PTHREAD_SIGMASK 1 // | #define WITH_DOC_STRINGS 1 // | #define WITH_PYMALLOC 1 // | #define HAVE_DLOPEN 1 // | #define HAVE_DYNAMIC_LOADING 1 // | #define HAVE_ALARM 1 // | #define HAVE_CHOWN 1 // | #define HAVE_CLOCK 1 // | #define HAVE_CONFSTR 1 // | #define HAVE_CTERMID 1 // | #define HAVE_EXECV 1 // | #define HAVE_FORK 1 // | #define HAVE_FPATHCONF 1 // | #define HAVE_FTIME 1 // | #define HAVE_FTRUNCATE 1 // | #define HAVE_GAI_STRERROR 1 // | #define HAVE_GETGROUPS 1 // | #define HAVE_GETLOGIN 1 // | #define HAVE_GETPEERNAME 1 // | #define HAVE_GETPGID 1 // | #define HAVE_GETPID 1 // | #define HAVE_GETPRIORITY 1 // | #define HAVE_GETPWENT 1 // | #define HAVE_GETSPNAM 1 // | #define HAVE_GETSPENT 1 // | #define HAVE_GETSID 1 // | #define HAVE_GETWD 1 // | #define HAVE_KILL 1 // | #define HAVE_KILLPG 1 // | #define HAVE_LCHOWN 1 // | #define HAVE_LSTAT 1 // | #define HAVE_MKFIFO 1 // | #define HAVE_MKNOD 1 // | #define HAVE_MKTIME 1 // | #define HAVE_NICE 1 // | #define HAVE_PATHCONF 1 // | #define HAVE_PAUSE 1 // | #define HAVE_POLL 1 // | #define HAVE_PUTENV 1 // | #define HAVE_READLINK 1 // | #define HAVE_REALPATH 1 // | #define HAVE_SELECT 1 // | #define HAVE_SETEGID 1 // | #define HAVE_SETEUID 1 // | #define HAVE_SETGID 1 // | #define HAVE_SETLOCALE 1 // | #define HAVE_SETREGID 1 // | #define HAVE_SETREUID 1 // | #define HAVE_SETSID 1 // | #define HAVE_SETPGID 1 // | #define HAVE_SETPGRP 1 // | #define HAVE_SETUID 1 // | #define HAVE_SETVBUF 1 // | #define HAVE_SNPRINTF 1 // | #define HAVE_SIGACTION 1 // | #define HAVE_STRFTIME 1 // | #define HAVE_SYSCONF 1 // | #define HAVE_TCGETPGRP 1 // | #define HAVE_TCSETPGRP 1 // | #define HAVE_TEMPNAM 1 // | #define HAVE_TIMES 1 // | #define HAVE_TMPFILE 1 // | #define HAVE_TMPNAM 1 // | #define HAVE_TRUNCATE 1 // | #define HAVE_UNAME 1 // | #define HAVE_UNSETENV 1 // | #define HAVE_UTIMES 1 // | #define HAVE_WAITPID 1 // | #define HAVE_WAIT3 1 // | #define HAVE_WAIT4 1 // | #define HAVE_WCSCOLL 1 // | #define HAVE_CHROOT 1 // | #define HAVE_LINK 1 // | #define HAVE_SYMLINK 1 // | #define HAVE_FCHDIR 1 // | #define HAVE_FSYNC 1 // | #define HAVE_FDATASYNC 1 // | #define HAVE_FLOCK 1 // | #define HAVE_ZLIB_COPY 1 // | #define HAVE_INET_PTON 1 // | #define HAVE_OPENPTY 1 // | #define HAVE_FORKPTY 1 // | #define HAVE_FSEEKO 1 // | #define HAVE_FSTATVFS 1 // | #define HAVE_FTELLO 1 // | #define HAVE_STATVFS 1 // | #define HAVE_DUP2 1 // | #define HAVE_GETCWD 1 // | #define HAVE_STRDUP 1 // | #define HAVE_STRERROR 1 // | #define HAVE_MEMMOVE 1 // | #define HAVE_GETPGRP 1 // | #define HAVE_SETPGRP 1 // | #define HAVE_GETTIMEOFDAY 1 // | /* end confdefs.h. */ // | // | #include // | #include // | #include // | #include // | #include // | // | main() // | { // | int passive, gaierr, inet4 = 0, inet6 = 0; // | struct addrinfo hints, *ai, *aitop; // | char straddr[INET6_ADDRSTRLEN], strport[16]; // | // | for (passive = 0; passive <= 1; passive++) { // | memset(&hints, 0, sizeof(hints)); // | hints.ai_family = AF_UNSPEC; // | hints.ai_flags = passive ? AI_PASSIVE : 0; // | hints.ai_socktype = SOCK_STREAM; // | hints.ai_protocol = IPPROTO_TCP; // | if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { // | (void)gai_strerror(gaierr); // | goto bad; // | } // | for (ai = aitop; ai; ai = ai->ai_next) { // | if (ai->ai_addr == NULL || // | ai->ai_addrlen == 0 || // | getnameinfo(ai->ai_addr, ai->ai_addrlen, // | straddr, sizeof(straddr), strport, sizeof(strport), // | NI_NUMERICHOST|NI_NUMERICSERV) != 0) { // | goto bad; // | } // | switch (ai->ai_family) { // | case AF_INET: // | if (strcmp(strport, "54321") != 0) { // | goto bad; // | } // | if (passive) { // | if (strcmp(straddr, "0.0.0.0") != 0) { // | goto bad; // | } // | } else { // | if (strcmp(straddr, "127.0.0.1") != 0) { // | goto bad; // | } // | } // | inet4++; // | break; // | case AF_INET6: // | if (strcmp(strport, "54321") != 0) { // | goto bad; // | } // | if (passive) { // | if (strcmp(straddr, "::") != 0) { // | goto bad; // | } // | } else { // | if (strcmp(straddr, "::1") != 0) { // | goto bad; // | } // | } // | inet6++; // | break; // | case AF_UNSPEC: // | goto bad; // | break; // | default: // | /* another family support? */ // | break; // | } // | } // | } // | // | if (!(inet4 == 0 || inet4 == 2)) // | goto bad; // | if (!(inet6 == 0 || inet6 == 2)) // | goto bad; // | // | if (aitop) // | freeaddrinfo(aitop); // | exit(0); // | // | bad: // | if (aitop) // | freeaddrinfo(aitop); // | exit(1); // | } // | // configure:17150: result: buggy // $ gcc -o conftest -O2 conftest.c -lsocket // conftest.c: In function `main': // conftest.c:304: error: storage size of `hints' isn't known // conftest.c:310: error: `AI_PASSIVE' undeclared (first use in this function) // conftest.c:310: error: (Each undeclared identifier is reported only once // conftest.c:310: error: for each function it appears in.) // conftest.c:313: warning: passing arg 4 of `getaddrinfo' from incompatible pointer type // conftest.c:317: error: dereferencing pointer to incomplete type // conftest.c:318: error: dereferencing pointer to incomplete type // conftest.c:319: error: dereferencing pointer to incomplete type // conftest.c:320: error: dereferencing pointer to incomplete type // conftest.c:320: error: dereferencing pointer to incomplete type // conftest.c:322: error: `NI_NUMERICHOST' undeclared (first use in this function) // conftest.c:322: error: `NI_NUMERICSERV' undeclared (first use in this function) // conftest.c:325: error: dereferencing pointer to incomplete type // conftest.c:372: warning: passing arg 1 of `freeaddrinfo' from incompatible pointer type // conftest.c:377: warning: passing arg 1 of `freeaddrinfo' from incompatible pointer type // gcc -o conftest -O2 conftest.c -lsocket #define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE_EXTENDED 1 #define _POSIX_C_SOURCE 200112L #include #include #include #include #include main() { int passive, gaierr, inet4 = 0, inet6 = 0; struct addrinfo hints, *ai, *aitop; char straddr[INET6_ADDRSTRLEN], strport[16]; for (passive = 0; passive <= 1; passive++) { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_flags = passive ? AI_PASSIVE : 0; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { (void)gai_strerror(gaierr); goto bad; } for (ai = aitop; ai; ai = ai->ai_next) { if (ai->ai_addr == NULL || ai->ai_addrlen == 0 || getnameinfo(ai->ai_addr, ai->ai_addrlen, straddr, sizeof(straddr), strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) { goto bad; } switch (ai->ai_family) { case AF_INET: if (strcmp(strport, "54321") != 0) { goto bad; } if (passive) { if (strcmp(straddr, "0.0.0.0") != 0) { goto bad; } } else { if (strcmp(straddr, "127.0.0.1") != 0) { goto bad; } } inet4++; break; case AF_INET6: if (strcmp(strport, "54321") != 0) { goto bad; } if (passive) { if (strcmp(straddr, "::") != 0) { goto bad; } } else { if (strcmp(straddr, "::1") != 0) { goto bad; } } inet6++; break; case AF_UNSPEC: goto bad; break; default: /* another family support? */ break; } } } if (!(inet4 == 0 || inet4 == 2)) goto bad; if (!(inet6 == 0 || inet6 == 2)) goto bad; if (aitop) freeaddrinfo(aitop); exit(0); bad: if (aitop) freeaddrinfo(aitop); exit(1); }