From ip@albatross.mcc.ac.uk  Thu Feb 21 04:11:37 2002
Return-Path: <ip@albatross.mcc.ac.uk>
Received: from probity.mcc.ac.uk (probity.mcc.ac.uk [130.88.200.94])
	by hub.freebsd.org (Postfix) with ESMTP id 38A5C37B404
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 21 Feb 2002 04:11:36 -0800 (PST)
Received: from albatross.mcc.ac.uk ([130.88.202.16])
	by probity.mcc.ac.uk with esmtp (Exim 2.05 #7)
	id 16ds4O-000H7p-00
	for FreeBSD-gnats-submit@freebsd.org; Thu, 21 Feb 2002 12:11:28 +0000
Received: (from ip@localhost)
	by albatross.mcc.ac.uk (8.11.6/8.11.6) id g1LCBRa44020;
	Thu, 21 Feb 2002 12:11:27 GMT
	(envelope-from ip)
Message-Id: <200202211211.g1LCBRa44020@albatross.mcc.ac.uk>
Date: Thu, 21 Feb 2002 12:11:27 GMT
From: Ian Pallfreeman <ip@mcc.ac.uk>
Reply-To: Ian Pallfreeman <ip@mcc.ac.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: elm-2.5.5_1: bounce command doesn't work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         35179
>Category:       ports
>Synopsis:       elm-2.5.5_1: bounce command doesn't work
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kris
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 21 04:20:01 PST 2002
>Closed-Date:    Sat May 10 22:00:24 PDT 2003
>Last-Modified:  Sat May 10 22:00:24 PDT 2003
>Originator:     Ian Pallfreeman
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
Manchester University, UK.
>Environment:
dark & chilly
System: FreeBSD albatross 4.5-STABLE FreeBSD 4.5-STABLE #4: Thu Feb 7 15:23:11 GMT 2002 ip@karma:/usr/src/sys/compile/ALBATROSS i386

>Description:

Using the 'b' (bounce) command, to remail a message, doesn't work in elm2.5.
This appears to be a consequence of:

kris        2001/07/23 20:01:26 PDT

  Modified files:
    mail/elm             Makefile 
  Added files:
    mail/elm/files       patch-mkstemp 
  Log:
  Fix insecure temporary file handling.
  
  Obtained from:        RedHat
  
  Revision  Changes    Path
  1.64      +2 -1      ports/mail/elm/Makefile

which ends up passing garbage to system(). The mail isn't sent, nor is it 
deleted from /tmp.

>How-To-Repeat:

Try bouncing a message from elm...

>Fix:

--- reply.c.ports	Thu Feb 21 12:06:09 2002
+++ reply.c	Thu Feb 21 12:07:36 2002
@@ -571,12 +571,12 @@
     
     FILE *mailfd;
     char entered[VERY_LONG_STRING], expanded[VERY_LONG_STRING];
-    char *filename, buffer[VERY_LONG_STRING], *msg;
+    char buffer[VERY_LONG_STRING], *msg;
     int  err,tmpfd;
     char tempfilename[255],*tmpdir;
-    filename = NULL;
     
     entered[0] = '\0';
+    tempfilename[0] = '\0';
 
     if (!get_to(entered, expanded, SM_ORIGINAL))
 	return FALSE;
@@ -608,29 +608,24 @@
     }
     if ((mailfd = fdopen(tmpfd, "w")) == NULL)
 	goto failed;
-    (void) elm_chown(filename, userid, groupid);
+    (void) elm_chown(tempfilename, userid, groupid);
 #ifdef MMDF
     if (strcmp(submitmail, mailer) == 0)
       do_mmdf_addresses(mailfd, expanded);
 #endif /* MMDF */
     copy_message(mailfd, curr_folder.curr_mssg, CM_REMOTE|CM_MMDF_HEAD|CM_REMAIL);
-    if (file_close(mailfd, filename) < 0)
+    if (file_close(mailfd, tempfilename) < 0)
 	goto failed;
 
-    build_mailer_command(buffer, filename,
+    build_mailer_command(buffer, tempfilename,
 	expanded, (char *)NULL, (char *)NULL);
     PutLine0(LINES, 0, catgets(elm_msg_cat, ElmSet, ElmResendingMail,
 	    "Resending mail..."));
     (void) system_call(buffer, 0);
     set_error(catgets(elm_msg_cat, ElmSet, ElmMailResent, "Mail resent."));
-    free((malloc_t)filename);
     return TRUE;
-
 failed:
-    if (filename != NULL) {
-	(void) unlink(filename);
-	free((malloc_t)filename);
-    }
+    (void) unlink(tempfilename);
     return TRUE;
 }
 
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports->kris 
Responsible-Changed-By: petef 
Responsible-Changed-When: Thu Feb 21 08:43:41 PST 2002 
Responsible-Changed-Why:  
Kris, could you take a look at this since patch-mkstemp seems 
to be causing the problem?  Thanks! 
. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35179 
State-Changed-From-To: open->closed 
State-Changed-By: kris 
State-Changed-When: Sat May 10 21:59:58 PDT 2003 
State-Changed-Why:  
This seems to have been fixed with the update to 2.5.6; 
thanks for the submission. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35179 
>Unformatted:
