From b0c32ea6b670877e573913139f05d5c110e50861 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 5 Feb 2013 00:02:17 +0100 Subject: [PATCH] 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 --- src/curl_xml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 " -- 2.30.2