<<< Date Index >>>     <<< Thread Index >>>

Re: Segmentation fault from mutt-1.5.17 with SMTP



On 2008-11-10, Brendan Cully <brendan@xxxxxxxxxx> wrote:

> On Monday, 10 November 2008 at 09:01, Kyle Wheeler wrote:
> > On Monday, November 10 at 11:42 PM, quoth TAKAHASHI Tamotsu:
> >> This has already been fixed:
> >>
> >> 1970-01-01 00:00 +0000  Brendan Cully  <brendan@xxxxxxxxxx> (a2e8f6fab8d3)
> >>
> >>        * smtp.c: Test that envelope from or from is set before attempting
> >>        SMTP delivery. Closes #3079.
> >>
> >> Oh wait, since over 38 years ago?
> >
> > Oh, wait, nevermind. The fix is in there, I just didn't see it the first 
> > time.
> >
> > But I just noticed, shouldn't smtp.c have this patch:
> >
> > --- smtp.old    2008-11-10 08:58:39.000000000 -0600
> > +++ smtp.c      2008-11-10 08:59:20.000000000 -0600
> > @@ -242,8 +242,7 @@ mutt_smtp_send (const ADDRESS* from, con
> >      FREE (&AuthMechs);
> >       /* send the sender's address */
> > -    ret = snprintf (buf, sizeof (buf), "MAIL FROM:<%s>",
> > -                    EnvFrom ? EnvFrom->mailbox : from->mailbox);
> > +    ret = snprintf (buf, sizeof (buf), "MAIL FROM:<%s>", envfrom);
> >      if (eightbit && mutt_bit_isset (Capabilities, EIGHTBITMIME))
> >      {
> >        safe_strncat (buf, sizeof (buf), " BODY=8BITMIME", 15);
> >
> > It goes to all the trouble of setting envfrom, but then never uses it.

> oops. I'll fix that tonight.

I'm using the 1.5.17 source, which doesn't have 'envfrom', so I
don't know what that means for the problem I've been having.  I did
use gdb more this evening and looked at the code in the
ci_send_message() function in send.c.  The problem seems to be that
'killfrom' is set to 1 near the top of the function with the
expectation that its value and the value of 'msg->env->from' will be
(re)set correctly after the send-hooks are executed.  However,
send-hooks aren't executed in batch mode, so 'killfrom' is never
reset and hence 'msg->env->from' is deleted before the message is
sent.  I made the following change which seems to fix the problem.


--- send.c.prebatchbugfix       2008-11-03 17:56:22.328343000 -0800
+++ send.c      2008-11-10 20:00:13.703739000 -0800
@@ -1222,7 +1222,8 @@
   if (!msg->env->from && option (OPTUSEFROM) && !(flags & 
(SENDPOSTPONED|SENDRESEND)))
   {
     msg->env->from = mutt_default_from ();
-    killfrom = 1;      /* $use_from will be re-checked after send-hooks */
+    if (!(flags & SENDBATCH))
+      killfrom = 1;    /* $use_from will be re-checked after send-hooks */
   }
 
   if (flags & SENDBATCH) 


I will admit that I don't completely understand the relationships
among 'killfrom', option(OPTUSEFROM) and msg->env->from, or all the
implications of the various flags, so I may have missed something,
but I'm going to try this "fix" for a while and see what happens.

Regards,
Gary