From nobody  Sat Feb  7 22:24:14 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id WAA07930;
          Sat, 7 Feb 1998 22:24:14 -0800 (PST)
          (envelope-from nobody)
Message-Id: <199802080624.WAA07930@hub.freebsd.org>
Date: Sat, 7 Feb 1998 22:24:14 -0800 (PST)
From: mzaki@e-mail.ne.jp
To: freebsd-gnats-submit@freebsd.org
Subject: ftp does not understand 'site' correctly 
X-Send-Pr-Version: www-1.0

>Number:         5679
>Category:       bin
>Synopsis:       ftp does not understand 'site' correctly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    steve
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb  7 22:30:00 PST 1998
>Closed-Date:    Sat Feb 14 07:43:22 PST 1998
>Last-Modified:  Sat Feb 14 07:43:46 PST 1998
>Originator:     Motomichi Matsuzaki
>Release:        2.2.5-STABLE
>Organization:
>Environment:
FreeBSD 2.2.5-STABLE i386

>Description:
The new ftp(1) (ported from NetBSD) does not understand correctly long 'site' like
'site foo bar etc etc etc'. It truncated 'site foo bar'. It is the same with 'quote'.
>How-To-Repeat:
% ftp -d 127.0.0.1
Connected to 127.0.0.1.
(...)
ftp> site foo bar etc etc etc
---> SITE foo bar
500 'SITE FOO bar': command not understood.
ftp>


>Fix:
--- /usr/src/usr.bin/ftp/cmds.c Fri Feb  6 02:32:24 1998
+++ cmds.c	Wed Jan 28 03:42:11 1998
@@ -1460,7 +1460,7 @@
                for (i = 2; i < argc && len < sizeof(buf); i++) {
                        buf[len++] = ' ';
                        len += strlen(strncpy(&buf[len], argv[i],
-                           sizeof(buf) - len) - 1);
+                           sizeof(buf) - len - 1));
                }
        }
        if (command(buf) == PRELIM) {

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: freebsd-gnats-submit@FreeBSD.ORG, mzaki@e-mail.ne.jp
Cc:  Subject: Re: bin/5679: ftp does not understand 'site' correctly
Date: Sun, 8 Feb 1998 18:10:46 +1100

 >>Fix:
 >--- /usr/src/usr.bin/ftp/cmds.c Fri Feb  6 02:32:24 1998
 >+++ cmds.c	Wed Jan 28 03:42:11 1998
 >@@ -1460,7 +1460,7 @@
 >                for (i = 2; i < argc && len < sizeof(buf); i++) {
                                                           ^ add ` - 1'
 >                        buf[len++] = ' ';
 >                        len += strlen(strncpy(&buf[len], argv[i],
 >-                           sizeof(buf) - len) - 1);
 >+                           sizeof(buf) - len - 1));
 >                }
 >        }
 >        if (command(buf) == PRELIM) {
 
 The bounds checking is broken too.  When len is initially sizeof(buf) - 1,
 the size passed to strncpy() is (size_t)-1 (essentially infinity).
 
 Bruce
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sat Feb 14 07:43:22 PST 1998 
State-Changed-Why:  
Fixed in both -current and -stable. 
>Unformatted:
