X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_client.c;h=0d2128387a8ed7633ca3125fb5a9b2d0d571f29f;hb=bbee4e31db966702d6fa3d7f4907b14aa1cb5aba;hp=b895237c52410598f0f03b1b77b8143fa0879663;hpb=252efcd3f319d99dbf700aa4d53da8945dc8725f;p=rrdtool.git diff --git a/src/rrd_client.c b/src/rrd_client.c index b895237..0d21283 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -73,30 +73,31 @@ 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; - if (*path == '/') /* absolute path */ + if (is_unix) { - if (! is_unix) - { - rrd_set_error ("absolute path names not allowed when talking " - "to a remote daemon"); - return (NULL); - } - /* else: nothing to do */ + ret = realpath(path, resolved_path); + if (ret == NULL) + rrd_set_error("realpath(%s): %s", path, rrd_strerror(errno)); + return ret; } - else /* relative path */ + else { - if (is_unix) + if (*path == '/') /* not absolute path */ { - realpath (path, resolved_path); - ret = resolved_path; + rrd_set_error ("absolute path names not allowed when talking " + "to a remote daemon"); + return NULL; } - /* else: nothing to do */ } - return (ret); + + return path; } /* }}} char *get_path */ static size_t strsplit (char *string, char **fields, size_t size) /* {{{ */ @@ -830,7 +831,7 @@ int rrdc_fetch (const char *filename, /* {{{ */ size_t buffer_size; rrdc_response_t *res; char path_buffer[PATH_MAX]; - char *path_ptr; + const char *path_ptr; char *str_tmp; unsigned long flush_version;