Bug 108956

Summary: lokkit does not handle > 10 interfaces
Product: Red Hat Enterprise Linux 2.1 Reporter: Rick Beldin <rick.beldin>
Component: gnome-lokkitAssignee: Bill Nottingham <notting>
Status: CLOSED DUPLICATE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.1CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-02-21 18:59:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rick Beldin 2003-11-03 19:18:21 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5)
Gecko/20031007

Description of problem:

This defect appears to Redhat specific since it refers to the
/usr/sbin/lokkit command. 

/usr/sbin/lokkit will not correctly interpret the interfaces if there
are more than 10 configured interfaces.  The symptom is that lokkit
will appear to hang. 

No curses displays were displayed at all.   strace logs showed that we
got as far as an open() on /etc/sysconfig/network-scripts and that was it.
    
When I downloaded source for that revision, I found where I think
the problem is occurring:

char **getNetworkDevices(int *len) {
        int num = 0;
        DIR *dir;
        char **ret = malloc(20*sizeof(char *));
        struct dirent *dent;

        dir = opendir("/etc/sysconfig/network-scripts");
        if (dir) {
                while ((dent = readdir(dir))) {
                        if (!strncmp(dent->d_name,"ifcfg-",6) &&
                            !strstr(dent->d_name,":") &&
                            strcmp(dent->d_name,"ifcfg-lo")) {
                                if (num > 20)

                                  ret = realloc(ret, num+1 *
sizeof(char *));
                                ret[num] = strdup(dent->d_name+6);
                                num++;
                        }
                }
                closedir(dir);
        }
        *len = num;
        if (ret) {
                qsort((void *)ret, num, sizeof(char *),
                      (int (*)(const void *, const void *))strcmp);
        }
        return ret;
} 

Reducing the number of interfaces allows the program to run normally. 


I wrote to Alan Cox (maintainer) and his reply was: 

>> 	software.  I recently was working a case with a customer who
>> 	experienced a strange problem with /usr/sbin/lokkit, from the
>> 	lokkit-0.50-6 package.

That should go in Red Hat bugzilla I think

>>                                  if (num > 20)
>> 
>>                                    ret = realloc(ret, num+1 *
sizeof(char *));


Thats the bug - it should be (num + 1) * sizeof(char *). The bracket
is rather important. Fixing that ought to fix your customer problem
but please file it and my suggested fix comment in Red Hat bugzilla
(the code in question isnt in the non Red Hat lokkit version)

Thanks

Alan



Version-Release number of selected component (if applicable):
lokkit-0.50-6

How reproducible:
Always

Steps to Reproduce:
1. Configure /etc/sysconfig/network-scripts to have > 10 ethernet devices
2. /usr/sbin/lokkit 
3.
    

Actual Results:  lokkit appears to hang.  We never get to curses screen. 

If you run strace on it, the last system call appears to be an open()
of /etc/sysconfig/network-scripts followed by a getdents() call: 

open("/etc/sysconfig/network-scripts",
O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3
SYS_1212(0x3, 0x60000fffffffb300, 0x1f8, 0x2000000000304c80,
0xc000000000000309, 
0, 0x40000000000070f0, 0x10800) = 0

Expected Results:  /usr/sbin/lokkit should have brought up a screen to
allow you to configure your firewall. 

Additional info:

Comment 1 Bill Nottingham 2003-11-03 20:41:35 UTC

*** This bug has been marked as a duplicate of 88533 ***

Comment 2 Red Hat Bugzilla 2006-02-21 18:59:41 UTC
Changed to 'CLOSED' state since 'RESOLVED' has been deprecated.