Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/libexec/ftpd Pullup rev 1.68, 1.70-1.80 (requested by he...



details:   https://anonhg.NetBSD.org/src/rev/1f2b0a43d7ab
branches:  netbsd-1-6
changeset: 531474:1f2b0a43d7ab
user:      jmc <jmc%NetBSD.org@localhost>
date:      Tue Aug 31 01:35:30 2004 +0000

description:
Pullup rev 1.68,1.70-1.80 (requested by he in ticket #1739)

Update to NetBSD ftpd 20040809.  Fixes SA#2004-009.

diffstat:

 libexec/ftpd/ftpcmd.y |  186 +++++++++++++++++++++++--------------------------
 1 files changed, 87 insertions(+), 99 deletions(-)

diffs (truncated from 461 to 300 lines):

diff -r 318dc7ffc017 -r 1f2b0a43d7ab libexec/ftpd/ftpcmd.y
--- a/libexec/ftpd/ftpcmd.y     Tue Aug 31 01:35:26 2004 +0000
+++ b/libexec/ftpd/ftpcmd.y     Tue Aug 31 01:35:30 2004 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: ftpcmd.y,v 1.66.2.2 2002/11/06 20:30:43 tron Exp $     */
+/*     $NetBSD: ftpcmd.y,v 1.66.2.3 2004/08/31 01:35:30 jmc Exp $      */
 
 /*-
- * Copyright (c) 1997-2001 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -48,11 +48,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -83,7 +79,7 @@
 #if 0
 static char sccsid[] = "@(#)ftpcmd.y   8.3 (Berkeley) 4/6/94";
 #else
-__RCSID("$NetBSD: ftpcmd.y,v 1.66.2.2 2002/11/06 20:30:43 tron Exp $");
+__RCSID("$NetBSD: ftpcmd.y,v 1.66.2.3 2004/08/31 01:35:30 jmc Exp $");
 #endif
 #endif /* not lint */
 
@@ -98,8 +94,6 @@
 #include <ctype.h>
 #include <errno.h>
 #include <pwd.h>
-#include <setjmp.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -127,7 +121,10 @@
 %}
 
 %union {
-       int     i;
+       struct {
+               LLT     ll;
+               int     i;
+       } u;
        char   *s;
 }
 
@@ -135,7 +132,7 @@
        A       B       C       E       F       I
        L       N       P       R       S       T
 
-       SP      CRLF    COMMA
+       SP      CRLF    COMMA   ALL
 
        USER    PASS    ACCT    CWD     CDUP    SMNT
        QUIT    REIN    PORT    PASV    TYPE    STRU
@@ -161,11 +158,10 @@
        LEXERR
 
 %token <s> STRING
-%token <s> ALL
-%token <i> NUMBER
+%token <u> NUMBER
 
-%type  <i> check_login octal_number byte_size
-%type  <i> struct_code mode_code type_code form_code decimal_integer
+%type  <u.i> check_login octal_number byte_size
+%type  <u.i> struct_code mode_code type_code form_code decimal_integer
 %type  <s> pathstring pathname password username
 %type  <s> mechanism_name base64data prot_code
 
@@ -176,7 +172,7 @@
 cmd_sel
        : cmd
                {
-                       fromname = NULL;
+                       REASSIGN(fromname, NULL);
                        restart_point = (off_t) 0;
                }
 
@@ -308,7 +304,8 @@
                {
                        if ($2) {
                                if (CURCLASS_FLAGS_ISSET(passive))
-                                       long_passive("EPSV", epsvproto2af($4));
+                                       long_passive("EPSV",
+                                           epsvproto2af($4.i));
                                else
                                        reply(500, "EPSV mode not available.");
                        }
@@ -318,7 +315,8 @@
                {
                        if ($2) {
                                if (CURCLASS_FLAGS_ISSET(passive)) {
-                                       reply(200, "EPSV ALL command successful.");
+                                       reply(200,
+                                           "EPSV ALL command successful.");
                                        epsvall++;
                                } else
                                        reply(500, "EPSV mode not available.");
@@ -454,8 +452,7 @@
                        if (check_write($3, 0)) {
                                if (fromname) {
                                        renamecmd(fromname, $3);
-                                       free(fromname);
-                                       fromname = NULL;
+                                       REASSIGN(fromname, NULL);
                                } else {
                                        reply(503, "Bad sequence of commands.");
                                }
@@ -543,7 +540,7 @@
        | SITE SP CHMOD SP octal_number SP pathname CRLF
                {
                        if (check_write($7, 0)) {
-                               if ($5 > 0777)
+                               if (($5 == -1) || ($5 > 0777))
                                        reply(501,
                                "CHMOD: Mode value must be between 0 and 0777");
                                else if (chmod($7, $5) < 0)
@@ -565,24 +562,28 @@
                {
                        if ($4) {
                                reply(200,
-                           "Current IDLE time limit is %d seconds; max %d",
-                                   curclass.timeout, curclass.maxtimeout);
+                                   "Current IDLE time limit is " LLF
+                                   " seconds; max " LLF,
+                                   (LLT)curclass.timeout,
+                                   (LLT)curclass.maxtimeout);
                        }
                }
 
        | SITE SP IDLE check_login SP NUMBER CRLF
                {
                        if ($4) {
-                               if ($6 < 30 || $6 > curclass.maxtimeout) {
+                               if ($6.i < 30 || $6.i > curclass.maxtimeout) {
                                        reply(501,
-                           "IDLE time limit must be between 30 and %d seconds",
-                                           curclass.maxtimeout);
+                               "IDLE time limit must be between 30 and "
+                                           LLF " seconds",
+                                           (LLT)curclass.maxtimeout);
                                } else {
-                                       curclass.timeout = $6;
+                                       curclass.timeout = $6.i;
                                        (void) alarm(curclass.timeout);
                                        reply(200,
-                                           "IDLE time limit set to %d seconds",
-                                           curclass.timeout);
+                                           "IDLE time limit set to "
+                                           LLF " seconds",
+                                           (LLT)curclass.timeout);
                                }
                        }
                }
@@ -598,19 +599,17 @@
 
        | SITE SP RATEGET check_login SP STRING CRLF
                {
+                       char errbuf[100];
                        char *p = $6;
                        LLT rate;
 
                        if ($4) {
-                               rate = strsuftoll(p);
-                               if (rate == -1)
-                                       reply(501, "Invalid RATEGET %s", p);
-                               else if (curclass.maxrateget &&
-                                   rate > curclass.maxrateget)
-                                       reply(501,
-                       "RATEGET " LLF " is larger than maximum RATEGET " LLF,
-                                           (LLT)rate,
-                                           (LLT)curclass.maxrateget);
+                               rate = strsuftollx("RATEGET", p, 0,
+                                   curclass.maxrateget
+                                   ? curclass.maxrateget
+                                   : LLTMAX, errbuf, sizeof(errbuf));
+                               if (errbuf[0])
+                                       reply(501, "%s", errbuf);
                                else {
                                        curclass.rateget = rate;
                                        reply(200,
@@ -632,19 +631,17 @@
 
        | SITE SP RATEPUT check_login SP STRING CRLF
                {
+                       char errbuf[100];
                        char *p = $6;
                        LLT rate;
 
                        if ($4) {
-                               rate = strsuftoll(p);
-                               if (rate == -1)
-                                       reply(501, "Invalid RATEPUT %s", p);
-                               else if (curclass.maxrateput &&
-                                   rate > curclass.maxrateput)
-                                       reply(501,
-                       "RATEPUT " LLF " is larger than maximum RATEPUT " LLF,
-                                           (LLT)rate,
-                                           (LLT)curclass.maxrateput);
+                               rate = strsuftollx("RATEPUT", p, 0,
+                                   curclass.maxrateput
+                                   ? curclass.maxrateput
+                                   : LLTMAX, errbuf, sizeof(errbuf));
+                               if (errbuf[0])
+                                       reply(501, "%s", errbuf);
                                else {
                                        curclass.rateput = rate;
                                        reply(200,
@@ -875,11 +872,11 @@
        ;
 
 rcmd
-       : REST check_login SP byte_size CRLF
+       : REST check_login SP NUMBER CRLF
                {
                        if ($2) {
-                               fromname = NULL;
-                               restart_point = $4; /* XXX: $4 is only "int" */
+                               REASSIGN(fromname, NULL);
+                               restart_point = (off_t)$4.ll;
                                reply(350,
     "Restarting at " LLF ". Send STORE or RETRIEVE to initiate transfer.",
                                    (LLT)restart_point);
@@ -889,8 +886,10 @@
        | RNFR SP pathname CRLF
                {
                        restart_point = (off_t) 0;
-                       if (check_write($3, 0))
+                       if (check_write($3, 0)) {
+                               REASSIGN(fromname, NULL);
                                fromname = renamefrom($3);
+                       }
                        if ($3 != NULL)
                                free($3);
                }
@@ -911,6 +910,9 @@
 
 byte_size
        : NUMBER
+               {
+                       $$ = $1.i;
+               }
        ;
 
 host_port
@@ -923,9 +925,9 @@
                        data_dest.su_len = sizeof(struct sockaddr_in);
                        data_dest.su_family = AF_INET;
                        p = (char *)&data_dest.su_port;
-                       p[0] = $9; p[1] = $11;
+                       p[0] = $9.i; p[1] = $11.i;
                        a = (char *)&data_dest.su_addr;
-                       a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
+                       a[0] = $1.i; a[1] = $3.i; a[2] = $5.i; a[3] = $7.i;
                }
        ;
 
@@ -940,12 +942,12 @@
                        data_dest.su_len = sizeof(struct sockaddr_in);
                        data_dest.su_family = AF_INET;
                        p = (char *)&data_dest.su_port;
-                       p[0] = $15; p[1] = $17;
+                       p[0] = $15.i; p[1] = $17.i;
                        a = (char *)&data_dest.su_addr;
-                       a[0] =  $5;  a[1] =  $7;  a[2] =  $9;  a[3] = $11;
+                       a[0] = $5.i; a[1] = $7.i; a[2] = $9.i; a[3] = $11.i;
 
                        /* reject invalid LPRT command */
-                       if ($1 != 4 || $3 != 4 || $13 != 2)
+                       if ($1.i != 4 || $3.i != 4 || $13.i != 2)
                                memset(&data_dest, 0, sizeof(data_dest));
                }
        ;
@@ -965,12 +967,12 @@
                        data_dest.su_len = sizeof(struct sockaddr_in6);
                        data_dest.su_family = AF_INET6;
                        p = (char *)&data_dest.su_port;
-                       p[0] = $39; p[1] = $41;
+                       p[0] = $39.i; p[1] = $41.i;
                        a = (char *)&data_dest.si_su.su_sin6.sin6_addr;
-                        a[0] =  $5;  a[1] =  $7;  a[2] =  $9;  a[3] = $11;
-                        a[4] = $13;  a[5] = $15;  a[6] = $17;  a[7] = $19;
-                        a[8] = $21;  a[9] = $23; a[10] = $25; a[11] = $27;
-                       a[12] = $29; a[13] = $31; a[14] = $33; a[15] = $35;
+                       a[0] = $5.i; a[1] = $7.i; a[2] = $9.i; a[3] = $11.i;
+                       a[4] = $13.i; a[5] = $15.i; a[6] = $17.i; a[7] = $19.i;
+                       a[8] = $21.i; a[9] = $23.i; a[10] = $25.i; a[11] = $27.i;
+                       a[12] = $29.i; a[13] = $31.i; a[14] = $33.i; a[15] = $35.i;
                        if (his_addr.su_family == AF_INET6) {



Home | Main Index | Thread Index | Old Index