From: David Yitzchak Cohen Date: Sat, 7 Feb 2004 21:36:41 +0000 (+0000) Subject: Looking at the code, the problem is pretty obvious. A recent patch X-Git-Tag: mutt-1-5-15-rel~223 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8680ffd233fe28632f90e91e60883a4903d00827;p=mutt Looking at the code, the problem is pretty obvious. A recent patch 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. --- diff --git a/init.c b/init.c index 80ef6ee7..db636b4a 100644 --- 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) { diff --git a/muttlib.c b/muttlib.c index 4d282c22..8370a3e8 100644 --- 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; }