In some configurations (no *message-id-disable*, no *from*, no
*hostname* and such, and no *stealthmua*), when resend-/Resending
a message, no Resent-Message-Id: would have been generated but
instead two Resent-Date: fields.

The attached patch is also on [master].
(Shall more bugs appear in the following months there may be
another subminor release.)
Ciao,

--steffen
commit 21b92186bd892f4ae1f42f14f2e9c746be33a15d (refs/heads/master)
Author: Steffen (Daode) Nurpmeso <[email protected]>
Date:   2014-08-08 13:50:55 +0200

    Fix Resent-Message-Id: code path (for some configuration)..
    
    We leave generation of the Message-Id: up to the sending MTA if we
    can't find any of the information sources we need to generate our
    Message-Id:.
    The resend code path however wrote "Resent-" anyway, regardless of
    wether we'd generate a Message-Id: or not, there possibly turning
    the following Date: into a Resent-Date:, so that we effectively
    could end up with two Resent-Date: fields.
---
 sendout.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/sendout.c b/sendout.c
index 9b3658c..8bc6b8f 100644
--- a/sendout.c
+++ b/sendout.c
@@ -106,7 +106,7 @@ static bool_t        start_mta(struct sendbundle *sbp);
 static bool_t        mightrecord(FILE *fp, struct name *to);
 
 /* Create a Message-Id: header field.  Use either host name or from address */
-static void          _message_id(FILE *fo, struct header *hp);
+static char *        _message_id(struct header *hp);
 
 /* Format the given header line to not exceed 72 characters */
 static int           fmt(char const *str, struct name *np, FILE *fo, int comma,
@@ -1070,9 +1070,10 @@ jbail:
    return rv;
 }
 
-static void
-_message_id(FILE *fo, struct header *hp)
+static char *
+_message_id(struct header *hp)
 {
+   char *rv = NULL;
    char const *h;
    size_t rl;
    struct tm *tmp;
@@ -1092,13 +1093,16 @@ _message_id(FILE *fo, struct header *hp)
       goto jleave;
 
    tmp = &time_current.tc_gm;
-   fprintf(fo, "Message-ID: <%04d%02d%02d%02d%02d%02d.%s%c%s>\n",
+   rv = salloc(sizeof("Message-ID: <%04d%02d%02d%02d%02d%02d.%s%c%s>")-1 +
+         rl + strlen(h) +1);
+   snprintf(rv, UI32_MAX, "Message-ID: <%04d%02d%02d%02d%02d%02d.%s%c%s>",
       tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
       tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
       getrandstring(rl), (rl == 8 ? '%' : '@'), h);
 jleave:
    __sendout_ident = NULL;
    NYD_LEAVE;
+   return rv;
 }
 
 static int
@@ -1190,6 +1194,7 @@ infix_resend(FILE *fi, FILE *fo, struct message *mp, struct name *to,
                &fromfield))
             goto jleave;
       }
+      /* TODO RFC 5322: Resent-Sender SHOULD NOT be used if it's EQ -From: */
       if ((cp = ok_vlook(sender)) != NULL) {
          if (_putname(cp, GCOMMA, SEND_MBOX, NULL, "Resent-Sender:", fo,
                &senderfield))
@@ -1197,10 +1202,9 @@ infix_resend(FILE *fi, FILE *fo, struct message *mp, struct name *to,
       }
       if (fmt("Resent-To:", to, fo, 1, 1, 0))
          goto jleave;
-      if ((cp = ok_vlook(stealthmua)) == NULL || !strcmp(cp, "noagent")) {
-         fputs("Resent-", fo);
-         _message_id(fo, NULL);
-      }
+      if (((cp = ok_vlook(stealthmua)) == NULL || !strcmp(cp, "noagent")) &&
+            (cp = _message_id(NULL)) != NULL)
+         fprintf(fo, "Resent-%s\n", cp);
    }
 
    if ((mdn = UNCONST(check_from_and_sender(fromfield, senderfield))) == NULL)
@@ -1624,8 +1628,11 @@ do {\
    if (ok_blook(bsdcompat) || ok_blook(bsdorder))
       FMT_CC_AND_BCC();
 
-   if ((w & GMSGID) && stealthmua <= 0)
-      _message_id(fo, hp), ++gotcha;
+   if ((w & GMSGID) && stealthmua <= 0 && (addr = _message_id(hp)) != NULL) {
+      fputs(addr, fo);
+      fputc('\n', fo);
+      ++gotcha;
+   }
 
    if ((np = hp->h_ref) != NULL && (w & GREF)) {
       fmt("References:", np, fo, 0, 1, 0);
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
S-nail-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/s-nail-users

Reply via email to