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) /* {{{ */
ret->lines_num = 0;
buffer_ptr = fgets (buffer, sizeof (buffer), sh);
- if (buffer_ptr == NULL)
+ if (buffer_ptr == NULL) {
+ close_connection();
return (-3);
+ }
chomp (buffer);
ret->status = strtol (buffer, &ret->message, 0);
if (buffer == ret->message)
{
response_free (ret);
+ close_connection();
return (-4);
}
/* Skip leading whitespace of the status message */
if (ret->lines == NULL)
{
response_free (ret);
+ close_connection();
return (-5);
}
memset (ret->lines, 0, sizeof (char *) * ret->status);
if (buffer_ptr == NULL)
{
response_free (ret);
+ close_connection();
return (-6);
}
chomp (buffer);
if (ret->lines[i] == NULL)
{
response_free (ret);
+ close_connection();
return (-7);
}
}
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;