From nobody@FreeBSD.org  Wed Oct 24 14:14:54 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 6181516A417
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 24 Oct 2007 14:14:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 5F1C513C4A8
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 24 Oct 2007 14:14:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l9OEERrG000509
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 24 Oct 2007 14:14:27 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l9OEERSE000508;
	Wed, 24 Oct 2007 14:14:27 GMT
	(envelope-from nobody)
Message-Id: <200710241414.l9OEERSE000508@www.freebsd.org>
Date: Wed, 24 Oct 2007 14:14:27 GMT
From: Spencer Minear <minear@securecomputing.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: The fix for PR 103206 is incorrect
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         117452
>Category:       bin
>Synopsis:       [patch] tftp(1): the fix for PR 103206 was incorrect
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 24 14:20:02 UTC 2007
>Closed-Date:    Sun Jan 17 11:11:35 UTC 2010
>Last-Modified:  Sun Jan 17 11:11:35 UTC 2010
>Originator:     Spencer Minear
>Release:        6.2
>Organization:
Secure Computing Corporation
>Environment:
FreeBSD freebe1.scur.com 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 10:40:27 UTC 2007     root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
The change that was made for PR 103206 results in tftp returns an error
code even if a send operation succeeds.  The txrx_error = 1 that was added
at the end of the   processing needs to be placed at each point where and
abort is detected.


>How-To-Repeat:
Use tftp to download a file and check the error status you will find that
it sets the error status to 1 even when the file is successfully downloaded.

Before the fix the following occurs:

echo "get configs/10.69.222.75.cfg" | ./tftp 10.69.222.30
Received 963 bytes in 0.0 seconds
alpha:Admn {14} % echo $?
1

After the fix I've proposed the same command has a 0 exit code.

alpha:Admn {11} % echo "get configs/10.69.222.75.cfg" | tftp 10.69.222.30
Received 963 bytes in 0.0 seconds
alpha:Admn {12} % echo $?
0

>Fix:
% diff -c /usr/src/usr.bin/tftp/tftp.c .
*** /usr/src/usr.bin/tftp/tftp.c        Mon Oct  2 13:43:57 2006
--- ./tftp.c    Wed Sep 19 10:58:23 2007
***************
*** 143,148 ****
--- 143,149 ----
                    (struct sockaddr *)&peer, peer.ss_len);
                if (n != size + 4) {
                        warn("sendto");
+                       txrx_error = 1;
                        goto abort;
                }
                read_ahead(file, convert);
***************
*** 156,161 ****
--- 157,163 ----
                        alarm(0);
                        if (n < 0) {
                                warn("recvfrom");
+                               txrx_error = 1;
                                goto abort;
                        }
                        if (!serv.ss_family)
***************
*** 163,168 ****
--- 165,171 ----
                        else if (!cmpport((struct sockaddr *)&serv,
                            (struct sockaddr *)&from)) {
                                warn("server port mismatch");
+                               txrx_error = 1;
                                goto abort;
                        }
                        peer = from;
***************
*** 205,211 ****
        stopclock();
        if (amount > 0)
                printstats("Sent", amount);
