X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/bc4927948a1b01bf2ae8b952dfd2639c1f929f00..9322ba2854211794c27fae9468768b80b767c211:/uip/mhparse.c diff --git a/uip/mhparse.c b/uip/mhparse.c index 42566aaa..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; @@ -662,7 +670,7 @@ get_ctinfo (char *cp, CT ct, int magic) TYPE_FIELD, ct->c_file); return NOTOK; } - ToLower(ci->ci_type); + to_lower(ci->ci_type); while (isspace ((unsigned char) *cp)) cp++; @@ -697,7 +705,7 @@ get_ctinfo (char *cp, CT ct, int magic) TYPE_FIELD, ct->c_file, ci->ci_type); return NOTOK; } - ToLower(ci->ci_subtype); + to_lower(ci->ci_subtype); magic_skip: while (isspace ((unsigned char) *cp)) @@ -960,7 +968,7 @@ invalid: case '(': i++; - /* and fall... */ + /* FALLTHRU */ default: *bp++ = c; continue; @@ -1531,7 +1539,7 @@ no_body: case CT_MESSAGE: if (p->c_subtype != MESSAGE_RFC822) break; - /* else fall... */ + /* FALLTHRU */ default: e->eb_partno = ct->c_partno; if (p->c_ctinitfnx) @@ -3479,7 +3487,7 @@ bad_quote: case '\\': if (*++cp == '\0') goto bad_quote; - /* FALL THROUGH */ + /* FALLTHRU */ default: len++; continue; @@ -3931,7 +3939,7 @@ param_len(PM pm, int index, size_t valueoff, int *encode, int *cont, case '\\': len++; maxfit--; - /* FALL THROUGH */ + /* FALLTHRU */ default: len++; maxfit--; @@ -4039,6 +4047,7 @@ normal_param(PM pm, char *output, size_t len, size_t valuelen, case '"': *output++ = '\\'; outlen++; + /* FALLTHRU */ default: *output++ = *p++; outlen++; @@ -4228,17 +4237,13 @@ noiconv: #endif /* HAVE_ICONV */ /* - * Take everything non-ASCII and substituite the replacement character + * Take everything non-ASCII and substitute the replacement character */ q = buffer; bufsize = sizeof(buffer); for (p = pm->pm_value; *p != '\0' && bufsize > 1; p++, q++, bufsize--) { - /* FIXME: !iscntrl should perhaps be isprint as that allows all - * classes bar cntrl, whereas the cntrl class can include those - * in space and blank. - * http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html */ - if (isascii((unsigned char) *p) && !iscntrl((unsigned char) *p)) + if (isascii((unsigned char) *p) && isprint((unsigned char) *p)) *q = *p; else *q = replace;