From 4318012376e06229307c0ed4f62a00faae9edc63 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sat, 18 Mar 2017 09:49:31 -0400 Subject: [PATCH] Don't let parse_mime() try to parse a directory. --- uip/mhparse.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/uip/mhparse.c b/uip/mhparse.c index 5db4efed..a2dcb88c 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -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; -- 2.56.0