-       txrx_error = 1;
  }
  
  /*
--- 208,213 ----
***************
*** 261,266 ****
--- 263,269 ----
                    peer.ss_len) != size) {
                        alarm(0);
                        warn("sendto");
+                       txrx_error = 1;
                        goto abort;
                }
                write_behind(file, convert);
***************
*** 274,279 ****
--- 277,283 ----
                        alarm(0);
                        if (n < 0) {
                                warn("recvfrom");
+                               txrx_error = 1;
                                goto abort;
                        }
                        if (!serv.ss_family)
***************
*** 281,286 ****
--- 285,291 ----
                        else if (!cmpport((struct sockaddr *)&serv,
                            (struct sockaddr *)&from)) {
                                warn("server port mismatch");
+                               txrx_error = 1;
                                goto abort;
                        }
                        peer = from;
***************
*** 331,337 ****
        stopclock();
        if (amount > 0)
                printstats("Received", amount);
-       txrx_error = 1;
  }
  
  static int
--- 336,341 ----



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: gavin 
State-Changed-When: Sun Jan 3 13:49:15 UTC 2010 
State-Changed-Why:  
Fixed in r201429, will MFC in 2 weeks.  Thanks for your submission! 


Responsible-Changed-From-To: freebsd-bugs->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Sun Jan 3 13:49:15 UTC 2010 
Responsible-Changed-Why:  
Mine 

http://www.freebsd.org/cgi/query-pr.cgi?pr=117452 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/117452: commit references a PR
Date: Sun,  3 Jan 2010 13:49:12 +0000 (UTC)

 Author: gavin
 Date: Sun Jan  3 13:48:58 2010
 New Revision: 201429
 URL: http://svn.freebsd.org/changeset/base/201429
 
 Log:
   Fix return code in the case of successful file transfer, broken in
   tftp.c 1.13
   
   PR:		bin/117452
   Submitted by:	Spencer Minear  minear securecomputing.com
   Approved by:	ed (mentor)
   MFC after:	2 weeks
 
 Modified:
   head/usr.bin/tftp/tftp.c
 
 Modified: head/usr.bin/tftp/tftp.c
 ==============================================================================
 --- head/usr.bin/tftp/tftp.c	Sun Jan  3 12:50:27 2010	(r201428)
 +++ head/usr.bin/tftp/tftp.c	Sun Jan  3 13:48:58 2010	(r201429)
 @@ -140,6 +140,7 @@ send_data:
  		    (struct sockaddr *)&peer, peer.ss_len);
  		if (n != size + 4) {
  			warn("sendto");
 +			txrx_error = 1;
  			goto abort;
  		}
  		read_ahead(file, convert);
 @@ -153,6 +154,7 @@ send_data:
  			alarm(0);
  			if (n < 0) {
  				warn("recvfrom");
 +				txrx_error = 1;
  				goto abort;
  			}
  			if (!serv.ss_family)
 @@ -160,6 +162,7 @@ send_data:
  			else if (!cmpport((struct sockaddr *)&serv,
  			    (struct sockaddr *)&from)) {
  				warn("server port mismatch");
 +				txrx_error = 1;
  				goto abort;
  			}
  			peer = from;
 @@ -202,7 +205,6 @@ abort:
  	stopclock();
  	if (amount > 0)
  		printstats("Sent", amount);
 -	txrx_error = 1;
  }
  
  /*
 @@ -255,6 +257,7 @@ send_ack:
  		    peer.ss_len) != size) {
  			alarm(0);
  			warn("sendto");
 +			txrx_error = 1;
  			goto abort;
  		}
  		write_behind(file, convert);
 @@ -268,6 +271,7 @@ send_ack:
  			alarm(0);
  			if (n < 0) {
  				warn("recvfrom");
 +				txrx_error = 1;
  				goto abort;
  			}
  			if (!serv.ss_family)
 @@ -275,6 +279,7 @@ send_ack:
  			else if (!cmpport((struct sockaddr *)&serv,
  			    (struct sockaddr *)&from)) {
  				warn("server port mismatch");
 +				txrx_error = 1;
  				goto abort;
  			}
  			peer = from;
 @@ -325,7 +330,6 @@ abort:						/* ok to ack, since user */
  	stopclock();
  	if (amount > 0)
  		printstats("Received", amount);
 -	txrx_error = 1;
  }
  
  static int
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/117452: commit references a PR
Date: Sun, 17 Jan 2010 10:59:19 +0000 (UTC)

 Author: gavin
 Date: Sun Jan 17 10:58:59 2010
 New Revision: 202462
 URL: http://svn.freebsd.org/changeset/base/202462
 
 Log:
   Merge r201429:
     Fix return code in the case of successful file transfer, broken in
     tftp.c 1.13
   
   PR:		bin/117452
   Submitted by:	Spencer Minear  minear securecomputing.com
   Approved by:	ed (mentor, implicit)
 
 Modified:
   stable/8/usr.bin/tftp/tftp.c
 Directory Properties:
   stable/8/usr.bin/tftp/   (props changed)
 
 Modified: stable/8/usr.bin/tftp/tftp.c
 ==============================================================================
 --- stable/8/usr.bin/tftp/tftp.c	Sun Jan 17 09:37:31 2010	(r202461)
 +++ stable/8/usr.bin/tftp/tftp.c	Sun Jan 17 10:58:59 2010	(r202462)
 @@ -140,6 +140,7 @@ send_data:
  		    (struct sockaddr *)&peer, peer.ss_len);
  		if (n != size + 4) {
  			warn("sendto");
 +			txrx_error = 1;
  			goto abort;
  		}
  		read_ahead(file, convert);
 @@ -153,6 +154,7 @@ send_data:
  			alarm(0);
  			if (n < 0) {
  				warn("recvfrom");
 +				txrx_error = 1;
  				goto abort;
  			}
  			if (!serv.ss_family)
 @@ -160,6 +162,7 @@ send_data:
  			else if (!cmpport((struct sockaddr *)&serv,
  			    (struct sockaddr *)&from)) {
  				warn("server port mismatch");
 +				txrx_error = 1;
  				goto abort;
  			}
  			peer = from;
 @@ -202,7 +205,6 @@ abort:
  	stopclock();
  	if (amount > 0)
  		printstats("Sent", amount);
 -	txrx_error = 1;
  }
  
  /*
 @@ -255,6 +257,7 @@ send_ack:
  		    peer.ss_len) != size) {
  			alarm(0);
  			warn("sendto");
 +			txrx_error = 1;
  			goto abort;
  		}
  		write_behind(file, convert);
 @@ -268,6 +271,7 @@ send_ack:
  			alarm(0);
  			if (n < 0) {
  				warn("recvfrom");
 +				txrx_error = 1;
  				goto abort;
  			}
  			if (!serv.ss_family)
 @@ -275,6 +279,7 @@ send_ack:
  			else if (!cmpport((struct sockaddr *)&serv,
  			    (struct sockaddr *)&from)) {
  				warn("server port mismatch");
 +				txrx_error = 1;
  				goto abort;
  			}
  			peer = from;
 @@ -325,7 +330,6 @@ abort:						/* ok to ack, since user */
  	stopclock();
  	if (amount > 0)
  		printstats("Received", amount);
 -	txrx_error = 1;
  }
  
  static int
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/117452: commit references a PR
Date: Sun, 17 Jan 2010 10:59:24 +0000 (UTC)

 Author: gavin
 Date: Sun Jan 17 10:59:07 2010
 New Revision: 202463
 URL: http://svn.freebsd.org/changeset/base/202463
 
 Log:
   Merge r201429 from head:
     Fix return code in the case of successful file transfer, broken in
     tftp.c 1.13
   
   PR:		bin/117452
   Submitted by:	Spencer Minear  minear securecomputing.com
   Approved by:	ed (mentor, implicit)
 
 Modified:
   stable/7/usr.bin/tftp/tftp.c
 Directory Properties:
   stable/7/usr.bin/tftp/   (props changed)
 
 Modified: stable/7/usr.bin/tftp/tftp.c
 ==============================================================================
 --- stable/7/usr.bin/tftp/tftp.c	Sun Jan 17 10:58:59 2010	(r202462)
 +++ stable/7/usr.bin/tftp/tftp.c	Sun Jan 17 10:59:07 2010	(r202463)
 @@ -143,6 +143,7 @@ send_data:
  		    (struct sockaddr *)&peer, peer.ss_len);
  		if (n != size + 4) {
  			warn("sendto");
 +			txrx_error = 1;
  			goto abort;
  		}
  		read_ahead(file, convert);
 @@ -156,6 +157,7 @@ send_data:
  			alarm(0);
  			if (n < 0) {
  				warn("recvfrom");
 +				txrx_error = 1;
  				goto abort;
  			}
  			if (!serv.ss_family)
 @@ -163,6 +165,7 @@ send_data:
  			else if (!cmpport((struct sockaddr *)&serv,
  			    (struct sockaddr *)&from)) {
  				warn("server port mismatch");
 +				txrx_error = 1;
  				goto abort;
  			}
  			peer = from;
 @@ -205,7 +208,6 @@ abort:
  	stopclock();
  	if (amount > 0)
  		printstats("Sent", amount);
 -	txrx_error = 1;
  }
  
  /*
 @@ -261,6 +263,7 @@ send_ack:
  		    peer.ss_len) != size) {
  			alarm(0);
  			warn("sendto");
 +			txrx_error = 1;
  			goto abort;
  		}
  		write_behind(file, convert);
 @@ -274,6 +277,7 @@ send_ack:
  			alarm(0);
  			if (n < 0) {
  				warn("recvfrom");
 +				txrx_error = 1;
  				goto abort;
  			}
  			if (!serv.ss_family)
 @@ -281,6 +285,7 @@ send_ack:
  			else if (!cmpport((struct sockaddr *)&serv,
  			    (struct sockaddr *)&from)) {
  				warn("server port mismatch");
 +				txrx_error = 1;
  				goto abort;
  			}
  			peer = from;
 @@ -331,7 +336,6 @@ abort:						/* ok to ack, since user */
  	stopclock();
  	if (amount > 0)
  		printstats("Received", amount);
 -	txrx_error = 1;
  }
  
  static int
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: gavin 
State-Changed-When: Sun Jan 17 11:11:08 UTC 2010 
State-Changed-Why:  
Merged to 8.x and 7.x.  Doesn't seem worth merging to 6.x. 

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