Subject: bin/32855: [dM] ftp -q is broken (or misdocumented)
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 02/16/2006 18:20:00
>Number:         32855
>Category:       bin
>Synopsis:       [dM] ftp -q is broken (or misdocumented)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 16 18:20:00 +0000 2006
>Originator:     der Mouse
>Release:        NetBSD 3.0
>Organization:
	Dis-
>Environment:
System: NetBSD ahab.openface.ca 3.0 NetBSD 3.0 (PFGATE) #1: Mon Feb 13 11:46:48 EST 2006 mouse@ahab.openface.ca:/usr/src/sys/arch/i386/compile/PFGATE i386
Architecture: i386
Machine: i386
>Description:
	ftp(1) has a -q option, which is documented as

     -q quittime
              Quit if the connection has stalled for quittime seconds.

	However, the actual timeout is 60 seconds, regardless of the -q
	value, for everything except data transfers.

	This could be thought of as a doc-bug, if -q really is supposed
	to affect only data connections, but that strikes me as much
	the less useful functionality (it certainly isn't the one I
	want now), so I believe the code should be changed instead.
>How-To-Repeat:
	FTP to a host with a -q value drastically different from 60
	(10, maybe, or 3600).  Cause the ftpd to go unresponsive
	(anything from kill -STOP to attaching to it with gdb to
	unplugging a network cable).  Do something in the client which
	causes it to try to speak to the daemon on the control
	connection.  Notice that you get
	421 Service not available, remote server timed out. Connection closed
	after one minute, no matter what value you gave to -q.
>Fix:
	(This is relative to ftp.c,v 1.126.2.9)

	--- ftp.c.ORIG	2006-02-09 21:56:15.000000000 -0500
	+++ ftp.c	2006-02-16 13:04:55.000000000 -0500
	@@ -402,7 +402,7 @@
	 	for (line = 0 ;; line++) {
	 		dig = n = code = 0;
	 		cp = current_line;
	-		while (alarmtimer(60),((c = getc(cin)) != '\n')) {
	+		while (alarmtimer(quit_time?quit_time:60),((c = getc(cin)) != '\n')) {
	 			if (c == IAC) {     /* handle telnet commands */
	 				switch (c = getc(cin)) {
	 				case WILL:

	"It works for me."

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B