From: gilles Date: Sun, 11 Jan 2015 11:49:36 +0000 (+0000) Subject: unbreak the delivery_filename backend, now that it no longer prepends the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f53ae6a06f483821459431ff37fdfa310a5186de;p=openbsd 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@ --- 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;