Bug 11201 - Segmentation fault when use getifaddrs function
Summary: Segmentation fault when use getifaddrs function
Status: CLOSED NOTABUG
Alias: None
Product: Sisyphus
Classification: Development
Component: glibc (show other bugs)
Version: unstable
Hardware: all Linux
: P1 normal
Assignee: placeholder@altlinux.org
QA Contact: qa-sisyphus
URL: http://www.mail-archive.com/debian-gl...
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-23 19:29 MSK by Klimov Denis
Modified: 2007-09-19 04:55 MSD (History)
4 users (show)

See Also:


Attachments
prog for test bug (826 bytes, text/plain)
2007-03-23 19:32 MSK, Klimov Denis
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Klimov Denis 2007-03-23 19:29:15 MSK
This is my program, which demo bug in getifaddrs function:

/* TEST BUG PROGRAM
 *
 * Compile
 * gcc -o getifaddrs getifaddrs.c
 *
 * Testing
 * with up and down ppp* interfaces run ./getifaddrs
 *
 * Author: Klimov Denis aka zver
 * email: kliden <at> km.ru
 * 23/03/2007
 *
 * P.S. some problem info about this bug you may read
 * http://www.mail-archive.com/debian-glibc@lists.debian.org/msg32785.html
 */

#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>

int main()
{
struct ifaddrs *ifap = NULL;
int rez = getifaddrs(&ifap);
int st=1;
if (rez==0 && ifap!=NULL)
        {
        do
                {
                if (st==1)
                        st=0;
                        else
                        ifap=(*ifap).ifa_next;
                if (ifap->ifa_addr->sa_family == AF_INET)
                        {
                        printf("Interface name: %s \n",(*ifap).ifa_name);
                        }
                }
        while  ((*ifap).ifa_next!=NULL);
        }
return 0;
}

Actual Results:  
Segmentation fault when ppp* device up
List network device when _all_ ppp* device down

Expected Results:  
List network device always

some problem info about this bug you may read example at this page:
http://www.mail-archive.com/debian-glibc@lists.debian.org/msg32785.html
Comment 1 Klimov Denis 2007-03-23 19:32:23 MSK
Created attachment 1872 [details]
prog for test bug
Comment 2 Klimov Denis 2007-03-27 15:45:17 MSD
May be this help:
http://sources.redhat.com/ml/ecos-patches/2004-06/msg00015.html
Comment 3 Dmitry V. Levin 2007-09-19 04:55:55 MSD
ifa_addr references either the address of the interface or the link level
address of the interface, if one exists, otherwise it is NULL.

That is, your test case is bogus.