[Linux-ha-dev] uninitialized string in heartbeat/findif.c

Pavol Gono palo.gono at gmail.com
Tue Feb 13 16:49:27 MST 2007


Hi

Configure script doesn't detect correct arguments for route command on debian.
#define ROUTEPARM "-n get"
e.g.
/sbin/route -n get 10.0.0.5
Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
       route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

       route {-h|--help} [<AF>]              Detailed usage syntax for
specified AF.
       route {-V|--version}                  Display version/author and exit.
...

This revealed bug of findif:

IPaddr.in:792
    NICINFO=`$IFCMD`
    rc=$?

    if [ $rc != 0 ]; then
        ocf_log err "$IFCMD failed [rc=$rc]."
        return $OCF_ERR_GENERIC
    fi

$IFCMD is command: /usr/lib/heartbeat/findif IP

findif.c:724
rc = (*sr) (address, &in, &addr_out, best_if, ...
The SearchUsingProcRoute() method failed because I had unplugged NIC cable.
SearchUsingRouteCmd(), line 270, there is declared string interface[].
The string "interface:" was not found in /sbin/route output, interface
string remained uninitialized.
On line 360
strncpy(best_if, interface, best_iflen);
the garbage was copied to best_if string, the SearchUsingRouteCmd()
returned zero and this garbage was first word of output of findif.

example of log:
IPaddr[3446]: [3470]: INFO: Using calculated nic for 127.9.2.82: _^H
IPaddr[3448]: [3473]: INFO: Using calculated nic for 127.9.2.83: _^H
IPaddr[3446]: [3482]: DEBUG: Using calculated netmask for 127.9.2.82:
255.255.255.255
IPaddr[3448]: [3487]: DEBUG: Using calculated netmask for 127.9.2.83:
255.255.255.255
IPaddr[3446]: [3488]: DEBUG: Using calculated broadcast for
127.9.2.82: 127.9.2.82
IPaddr[3448]: [3496]: DEBUG: Using calculated broadcast for
127.9.2.83: 127.9.2.83
IPaddr[3446]: [3524]: INFO: eval /sbin/ifconfig _^H:0 127.9.2.82
netmask 255.255.255.255 broadcast 127.9.2.82
lrmd: [3390]: info: RA output: (x_IPaddrL:start:stderr) SIOCSIFADDR:
No such device
IPaddr[3448]: [3535]: INFO: eval /sbin/ifconfig _^H:1 127.9.2.83
netmask 255.255.255.255 broadcast 127.9.2.83
lrmd: [3390]: info: RA output: (x_IPaddrL:start:stderr) _^H:0: ERROR
while getting interface flags: No such device


The attached patch worked fine for me.

IPaddr[8118]: [8137]: ERROR: /usr/local/lib/heartbeat/findif
127.9.2.83 failed [rc=1].
lrmd: [8057]: info: RA output: (x_IPaddrL:start:stderr) No interface found
IPaddr[8117]: [8139]: ERROR: /usr/local/lib/heartbeat/findif
127.9.2.82 failed [rc=1].


Palo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: findif_fix.diff
Type: text/x-diff
Size: 963 bytes
Desc: not available
Url : http://lists.community.tummy.com/pipermail/linux-ha-dev/attachments/20070214/30e76aea/findif_fix.bin


More information about the Linux-HA-Dev mailing list