From d8c6d340380a0b3d41f219373bb08075f497f4c7 Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 12 Mar 2012 10:47:21 +0000 Subject: [PATCH] fix rrdcached crash as reported in debian bug #663505 -- Witold Baryluk git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4/program@2285 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_daemon.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 4dfe35c..f5ab6bb 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3093,7 +3093,17 @@ static int read_options (int argc, char **argv) /* {{{ */ { char journal_dir_actual[PATH_MAX]; const char *dir; - dir = journal_dir = strdup(realpath((const char *)optarg, journal_dir_actual)); + if (realpath((const char *)optarg, journal_dir_actual) == NULL) + { + fprintf(stderr, "Failed to canonicalize the journal directory '%s': %s\n", + optarg, rrd_strerror(errno)); + return 7; + } + dir = journal_dir = strdup(journal_dir_actual); + if (dir == NULL) { + fprintf (stderr, "read_options: strdup failed.\n"); + return (3); + } status = rrd_mkdir_p(dir, 0777); if (status != 0) -- 2.30.2