Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 1998 17:33:13 +0100 (MET)
From:      Jens Schweikhardt <schweikh@noc.dfn.de>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/5565: ftp prints garbage
Message-ID:  <199801251633.RAA04636@obsidian.noc.dfn.de>

next in thread | raw e-mail | index | archive | help

>Number:         5565
>Category:       bin
>Synopsis:       ftp prints garbage
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 25 08:40:01 PST 1998
>Last-Modified:
>Originator:     Jens Schweikhardt
>Organization:
DFN NOC
>Release:        FreeBSD 2.2.5-RELEASE i386
>Environment:

FreeBSD hal9000.details.de 2.2.5-RELEASE FreeBSD 2.2.5-RELEASE #0: Thu Jan 22 20:05:20 CET 1998     schweikh@hal9000.details.de:/usr/src/sys/compile/HAL9000  i386

>Description:

	ftp prints garbage when I type Control-D at the login prompt.

>How-To-Repeat:

hal9000: 0 $ ftp localhost
Connected to localhost.
220 hal9000.details.de FTP server (Version 6.00) ready.
Name (localhost:schweikh): ^D331 Password required for .

The garbage is the stuff after 'Password required for '

>Fix:

The bug is that tmp[] is used unitialized when fgets returns NULL.
The following patch to usr.bin/ftp/ftp.c makes a Control-D at the
login prompt leave ftp -- the same behavior as for telnet.

--- ftp.c.orig	Sun Jan 25 14:39:14 1998
+++ ftp.c	Sun Jan 25 14:51:46 1998
@@ -214,7 +214,8 @@
 			printf("Name (%s:%s): ", host, myname);
 		else
 			printf("Name (%s): ", host);
-		(void) fgets(tmp, sizeof(tmp) - 1, stdin);
+		if (fgets(tmp, sizeof(tmp) - 1, stdin) == NULL)
+			return 0;
 		tmp[strlen(tmp) - 1] = '\0';
 		if (*tmp == '\0')
 			user = myname;

Regards,

	Jens
-- 
Jens Schweikhardt  http://www.shuttle.de/schweikh/
SIGSIG -- signature too long (core dumped)
>Audit-Trail:
>Unformatted:
From: schweikh@noc.dfn.de
Reply-To: schweikh@noc.dfn.de
X-send-pr-version: 3.2





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801251633.RAA04636>