Subject: PATCH for ftpd
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: David Carrel <carrel@cisco.com>
List: current-users
Date: 05/10/1994 23:38:07
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"

The following is a quick patch to fix an off_t problem in ftpd.  The only
problem is in the sizes that get printed (they always show up as zero).
You might have noticed output like this when ftp-ing to a NetBSD machine:
	ftp> get xv xv.foo
	227 Entering Passive Mode (198,92,30,121,4,16)
	150 Opening BINARY mode data connection for xv (0 bytes).

I solved this by casting the off_t values to unsigned longs when printing
them.  The truely correct way to fix this would be to have printf()
recognize a "long long".  I tried "%lld" and "%llu" but they did not work.

Maybe I'll be more energetic tomorrow night and look into a patch for
printf.

Dave


------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-Description: ftpd patch

diff -r -c /usr/src/libexec/ftpd/ftpcmd.y ./ftpcmd.y
*** /usr/src/libexec/ftpd/ftpcmd.y	Fri Apr 15 04:06:43 1994
--- ./ftpcmd.y	Tue May 10 23:21:31 1994
***************
*** 1171,1177 ****
  		    (stbuf.st_mode&S_IFMT) != S_IFREG)
  			reply(550, "%s: not a plain file.", filename);
  		else
! 			reply(213, "%lu", stbuf.st_size);
  		break;}
  	case TYPE_A: {
  		FILE *fin;
--- 1171,1177 ----
  		    (stbuf.st_mode&S_IFMT) != S_IFREG)
  			reply(550, "%s: not a plain file.", filename);
  		else
! 			reply(213, "%lu", (unsigned long)stbuf.st_size);
  		break;}
  	case TYPE_A: {
  		FILE *fin;
diff -r -c /usr/src/libexec/ftpd/ftpd.c ./ftpd.c
*** /usr/src/libexec/ftpd/ftpd.c	Fri Apr 15 04:06:44 1994
--- ./ftpd.c	Tue May 10 23:21:10 1994
***************
*** 719,725 ****
  	file_size = size;
  	byte_count = 0;
  	if (size != (off_t) -1)
! 		(void) sprintf (sizebuf, " (%ld bytes)", size);
  	else
  		(void) strcpy(sizebuf, "");
  	if (pdata >= 0) {
--- 719,725 ----
  	file_size = size;
  	byte_count = 0;
  	if (size != (off_t) -1)
! 		(void) sprintf (sizebuf, " (%ld bytes)", (unsigned long)size);
  	else
  		(void) strcpy(sizebuf, "");
  	if (pdata >= 0) {

------- =_aaaaaaaaaa0--

------------------------------------------------------------------------------