diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2015-01-11 11:49:37 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2015-01-11 11:49:37 +0000 |
commit | 750d7f0b51f4826b7e6300902012232896522712 (patch) | |
tree | ddd488c22f69e5f99c2f517e2d48b692df962171 /usr.sbin/smtpd/delivery_filename.c | |
parent | a9b5be4c92fd13020f648e508b3c0a99965bb7f0 (diff) |
unbreak the delivery_filename backend, now that it no longer prepends the
From separator line but gets it injected in its iobuf by the mda process,
we need to make sure not to escape the first 'From ' we receive.
spotted by deraadt@
Diffstat (limited to 'usr.sbin/smtpd/delivery_filename.c')
-rw-r--r-- | usr.sbin/smtpd/delivery_filename.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/delivery_filename.c b/usr.sbin/smtpd/delivery_filename.c index ade9de88577..e5fb145b8fa 100644 --- a/usr.sbin/smtpd/delivery_filename.c +++ b/usr.sbin/smtpd/delivery_filename.c @@ -1,4 +1,4 @@ -/* $OpenBSD: delivery_filename.c,v 1.10 2015/01/05 21:00:36 gilles Exp $ */ +/* $OpenBSD: delivery_filename.c,v 1.11 2015/01/11 11:49:36 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -58,6 +58,7 @@ delivery_filename_open(struct deliver *deliver) char *ln; char *msg; int n; + int escape_from; #define error(m) { msg = m; goto err; } #define error2(m) { msg = m; goto err2; } @@ -73,11 +74,17 @@ delivery_filename_open(struct deliver *deliver) fp = fdopen(fd, "a"); if (fp == NULL) error("fdopen"); + + escape_from = 0; while ((ln = fgetln(stdin, &len)) != NULL) { if (ln[len - 1] == '\n') len--; - if (len >= 5 && memcmp(ln, "From ", 5) == 0) - putc('>', fp); + if (len >= 5 && memcmp(ln, "From ", 5) == 0) { + if (escape_from == 0) + escape_from = 1; + else + putc('>', fp); + } fprintf(fp, "%.*s\n", (int)len, ln); if (ferror(fp)) break; |