From e198e3beff0d2dbf4ffaf5a78f9d87bccfeebb7a Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 30 Jun 2010 12:48:47 +0000 Subject: [PATCH] src/rrd_client.c: Fix a potential segmentation fault in "get_path". The "get_path" function is called at least from "rrdc_update" without checking for a connection first. In that case the "sd_path" pointer may be NULL, so dereferencing it without checking for NULL is not good behavior. This patch checks all arguments of the "get_path" function and returns an error if any pointer is NULL. -- Florian Forster git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2094 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_client.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/program/src/rrd_client.c b/program/src/rrd_client.c index 18dd0dde..187afb22 100644 --- a/program/src/rrd_client.c +++ b/program/src/rrd_client.c @@ -73,6 +73,9 @@ static const char *get_path (const char *path, char *resolved_path) /* {{{ */ const char *ret = path; int is_unix = 0; + if ((path == NULL) || (resolved_path == NULL) || (sd_path == NULL)) + return (NULL); + if ((*sd_path == '/') || (strncmp ("unix:", sd_path, strlen ("unix:")) == 0)) is_unix = 1; -- 2.30.2