From: Dan Fandrich Date: Mon, 4 Feb 2013 23:02:17 +0000 (+0100) Subject: curl_xml plugin: Fix potential dereference of NULL pointer. X-Git-Tag: collectd-4.10.9~14 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b0c32ea6b670877e573913139f05d5c110e50861;p=collectd.git curl_xml plugin: Fix potential dereference of NULL pointer. I managed to get collectd to segfault in a couple of places while playing with it a bit. The first is in the curl_xml module when the XPATH expression doesn't quite match the input. The crash occurs on line 407 when instance_node->nodeTab[0] is dereferenced. At this point, all members of instance_node are 0, so dereferencing the array isn't a good idea. This patch fixes the problem, although I'm not sure if this particular case actually deserves its own error message. Signed-off-by: Florian Forster --- diff --git a/src/curl_xml.c b/src/curl_xml.c index da90d7c8..c22172a7 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -365,7 +365,7 @@ static int cx_handle_instance_xpath (xmlXPathContextPtr xpath_ctx, /* {{{ */ instance_node = instance_node_obj->nodesetval; tmp_size = (instance_node) ? instance_node->nodeNr : 0; - if ( (tmp_size == 0) && (is_table) ) + if (tmp_size <= 0) { WARNING ("curl_xml plugin: " "relative xpath expression for 'InstanceFrom' \"%s\" doesn't match "