From: oetiker Date: Mon, 12 Mar 2012 10:47:21 +0000 (+0000) Subject: fix rrdcached crash as reported in debian bug #663505 -- Witold Baryluk X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4752619253352bd2336165a8206279121dbf98ce;p=rrdtool-all.git fix rrdcached crash as reported in debian bug #663505 -- Witold Baryluk git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.4@2285 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index 4dfe35c2..f5ab6bbb 100644 --- a/program/src/rrd_daemon.c +++ b/program/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)