From c7733272ab55ccd776f3d409521d166e478adfab Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 28 Jan 2020 01:50:15 -0500 Subject: Limit subject to 7-bit 78 characters Since file names are unlikely to be 8-bit and long, taking the easy way out. Otherwise it should be encoded according to . --- notemap.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/notemap.c b/notemap.c index 35dba0c..f1ebf5a 100644 --- a/notemap.c +++ b/notemap.c @@ -217,6 +217,12 @@ static void append( localtime(&status.st_mtime) ); + char subj[78 - (sizeof("Subject: ") - 1)] = {0}; + for (size_t i = 0; i < sizeof(subj) - 1; ++i) { + if (!path[i]) break; + subj[i] = (path[i] & 0x80 ? '?' : path[i]); + } + #define HEADERS \ "From: <%s>\r\n" \ "Subject: %s\r\n" \ @@ -231,7 +237,7 @@ static void append( size_t max = sizeof(HEADERS) + strlen(from) - + strlen(path) + + strlen(subj) + strlen(date) + strlen(uuid) + 3 * status.st_size @@ -241,7 +247,7 @@ static void append( FILE *msg = fmemopen(buf, max, "w"); if (!msg) err(EX_OSERR, "fmemopen"); - fprintf(msg, HEADERS, from, path, date, uuid); + fprintf(msg, HEADERS, from, subj, date, uuid); #undef HEADERS int ch; -- cgit 1.4.1