Hide Forgot
Cloning from Fedora, because also seen with man-pages-3.22-12.el6.noarch +++ This bug was initially created as a clone of Bug #683038 +++ Description of problem: In the getifaddrs(3) manual page, there is an 'EXAMPLE' section which contains code demonstrating how to use the getifaddrs() API. This code is not robust and will crash depending on the host OS network configuration # gcc -g -o if if.c # gdb ./if (gdb) run Starting program: /home/berrange/if lo address family: 17 (AF_PACKET) wlan0 address family: 17 (AF_PACKET) virbr0 address family: 17 (AF_PACKET) virbr0-nic address family: 17 (AF_PACKET) Program received signal SIGSEGV, Segmentation fault. 0x00000000004006f7 in main (argc=1, argv=0x7fffffffe1e8) at if.c:25 25 family = ifa->ifa_addr->sa_family; (gdb) print ifa->ifa_addr $1 = (struct sockaddr *) 0x0 (gdb) print *ifa $2 = {ifa_next = 0x602088, ifa_name = 0x602074 "tun0", ifa_flags = 69841, ifa_addr = 0x0, ifa_netmask = 0x0, ifa_ifu = {ifu_broadaddr = 0x0, ifu_dstaddr = 0x0}, ifa_data = 0x6027b8} This bit of the example code: /* Walk through linked list, maintaining head pointer so we can free list later */ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { family = ifa->ifa_addr->sa_family; Should be changed to /* Walk through linked list, maintaining head pointer so we can free list later */ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { family = ifa->ifa_addr ? ifa->ifa_addr->sa_family : AF_UNSPEC; ie, allow for ifa->ifa_addr being possibly NULL Version-Release number of selected component (if applicable): man-pages-3.25-1.fc14.noarch glibc-2.13-1.x86_64 How reproducible: Only if 'ifconfig -a' shows an interface with "Link encap:UNSPEC", eg tun0 from a VPNC connection Steps to Reproduce: 1. Start VPNC client 2. Run getifaddrs() example program 3. Actual results: $ ./if lo address family: 17 (AF_PACKET) wlan0 address family: 17 (AF_PACKET) virbr0 address family: 17 (AF_PACKET) virbr0-nic address family: 17 (AF_PACKET) Segmentation fault Expected results: $ ./if lo address family: 17 (AF_PACKET) wlan0 address family: 17 (AF_PACKET) virbr0 address family: 17 (AF_PACKET) virbr0-nic address family: 17 (AF_PACKET) tun0 address family: 0 eth0 address family: 17 (AF_PACKET) lo address family: 2 (AF_INET) address: <127.0.0.1> wlan0 address family: 2 (AF_INET) address: <192....> virbr0 address family: 2 (AF_INET) address: <192.....> tun0 address family: 2 (AF_INET) address: <10.....> lo address family: 10 (AF_INET6) address: <::1> wlan0 address family: 10 (AF_INET6) address: <2a01:....> wlan0 address family: 10 (AF_INET6) address: <fe80:....> Additional info:
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0679.html