Subject: bin/640: ftp/mget: filename case translation option trashes filenames
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: George Robbins <grr@shandakor.tharsis.com>
List: netbsd-bugs
Date: 12/14/1994 17:05:10
>Number:         640
>Category:       bin
>Synopsis:       ftp/mget: filename case translation option trashes filenames
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 14 17:05:05 1994
>Originator:     George Robbins
>Organization:
none
>Release:        1.0
>Environment:
System: NetBSD shandakor.tharsis.com 1.0 NetBSD 1.0 (SHANDAKOR) #3: Sun Dec 11 09:38:56 PST 1994 root@shandakor.tharsis.com:/usr/src/sys/arch/i386/compile/SHANDAKOR i386
>Description:
when the "case" command is used to enable filename case
	translation, the mget command fails to null terminate the translated
	filename, resulting in garbage being appended to the filename as
	displayed on the terminal and when the file is created.
	
>How-To-Repeat:
	open connection to system such as MS-DOS with upper-case filenames
	case
	mget *.*
	examine messages and created filenames
>Fix:
	add null termination to code...
	see attached diff

*** src/usr.bin/ftp/cmds.c.dist	Wed Dec 14 17:14:15 1994
--- src/usr.bin/ftp/cmds.c	Wed Dec 14 17:14:55 1994
***************
*** 743,748 ****
--- 743,749 ----
  			if (mcase) {
  				for (tp2 = tmpbuf; ch = *tp++;)
  					*tp2++ = isupper(ch) ? tolower(ch) : ch;
+ 				*tp2 = '\0';
  				tp = tmpbuf;
  			}
  			if (ntflag) {

>Audit-Trail:
>Unformatted: