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-343-gea7b8


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-343-gea7b8e2
Date: Sun, 15 Sep 2013 01:44:57 +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  ea7b8e2c2d266fea32124c1ca7f564b5cd03f74c (commit)
      from  489e189add01f52ece8ba68ea75ec5434f90f555 (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=ea7b8e2c2d266fea32124c1ca7f564b5cd03f74c


commit ea7b8e2c2d266fea32124c1ca7f564b5cd03f74c
Author: Mats Erik Andersson <address@hidden>
Date:   Sun Sep 15 03:26:06 2013 +0200

    telnet: Uninitialized array of pointers.

diff --git a/ChangeLog b/ChangeLog
index 73b429a..2329d79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-09-15  Mats Erik Andersson  <address@hidden>
+
+       telnet: Uninitialized array of pointers.
+       Contemporary tgetent() emulations are known to ignore
+       the scratch buffer, as well as fill it in (contrary to
+       claim in manual page).  Account for this.
+
+       * telnet/telnet.c (mklist): Return quickly in case of
+       an empty first parameter `buf'.  Carefully initialize
+       `*ARGVP' to NULL at every stage.
+
+
+       Harmless memory leak in test program.
+
+       * tests/localhost.c: Include <stdlib.h>.
+       (main): Remove `const' on P, and it free after use.
+
 2013-09-12  Mats Erik Andersson  <address@hidden>
 
        * configure.ac: Add a relevant comment where AC_DEFINE
diff --git a/telnet/telnet.c b/telnet/telnet.c
index 73406ed..9dda4a3 100644
--- a/telnet/telnet.c
+++ b/telnet/telnet.c
@@ -633,30 +633,41 @@ mklist (char *buf, char *name)
     }
   else
     unknown[0] = name_unknown;
+
+  /*
+   * An empty capability buffer finishes the analysis.
+   */
+  if (!buf || !*buf)
+    return (unknown);
+
   /*
-   * Count up the number of names.
+   * Count the number of alias names.
+   * Stop at the first field separator, a colon.
    */
   for (n = 1, cp = buf; *cp && *cp != ':'; cp++)
     {
       if (*cp == '|')
        n++;
     }
+
   /*
-   * Allocate an array to put the name pointers into.
+   * Allocate an array to hold the name pointers.
    */
   argv = (char **) malloc ((n + 3) * sizeof (char *));
   if (argv == 0)
     return (unknown);
 
   /*
-   * Fill up the array of pointers to names.
+   * Fill the array of pointers with the established aliases.
+   * Reserve the first slot for the preferred name.
    */
-  *argv = 0;
   argvp = argv + 1;
-  n = 0;
+  *argv = *argvp = 0;
+  n = 0;               /* Positive: name uses white space.  */
+
   for (cp = cp2 = buf; (c = *cp); cp++)
     {
-      if (c == '|' || c == ':')
+      if (c == '|' || c == ':')                /* Delimiters */
        {
          *cp++ = '\0';
          /*
@@ -667,21 +678,28 @@ mklist (char *buf, char *name)
           * insensitive) add it to the list.
           */
          if (n || (cp - cp2 > 41))
-           ;
+           ;                   /* Ignore the just scanned name.  */
          else if (name && (strncasecmp (name, cp2, cp - cp2) == 0))
-           *argv = cp2;
+           *argv = cp2;        /* Preferred name, exact match.  */
          else if (is_unique (cp2, argv + 1, argvp))
-           *argvp++ = cp2;
+           {
+             *argvp++ = cp2;
+             *argvp = 0;       /* Prevent looking forward.  */
+           }
+
+         /* Abort parsing at first field delimiter.  */
          if (c == ':')
            break;
+
          /*
-          * Skip multiple delimiters. Reset cp2 to
-          * the beginning of the next name. Reset n,
+          * Skip multiple delimiters. Reset CP2 to
+          * the beginning of the next name. Reset N,
           * the flag for names with spaces.
           */
          while ((c = *cp) == '|')
            cp++;
-         cp2 = cp;
+
+         cp2 = cp;             /* Proceed to next alias name.  */
          n = 0;
        }
       /*
@@ -733,8 +751,8 @@ mklist (char *buf, char *name)
     return (unknown);
 }
 
-/* Mostly ignored by contemorary implementations,
- * but still used by NetBSD.
+/* Claimed to be ignored by contemporary implementations,
+ * but still modified by FreeBSD and NetBSD.
  * mklist will examine this buffer, so erase it
  * to cover corner cases.
  */
diff --git a/tests/localhost.c b/tests/localhost.c
index ec914b0..aa25b9f 100644
--- a/tests/localhost.c
+++ b/tests/localhost.c
@@ -22,18 +22,20 @@
 #include "libinetutils.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unused-parameter.h>
 #include <progname.h>
 
 int
 main (int argc _GL_UNUSED_PARAMETER, char **argv)
 {
-  const char *p = localhost ();
+  char *p = localhost ();
   set_program_name (argv[0]);
   if (!p)
     return 1;
 
   printf ("localhost: %s\n", p);
+  free (p);
 
   return 0;
 }

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

Summary of changes:
 ChangeLog         |   17 +++++++++++++++++
 telnet/telnet.c   |   46 ++++++++++++++++++++++++++++++++--------------
 tests/localhost.c |    4 +++-
 3 files changed, 52 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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