Hi,

problem is in incorrect error handling.

Attached patch adds realpath and strdup error handling for journal dir
option.

Why journal dir was not created in first place, is different story
(probably bug in postinst script)

Regards,
Witek

-- 
Witold Baryluk
--- rrdtool-1.4.7/src/rrd_daemon.c.orig	2011-12-16 08:29:44.000000000 +0100
+++ rrdtool-1.4.7/src/rrd_daemon.c	2012-03-12 06:05:51.000000000 +0100
@@ -3091,7 +3091,17 @@
       {
         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)

Reply via email to