commit-inetutils
[Top][All Lists]
Advanced

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

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-338-ga3a5e


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-338-ga3a5ee8
Date: Mon, 09 Sep 2013 20:32:47 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  a3a5ee825f903d127c06d073af683b454165fc42 (commit)
      from  7df832e9413143011feb9bd0b9bcc3d7349ce785 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=a3a5ee825f903d127c06d073af683b454165fc42


commit a3a5ee825f903d127c06d073af683b454165fc42
Author: Mats Erik Andersson <address@hidden>
Date:   Sat Sep 7 14:37:59 2013 +0200

    ftp: Remove line length limit.
    
    Final step to manage input lines of almost
    arbitrary lengths from the user.

diff --git a/ChangeLog b/ChangeLog
index d19c41f..d1d572c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2013-09-07  Mats Erik Andersson  <address@hidden>
+
+       ftp: Remove line length limit.
+       Once the argument parsing routine is rewritten
+       to work with dynamic memory, the length limit
+       on input lines can be removed in its entirety.
+
+       * ftp/extern.h (slurpstring): Remove declaration.
+       * ftp/ftp_var.h (argbuf): Change to string pointer.
+       (MAXMARGV) [!MAXMARGV]: New macro.
+       (margv): Change array length to MAXMARGV.
+
+       * ftp/main.c (slurpstring): Declare as static.
+       (main): Initalize `argbuf' to NULL.
+       (cmdscanner): Remove check whether `line' exceeds
+       MAXLINE in length.
+       (slrflag): Declare as static.
+       (makeargv): Free and allocate `argbuf' at entry.
+       Insert a condition to ensure that at most MAXMARGV
+       arguments are located, thus avoiding an overflow.
+
+       * ftp/ruserpass.c (tokval): Change array length
+       to BUFSIZ.
+
 2013-09-06  Mats Erik Andersson  <address@hidden>
 
        ftp: Macro execution and allocation.
diff --git a/ftp/extern.h b/ftp/extern.h
index dff99cf..9a07965 100644
--- a/ftp/extern.h
+++ b/ftp/extern.h
@@ -152,7 +152,6 @@ void setverbose (int, char **);
 void shell (int, char **);
 void site (int, char **);
 void sizecmd (int, char **);
-char *slurpstring (void);
 void status (int, char **);
 void syst (int, char **);
 void tvsub (struct timeval *, struct timeval *, struct timeval *);
diff --git a/ftp/ftp_var.h b/ftp/ftp_var.h
index 29247d1..dedb357 100644
--- a/ftp/ftp_var.h
+++ b/ftp/ftp_var.h
@@ -117,10 +117,15 @@ FTP_EXTERN char *line;            /* input produced by 
readline or getline */
 FTP_EXTERN size_t linelen;     /* allocated length of the same, if known */
 
 FTP_EXTERN char *stringbase;   /* current scan point in line buffer */
-FTP_EXTERN char argbuf[MAXLINE];       /* argument storage buffer */
+FTP_EXTERN char *argbuf;       /* allocated argument storage buffer */
 FTP_EXTERN char *argbase;      /* current storage point in arg buffer */
+
+#ifndef MAXMARGV
+# define MAXMARGV 20
+#endif
+
 FTP_EXTERN int margc;          /* count of arguments on input line */
-FTP_EXTERN char *margv[20];    /* args parsed from input line */
+FTP_EXTERN char *margv[MAXMARGV]; /* args parsed from input line */
 FTP_EXTERN int cpend;          /* flag: if != 0, then pending server reply */
 FTP_EXTERN int mflag;          /* flag: if != 0, then active multi command */
 
diff --git a/ftp/main.c b/ftp/main.c
index 2b847b3..630cfe5 100644
--- a/ftp/main.c
+++ b/ftp/main.c
@@ -94,6 +94,8 @@
 #endif
 
 
+static char *slurpstring (void);
+
 #define DEFAULT_PROMPT "ftp> "
 static char *prompt = NULL;
 
@@ -221,6 +223,7 @@ main (int argc, char *argv[])
 
   line = NULL;                 /* reset global input */
   linelen = 0;
+  argbuf = NULL;
 
   /* Invoked as `pftp'?  Then set passive mode.  */
   cp = strrchr (argv[0], '/');
@@ -413,12 +416,6 @@ cmdscanner (int top)
        quit (0, 0);
 
       l = strlen (line);
-      if (l >= MAXLINE)                        /* XXX: Relax.  */
-       {
-         printf ("Line too long.\n");
-         break;
-       }
-
       if (l == 0)
        break;
 
@@ -464,19 +461,33 @@ cmdscanner (int top)
  * Slice a string up into argc/argv.
  */
 
-int slrflag;
+static int slrflag;
 
 void
 makeargv (void)
 {
   char **argp;
 
-  margc = 0;
+  margc = 0;                   /* No content as of yet.  */
+
+  /* Make sure that `argbuf' is large enough
+   * to contain `line'.  As soon as `line' is
+   * invalidated, so will `argbuf' be.
+   **/
+  free (argbuf);               /* Get rid of previous content.  */
+  argbuf = malloc (strlen (line) + 4);
+  if (!argbuf)
+    {
+      /* `margc' is naught, which hopefully will cover our back.  */
+      printf ("Allocation failure.  Serious error.\n");
+      return;
+    }
+
   argp = margv;
   stringbase = line;           /* scan from beginning of buffer */
   argbase = argbuf;            /* store at beginning of buffer */
   slrflag = 0;
-  while ((*argp++ = slurpstring ()))
+  while ((margc < MAXMARGV) && (*argp++ = slurpstring ()))
     margc++;
 }
 
@@ -485,7 +496,7 @@ makeargv (void)
  * implemented with FSM to
  * handle quoting and strings
  */
-char *
+static char *
 slurpstring (void)
 {
   int got_one = 0;
diff --git a/ftp/ruserpass.c b/ftp/ruserpass.c
index 33d99b0..8e1775c 100644
--- a/ftp/ruserpass.c
+++ b/ftp/ruserpass.c
@@ -84,7 +84,7 @@ static FILE *cfile;
 #undef MACHINE
 #define MACHINE        11
 
-static char tokval[100];
+static char tokval[BUFSIZ];
 
 static struct toktab
 {

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

Summary of changes:
 ChangeLog       |   24 ++++++++++++++++++++++++
 ftp/extern.h    |    1 -
 ftp/ftp_var.h   |    9 +++++++--
 ftp/main.c      |   31 +++++++++++++++++++++----------
 ftp/ruserpass.c |    2 +-
 5 files changed, 53 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]