[Xymon] [Patch] xymond_rrd crash when parsing Linux ifconfig data

Jurgen Claessens Jurgen.Claessens at cegeka.com
Fri Feb 22 13:53:29 CET 2019


Hello,

When I try to apply this patch to a clean install, I get a bunch of compilation errors.
I'm not familiar at all with C programming.
Sounds to me there is something wrong with how the data is being transferred.

In file included from do_rrd.c:641:0:
rrd/do_netstat.c: In function ‘handle_pcre_netstat’:
rrd/do_netstat.c:88:5: warning: passing argument 4 of ‘pickdata’ makes integer from pointer without a cast [enabled by default]
     if (pickdata(datapart, pcreset[0],  0, &tcpretranspackets, &tcpretransbytes)   ||
     ^
In file included from /home/mms/xymon-4.3.28/include/libxymon.h:85:0,
                 from do_rrd.c:28:
/home/mms/xymon-4.3.28/include/../lib/matching.h:34:12: note: expected ‘int’ but argument is of type ‘char **’
 extern int pickdata(char *buf, pcre *expr, int dupok, int num_args, ...);
            ^
In file included from do_rrd.c:641:0:
rrd/do_netstat.c:89:9: warning: passing argument 4 of ‘pickdata’ makes integer from pointer without a cast [enabled by default]
         pickdata(datapart, pcreset[1],  0, &tcpoutdatapackets, &tcpoutdatabytes)   ||
         ^
Etc etc.


Met vriendelijke groeten/Meilleures salutations/Best regards

Jurgen Claessens
-----Original Message-----
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Steve Hill
Sent: dinsdag 27 februari 2018 13:29
To: xymon at xymon.com
Subject: [Xymon] [Patch] xymond_rrd crash when parsing Linux ifconfig data


This patch addresses two problems:

1. For Linux clients, do_ifstat_rrd parses the ifconfig output using the
regex:
	([a-z0-9]+(_[0-9]+)?:*|lo:?)\s
pickdata() is called like this:
	pickdata(bol, ifstat_linux_pcres[0], 1, &ifname)

With a network interface name such as "foo1", the regex produces 2 results:
	0: "foo1 "
	1: "foo1"
pickdata() discards result 0 and assigns result 1 ("foo1") to the ifname parameter as expected.

With a network interface name such as "foo_1", the regex produces 3 results:
	0: "foo_1 "
	1: "foo_1"
	2: "_1"
pickdata() discards result 0, assigns result 1 ("foo_1") to the ifname parameter and then tries to assign result 2 ("_1") to the next parameter in the variable argument list.  Since there it no such parameter, this results in a segmentation fault and xymond_rrd crashes.

The attached patch adds a "num_args" parameter to pickdata() to tell it how many arguments are in the variable argument list and ensure it never rolls off the end of that list.


2. I have some clients with network interface names in the form "foo.5", "foo_bar" and "foo-bar" ("eth0.5" is especially common when eth0 is carrying an 802.1q trunk, for example).  Xymon does not collect statistics on those network interfaces because they don't match the regex.  This patch relaxes the regex a bit so that it matches these network interfaces.

--
  - Steve Hill
    Technical Director
    Opendium    Online Safety / Web Filtering    http://www.opendium.com

    Enquiries:  sales at opendium.com      +44-1792-824568
    Support:    support at opendium.com    +44-1792-825748


    Opendium Limited is a company registered in England and Wales.
    Company No. 5465437
    Highfield House, 1 Brue Close, Bruton, Somerset, BA10 0HY, England.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3854 bytes
Desc: not available
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20190222/75cc1a3c/attachment.bin>


More information about the Xymon mailing list