Subject: bin/29534: pkg_add hangs during FTP from ftp.fi.netbsd.org
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Andreas Gustafsson <gson@gson.org>
List: netbsd-bugs
Date: 02/26/2005 12:37:01
>Number:         29534
>Category:       bin
>Synopsis:       pkg_add hangs during FTP from ftp.fi.netbsd.org
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 26 12:37:00 +0000 2005
>Originator:     Andreas Gustafsson
>Release:        NetBSD 2.0
>Organization:
>Environment:
System: NetBSD gus.araneus.fi 2.0 NetBSD 2.0 (GENERIC) #0: Thu Dec 2 01:57:30 UTC 2004 builds@build:/big/builds/ab/netbsd-2-0-RELEASE/sparc/200411300000Z-obj/big/builds/ab/netbsd-2-0-RELEASE/src/sys/arch/sparc/compile/GENERIC sparc
Architecture: sparc
Machine: sparc
>Description:

pkg_add hangs when attempting to retrive binary packages from ftp.fi.netbsd.org.
This is because expect() in src/usr.bin/pkg_install/lib/ftpio.c only handles FTP
replies of 90 characters or less including the two surrounding newlines,
but the response ftp.fi.netbsd.org sends to the command "cd ." can be much
longer.  In my case, it was 129 characters:

  ftp> cd .
  250 OK. Current directory is /.m/mirrors11/ftp.netbsd.org/pub/NetBSD/packages/pkgsrc-2004Q4/NetBSD-2.0/sparc/All

>How-To-Repeat:

Run the command

  pkg_add -v ftp://ftp.fi.netbsd.org/pub/NetBSD/packages/2.0/sparc/All/apache-1.3.33nb1.tgz

Note how it hangs after sending the "cd ." command to FTP.

>Fix:

Index: ftpio.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/pkg_install/lib/ftpio.c,v
retrieving revision 1.66
diff -u -r1.66 ftpio.c
--- ftpio.c	6 Jan 2005 11:56:39 -0000	1.66
+++ ftpio.c	26 Feb 2005 12:33:33 -0000
@@ -139,7 +139,7 @@
 expect(int fd, const char *str, int *ftprc)
 {
 	int rc;
-	char buf[90];  
+	char buf[150];  
 #if EXPECT_DEBUG
 	char *vstr;
 #endif /* EXPECT_DEBUG */