From f53ae6a06f483821459431ff37fdfa310a5186de Mon Sep 17 00:00:00 2001 From: gilles Date: Sun, 11 Jan 2015 11:49:36 +0000 Subject: [PATCH] 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@ --- usr.sbin/smtpd/delivery_filename.c | 13 ++++++++++--- 1 file 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 @@ -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; -- 2.20.1