diff options
author | Leah Neukirchen <leah@vuxu.org> | 2021-08-07 19:33:08 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2021-08-07 19:33:08 +0200 |
commit | 4ccf2f08c1aa8b15f31ac469edebe6c4710d74f1 (patch) | |
tree | 76dcdb6a8245393ab4480e076ddf1ad006cbe124 /mmime.c | |
parent | 65d43e3cea10e40f65e9cd1b49ef1ddaed514a14 (diff) | |
download | mblaze-4ccf2f08c1aa8b15f31ac469edebe6c4710d74f1.tar.gz mblaze-4ccf2f08c1aa8b15f31ac469edebe6c4710d74f1.tar.xz mblaze-4ccf2f08c1aa8b15f31ac469edebe6c4710d74f1.zip |
mmime: ensure no empty parts are generated after an include.
Reported by lhynes.
Diffstat (limited to 'mmime.c')
-rw-r--r-- | mmime.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/mmime.c b/mmime.c index 7d47a20..f082cf0 100644 --- a/mmime.c +++ b/mmime.c @@ -423,6 +423,7 @@ gen_build() size_t linelen = 0; int inheader = 1; int intext = 0; + int emptybody = 1; int ret = 0; char *contenttype = 0; char *contenttransferenc = 0; @@ -430,12 +431,13 @@ gen_build() while (1) { ssize_t read = getdelim(&line, &linelen, '\n', stdin); if (read == -1) { - if (!intext && !rflag) + if (feof(stdin)) { + if (!emptybody) + break; line = strdup(inheader ? "\n" : ""); - else if (feof(stdin)) - break; - else + } else { // errored exit(1); + } } if (inheader) { if (line[0] == '\n') { @@ -476,6 +478,7 @@ gen_build() if (gen_file(f+1, line+1) != 0) ret = 1; intext = 0; + emptybody = 0; continue; } *f = of; @@ -496,6 +499,8 @@ gen_build() printf("%s", line); else gen_qp((uint8_t *)line, strlen(line), 78, 0); + + emptybody = 0; } if (!rflag && !inheader) printf("\n--%s--\n", sep); |