Subject: bin/3957: ftpd may lose conversion suffix info
To: None <gnats-bugs@gnats.netbsd.org>
From: Tatoku Ogaito <tacha@tera.fukui-med.ac.jp>
List: netbsd-bugs
Date: 08/08/1997 22:04:31
>Number:         3957
>Category:       bin
>Synopsis:       ftpd may lose conversion suffix info
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug  8 06:20:02 1997
>Last-Modified:
>Originator:     Tatoku Ogaito
>Organization:
-----            : Tatoku Ogaito
   / _  _ _/ _   : Department of Physics, Fukui Medical University
  / (_|(_ /)(_|  : E-mail: tacha@tera.fukui-med.ac.jp
>Release:        current 970806
>Environment:
	
System: NetBSD tera.fukui-med.ac.jp 1.2G NetBSD 1.2G (TERA) #89: Thu Aug 7 13:22:57 JST 1997 root@tera.fukui-med.ac.jp:/usr/current/src/sys/arch/i386/compile/TERA i386


>Description:

	I set up ftpd.conf to support on-the-fly translation, 
but reply from STAT command includes wrong suffix information and
no conversion happened.
	
>How-To-Repeat:
[tera]/etc% cat ftpd.conf
conversion all    .tar.gz d .notar /usr/bin/tar -czf - %s
conversion all    .tar.Z  d .notar /usr/bin/tar -cvZf - %s
conversion all    .tar    d .notar /usr/bin/tar -cf  - %s
display         guest   .message
notify          guest   README*

[tera]/etc% ftp localhost
....	
ftp> quot STAT
211- tera.fukui-med.ac.jp FTP server status:
211- Version 7.00
211- Connected to localhost (127.0.0.1)
211- Logged in anonymously
211- TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: Stream
211- No data connection
211- 
211- Class: guest
211- Display file: .message
211- Notify fileglob: README*
211- Idle timeout: 900, maximum timeout: 7200
211- dele, mkd, rmd, umask, chmod: disabled
211- Umask: 0707
211- Conversion:  [d] disable: .notar, command: /usr/bin/tar -cf  - %s
211- Conversion: p
 [d] disable: .notar, command: /usr/bin/tar -cvZf - %s
211- Conversion: .. [d] disable: .notar, command: /usr/bin/tar -czf - %s
211 End of status

>Fix:
--- libexec/ftpd/conf.c.orig	Thu Jul 31 20:14:56 1997
+++ libexec/ftpd/conf.c	Fri Aug  8 21:03:11 1997
@@ -74,7 +74,7 @@
 	size_t		 len;
 	int		 none, match;
 	char		*endp;
-	char		*class, *word, *arg;
+	char		*class, *word, *arg, *suffix;
 	char		*types, *disable, *convcmd;
 	const char	*infile;
 	int		 line;
@@ -143,6 +143,7 @@
 			NEXTWORD(types);
 			NEXTWORD(disable);
 			convcmd = buf;
+			suffix=strdup(arg);
 			if (convcmd)
 				convcmd += strspn(convcmd, " \t");
 			if (none || EMPTYSTR(types) ||
@@ -157,7 +158,7 @@
 			}
 			for (conv = curclass.conversions; conv != NULL;
 			    conv = conv->next) {
-				if (strcmp(conv->suffix, arg) == 0)
+				if (strcmp(conv->suffix, suffix) == 0)
 					break;
 			}
 			if (conv == NULL) {
@@ -170,7 +171,7 @@
 				conv->next = curclass.conversions;
 				curclass.conversions = conv;
 			}
-			REASSIGN(conv->suffix, arg);
+			REASSIGN(conv->suffix, suffix);
 			REASSIGN(conv->types, types);
 			REASSIGN(conv->disable, disable);
 			REASSIGN(conv->command, convcmd);
>Audit-Trail:
>Unformatted: