NetBSD Problem Report #9591

Received: (qmail 4757 invoked from network); 9 Mar 2000 22:19:26 -0000
Message-Id: <200003092137.WAA00526@schleppo.sun.universe>
Date: Thu, 9 Mar 2000 22:37:54 +0100 (CET)
From: Bernd Salbrechter <bernd@mycity.at>
Reply-To: bernd@mycity.at
To: gnats-bugs@gnats.netbsd.org
Subject: ftp/util.c free()'s static and stack values.
X-Send-Pr-Version: 3.95

>Number:         9591
>Category:       bin
>Synopsis:       ftp/util.c free()'s static and stack values.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 09 14:20:59 +0000 2000
>Closed-Date:    Sat Mar 11 12:07:39 +0000 2000
>Last-Modified:  Wed May 24 21:12:01 +0000 2000
>Originator:     Bernd Salbrechter
>Release:        NetBSD-1.4.1
>Organization:
	Private
>Environment:
System: NetBSD schleppo.sun.universe 1.4.1 NetBSD 1.4.1 (SCHLEPPO) #1: Fri Feb 4 20:36:41 CET 2000 salb@schleppo.sun.universe:/products/NetBSD/usr/src/sys/arch/i386/compile/SCHLEPPO i386


>Description:
	When ftp promtes for the user and the password, it free()'s
	a stack value and the static buffer of getpass().

   This cause ftp to core dump on Linux.

>How-To-Repeat:
   Look at the source of /usr/src/usr.bin/ftp/util.c between line
   314 and 350.

>Fix:
--- /home/salb/prs/util.c.orig	Thu Mar  9 22:23:18 2000
+++ /home/salb/prs/util.c	Thu Mar  9 22:26:12 2000
@@ -314,8 +314,10 @@
 		tmp[strlen(tmp) - 1] = '\0';
 		if (*tmp == '\0')
 			user = myname;
-		else
+		else {
 			user = tmp;
+			freeuser = 0;  /* Don't free a stack vaule!. */
+		}
 	}

 	if (gatemode) {
@@ -331,8 +333,10 @@

 	n = command("USER %s", user);
 	if (n == CONTINUE) {
-		if (pass == NULL)
+		if (pass == NULL) {
 			pass = getpass("Password:");
+			freepass = 0;  /* getpass() returna a pointer to a staic buffer!. */
+		}
 		n = command("PASS %s", pass);
 	}
 	if (n == CONTINUE) {
>Release-Note:
>Audit-Trail:

From: Luke Mewburn <lukem@cs.rmit.edu.au>
To: bernd@mycity.at
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9591: ftp/util.c free()'s static and stack values. 
Date: Sat, 11 Mar 2000 23:03:42 +1100

 Bernd Salbrechter writes:
 > >Synopsis:       ftp/util.c free()'s static and stack values.
 > >Release:        NetBSD-1.4.1
 >
 > >Description:
 > 	When ftp promtes for the user and the password, it free()'s
 > 	a stack value and the static buffer of getpass().
 > 
 >    This cause ftp to core dump on Linux.

 This has been fixed in NetBSD-current for a long time.

 If you want a version of NetBSD's ftp for Linux I suggest that you use
 lukemftp, which can be found at:
 	ftp://ftp.netbsd.org/pub/misc/lukemftp/lukemftp-1.2.tar.gz
 This is a port of NetBSD's ftp to various systems including linux, and
 is generally kept up to date with fixes in the NetBSD mainline code.

 Luke.
State-Changed-From-To: open->closed 
State-Changed-By: lukem 
State-Changed-When: Sat Mar 11 04:07:39 PST 2000 
State-Changed-Why:  
hasn't been a problem in current for a long time. 
also, lukemftp exists as a portable version of the netbsd ftp client. 

From: Bernd Salbrechter <bernd@mycity.at>
To: lukem@cs.rmit.edu.au
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/9591: ftp/util.c free()'s static and stack values. 
Date: Thu, 19 Oct 2000 21:56:12 +0200 (CEST)

 Fist of all, sorry for the late replay, but I had seroius hardware
 problems with my laptop.

 On Sat, 11 Mar 2000 23:03:42 +1100 Luke Mewburn <lukem@cs.rmit.edu.au> wrote:

 > Bernd Salbrechter writes:
 > > >Synopsis:       ftp/util.c free()'s static and stack values.
 > > >Release:        NetBSD-1.4.1
 > >
 > > >Description:
 > > 	When ftp promtes for the user and the password, it free()'s
 > > 	a stack value and the static buffer of getpass().
 > > 
 > >    This cause ftp to core dump on Linux.
 > 
 > This has been fixed in NetBSD-current for a long time.

 If it is fixed in -current it's Ok for me, solved it in the -1.4.1
 sources used to bootstap zoularis on Linux localy. Next time I
 realy look in the -current sources, before filling a PR, dosen't
 expect that much delta in that area.

 ...

 Bernd Salbrechter
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.