]> granicus.if.org Git - mutt/commitdiff
Looking at the code, the problem is pretty obvious. A recent patch
authorDavid Yitzchak Cohen <lists+mutt_devs@bigfatdave.com>
Sat, 7 Feb 2004 21:36:41 +0000 (21:36 +0000)
committerDavid Yitzchak Cohen <lists+mutt_devs@bigfatdave.com>
Sat, 7 Feb 2004 21:36:41 +0000 (21:36 +0000)
to init.c (the one that was supposed to prevent Mutt from silently
failing to read nonexistant RC files, IIRC) changed source_rc() to
stat(2) the RC "file" before trying to mutt_open_read() it.  There's
only one problem here: source_rc() has no way of knowing whether or
not its "file" is a file or a command.  I'm attaching a patch that
fixes the problem in what I believe is the right way.

init.c
muttlib.c

diff --git a/init.c b/init.c
index 80ef6ee71c5b3ba90858628c65b3b482e0712ec6..db636b4a9631b993ad6e8af4fbb43b51906965de 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1368,18 +1368,6 @@ static int source_rc (const char *rcfile, BUFFER *err)
   char *linebuf = NULL;
   size_t buflen;
   pid_t pid;
-  struct stat s;
-
-  if (stat (rcfile, &s) < 0)
-  {
-    snprintf (err->data, err->dsize, _("%s: stat: %s"), rcfile, strerror (errno));
-    return (-1);
-  }
-  if (!S_ISREG (s.st_mode))
-  {
-    snprintf (err->data, err->dsize, _("%s: not a regular file"), rcfile);
-    return (-1);
-  }
 
   if ((f = mutt_open_read (rcfile, &pid)) == NULL)
   {
index 4d282c22847b3cb9eef11c14f85499f36c575f5b..8370a3e86513e8b8be6e9a3e68c52860db8130f1 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -1134,6 +1134,8 @@ void mutt_FormatString (char *dest,               /* output buffer */
 FILE *mutt_open_read (const char *path, pid_t *thepid)
 {
   FILE *f;
+  struct stat s;
+
   int len = mutt_strlen (path);
 
   if (path[len - 1] == '|')
@@ -1149,6 +1151,16 @@ FILE *mutt_open_read (const char *path, pid_t *thepid)
   }
   else
   {
+    if (stat (path, &s) < 0)
+    {
+      mutt_error (_("%s: stat: %s"), path, strerror (errno));
+      return (NULL);
+    }
+    if (!S_ISREG (s.st_mode))
+    {
+      mutt_error (_("%s: not a regular file"), path);
+      return (NULL);
+    }
     f = fopen (path, "r");
     *thepid = -1;
   }