]> diplodocus.org Git - nmh/commitdiff
Don't let parse_mime() try to parse a directory.
authorDavid Levine <levinedl@acm.org>
Sat, 18 Mar 2017 13:49:31 +0000 (09:49 -0400)
committerDavid Levine <levinedl@acm.org>
Sat, 18 Mar 2017 13:49:31 +0000 (09:49 -0400)
uip/mhparse.c

index 5db4efe..a2dcb88 100644 (file)
@@ -209,6 +209,7 @@ parse_mime (char *file)
     FILE *fp;
     CT ct;
     size_t n;
+    struct stat statbuf;
 
     bogus_mp_content = 0;
 
@@ -244,6 +245,13 @@ parse_mime (char *file)
            return NULL;
        }
        fseek (fp, 0L, SEEK_SET);
+    } else if (lstat (file, &statbuf) == NOTOK) {
+       advise (file, "unable to lstat");
+       return NULL;
+    } else if (S_ISDIR(statbuf.st_mode)) {
+       /* Don't try to parse a directory. */
+       advise (NULL, "%s is a directory", file);
+       return NULL;
     } else if ((fp = fopen (file, "r")) == NULL) {
        advise (file, "unable to read");
        return NULL;