From 5fd88a20936bd028a500df91b06d14f61b7a2d76 Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 26 Apr 2010 12:38:11 +0000 Subject: [PATCH] When specifying a relative path (-j option) rrd_cached would segfault when trying to read past journals (journal_init function). Added an extra check to journal_init before reading the directory, and, when parsing the command line options, to expand the relative path to an absolute path. -- Adrian-Ioan Vasile yoyo@opennet.ro git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2072 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_daemon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index 58b07049..3697a4ae 100644 --- a/program/src/rrd_daemon.c +++ b/program/src/rrd_daemon.c @@ -2111,6 +2111,10 @@ static void journal_init(void) /* {{{ */ } dir = opendir(journal_dir); + if (!dir) { + RRDD_LOG(LOG_CRIT, "journal_init: opendir(%s) failed\n", journal_dir); + return; + } while ((dent = readdir(dir)) != NULL) { /* looks like a journal file? */ @@ -3062,7 +3066,9 @@ static int read_options (int argc, char **argv) /* {{{ */ case 'j': { - const char *dir = journal_dir = strdup(optarg); + char journal_dir_actual[PATH_MAX]; + const char *dir; + dir = journal_dir = strdup(realpath((const char *)optarg, journal_dir_actual)); status = rrd_mkdir_p(dir, 0777); if (status != 0) -- 2.30.2