From malcolm.kay@ies.sa.com.au  Tue Feb 24 16:23:21 2004
Return-Path: <malcolm.kay@ies.sa.com.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 75C9616A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 24 Feb 2004 16:23:21 -0800 (PST)
Received: from ies.ct (mail.ies.sa.com.au [203.28.4.119])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 205AF43D31
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 24 Feb 2004 16:23:15 -0800 (PST)
	(envelope-from malcolm.kay@ies.sa.com.au)
Received: from QuoVadis.design (QuoVadis [192.168.10.215])
	by ies.ct (8.12.1/8.12.1) with ESMTP id i1P0NAH5089270
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 25 Feb 2004 10:53:11 +1030 (CST)
Message-Id: <200402251053.10047.malcolm.kay@ies.sa.com.au>
Date: Wed, 25 Feb 2004 10:53:10 +1030
From: Malcolm Kay <malcolm.kay@ies.sa.com.au>
Reply-To: Malcolm Kay <malcolm.kay@internode.on.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: port mail/smtpclient: smtpclient -c comma,separated,list,fails

>Number:         63324
>Category:       ports
>Synopsis:       port mail/smtpclient: smtpclient -c comma,separated,list,fails
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 24 16:30:13 PST 2004
>Closed-Date:    Wed May 26 10:57:29 PDT 2004
>Last-Modified:  Wed May 26 10:57:29 PDT 2004
>Originator:     Malcolm Kay
>Release:        FreeBSD 4.7-RELEASE i386
>Organization:
	Integrated Electronic Solutions Pty Ltd
>Environment:
System: FreeBSD QuoVadis.design 4.7-RELEASE FreeBSD 4.7-RELEASE #0: Wed Aug 27 11:38:47 CST 2003 kay@QuoVadis.design:/usr/src/sys/compile/IPX i386

>Description:
	smtpclient version 1.0.0 from port does not correctly process 
	multiple Cc addresses using a comma separated list with the 
	-c toggle as described in the man page smtpclient(1).

	May report error or send copy only to the last in the list
	depending on the precise syntax used in the command line.

>How-To-Repeat:
	echo "This is a test" | smtpclient -c fred@some,joe@where alfred@else
>Fix:
	Work around: move all but one Cc: recipient to To: list:-
	echo "Another test" | smtpclient -c fred@some joe@where alfred@else

	Correct the problem:
       Replace files/patch-smtpclient_main_c in port with:-
--------------------patch-smtpclient_main_c----------------------------------
--- smtpclient_main.c.orig	Tue Feb 24 11:49:07 2004
+++ smtpclient_main.c	Tue Feb 24 12:47:11 2004
@@ -86,7 +86,7 @@ void log(char *str, ...)
     char buf[1024];
 
     va_start(ap, str);
-    vsprintf(buf, str, ap);
+    vsnprintf(buf, 1024, str, ap);
     if (usesyslog)
         syslog(LOG_ERR, "SMTPclient: %s", buf);
     else
@@ -395,16 +395,16 @@ int main(int argc, char **argv)
         log("%s: unknown host\n", my_name);
         exit(1);
     }
-    strcpy(my_name, hp->h_name);
+    strlcpy(my_name, hp->h_name, sizeof(my_name));
 
     /*
      *  Determine from address.
      */
     if (from_addr == NULL) {
         if ((pwd = getpwuid(getuid())) == 0) {
-            sprintf(buf, "userid-%d@%s", getuid(), my_name);
+            snprintf(buf, (sizeof(buf) - 1), "userid-%d@%s", getuid(), m=
y_name);
         } else {
-            sprintf(buf, "%s@%s", pwd->pw_name, my_name);
+            snprintf(buf, (sizeof(buf) - 1), "%s@%s", pwd->pw_name, my_n=
ame);
         }
         from_addr = strdup(buf);
     }
@@ -453,8 +453,20 @@ int main(int argc, char **argv)
     chat("MAIL FROM: <%s>\r\n", from_addr);
     for (i = optind; i < argc; i++)
         chat("RCPT TO: <%s>\r\n", argv[i]);
-    if (cc_addr)
-        chat("RCPT TO: <%s>\r\n", cc_addr);
+    if (cc_addr) {
+    	char *cc_tmp,*p;
+	if(!(cc_tmp=malloc(strlen(cc_addr+1)))) {
+	    log("memory allocation failed.");
+	    exit(1);
+	}
+	strcpy(cc_tmp,cc_addr);
+	p=strtok(cc_tmp,",");
+	while(p) {
+	    chat("RCPT TO: <%s>\r\n", p);
+	    p=strtok(NULL,",");
+	}
+	free(cc_tmp);
+    }
     chat("DATA\r\n");
 
     /* 
----------------EOF:patch-smtpclient_main_c---------------------------------
	and rebuild the port.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-ports-bugs 
Responsible-Changed-By: eik 
Responsible-Changed-When: Wed Feb 25 17:38:53 CET 2004 
Responsible-Changed-Why:  
reassign misfiled PR 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63324 
State-Changed-From-To: open->feedback 
State-Changed-By: vs 
State-Changed-When: Fri Mar 12 04:17:52 PST 2004 
State-Changed-Why:  
Asked upstream (rse@) for approval. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63324 
State-Changed-From-To: feedback->closed 
State-Changed-By: pav 
State-Changed-When: Wed May 26 10:57:22 PDT 2004 
State-Changed-Why:  
Committed, thanks! 

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