[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] mhshow -file /tmp (!)
From: |
David Levine |
Subject: |
Re: [Nmh-workers] mhshow -file /tmp (!) |
Date: |
Sat, 18 Mar 2017 09:14:56 -0400 |
Ken wrote:
> maybe the "right" fix is to properly bubble up read errors from m_getfld()?
I agree, and would be willing to visit that after 1.7. I think that all callers
should be able to handle the error, but I'm not certain.
In the meantime, how about the fix below to parse_mime()? That should be done
in any case, because parse_mime() really expects a file.
David
index 5db4efe..bd2b16c 100644
--- a/uip/mhparse.c
+++ b/uip/mhparse.c
@@ -211,0 +212 @@ parse_mime (char *file)
+ struct stat statbuf;
@@ -247,3 +248,12 @@ parse_mime (char *file)
- } else if ((fp = fopen (file, "r")) == NULL) {
- advise (file, "unable to read");
- return NULL;
+ } else {
+ /* Don't try to parse a directory. */
+ if (lstat (file, &statbuf) == NOTOK) {
+ advise (file, "unable to lstat");
+ return NULL;
+ } else if (S_ISDIR(statbuf.st_mode)) {
+ advise (NULL, "%s is a directory", file);
+ return NULL;
+ } else if ((fp = fopen (file, "r")) == NULL) {
+ advise (file, "unable to read");
+ return NULL;
+ }
Re: [Nmh-workers] mhshow -file /tmp (!), Robert Elz, 2017/03/17