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-226-g4d081


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-226-g4d08115
Date: Sat, 15 Dec 2012 14:56:04 +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  4d0811532f03ca76fec3f5ba5b7d90644d027510 (commit)
      from  8b7266bbea9c489b147cf3dece2eb05f2f3c4ecc (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=4d0811532f03ca76fec3f5ba5b7d90644d027510


commit 4d0811532f03ca76fec3f5ba5b7d90644d027510
Author: Mats Erik Andersson <address@hidden>
Date:   Sat Dec 15 14:50:48 2012 +0100

    ftp: Check for allocated buffer.

diff --git a/ChangeLog b/ChangeLog
index a2ae553..5f25421 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-12-15  Mats Erik Andersson  <address@hidden>
+
+       * ftp/cmds.c (put, mput, getit, mget): Check if
+       domap() has allocated new memory, and only then
+       update string pointer and free old memory.
+       (domap) <'[', LOOP>: If cp_subst() substituted
+       something, set MATCH to 1.
+
 2012-12-07  Mats Erik Andersson  <address@hidden>
 
        Activate servers in FreeBSD 9 and 10.  They work
diff --git a/ftp/cmds.c b/ftp/cmds.c
index 9886fd2..362c277 100644
--- a/ftp/cmds.c
+++ b/ftp/cmds.c
@@ -569,8 +569,11 @@ put (int argc, char **argv)
   if (loc && mapflag)
     {
       char *new = domap (remote);
-      free (remote);
-      remote = new;
+      if (new != remote)
+       {
+         free (remote);
+         remote = new;
+       }
     }
   sendrequest (cmd, local, remote,
               strcmp (argv[1], local) != 0 || strcmp (argv[2], remote) != 0);
@@ -625,9 +628,12 @@ mput (int argc, char **argv)
              if (mapflag)
                {
                  char *new = domap (tp);
-                 if (tp != cp)
-                   free (tp);
-                 tp = new;
+                 if (new != tp)
+                   {
+                     if (tp != cp)
+                       free (tp);
+                     tp = new;
+                   }
                }
              sendrequest ((sunique) ? "STOU" : "STOR",
                           cp, tp, cp != tp || !interactive);
@@ -668,9 +674,12 @@ mput (int argc, char **argv)
              if (mapflag)
                {
                  char *new = domap (tp);
-                 if (tp != argv[i])
-                   free (tp);
-                 tp = new;
+                 if (new != tp)
+                   {
+                     if (tp != argv[i])
+                       free (tp);
+                     tp = new;
+                   }
                }
              sendrequest ((sunique) ? "STOU" : "STOR",
                           argv[i], tp, tp != argv[i] || !interactive);
@@ -717,9 +726,12 @@ mput (int argc, char **argv)
              if (mapflag)
                {
                  char *new = domap (tp);
-                 if (tp != *cpp)
-                   free (tp);
-                 tp = new;
+                 if (new != tp)
+                   {
+                     if (tp != *cpp)
+                       free (tp);
+                     tp = new;
+                   }
                }
              sendrequest ((sunique) ? "STOU" : "STOR",
                           *cpp, tp, *cpp != tp || !interactive);
@@ -799,8 +811,11 @@ getit (int argc, char **argv, int restartit, char *mode)
   if (loc && mapflag)
     {
       char *new = domap (local);
-      free (local);
-      local = new;
+      if (new != local)
+       {
+         free (local);
+         local = new;
+       }
     }
   if (restartit)
     {
@@ -937,9 +952,12 @@ mget (int argc, char **argv)
          if (mapflag)
            {
              char *new = domap (tp);
-             if (tp != cp)
-               free (tp);
-             tp = new;
+             if (new != tp)
+               {
+                 if (tp != cp)
+                   free (tp);
+                 tp = new;
+               }
            }
          recvrequest ("RETR", tp, cp, "w", tp != cp || !interactive);
          if (!mflag && fromatty)
@@ -2104,6 +2122,9 @@ setntrans (int argc, char **argv)
   ntout[sizeof (ntout) - 1] = '\0';
 }
 
+/* NOTE: dotrans() always returns a newly allocated string.
+ */
+
 char *
 dotrans (char *name)
 {
@@ -2218,6 +2239,10 @@ cp_subst (char **from_p, char **to_p, int *toks, char 
**tp, char **te, char *tok
   return 1;
 }
 
+/* NOTE: domap() can return a newly allocated string,
+ * but need not do so every time.
+ */
+
 char *
 domap (char *name)
 {
@@ -2291,7 +2316,10 @@ domap (char *name)
        case '[':
        LOOP:
          if (*++cp2 == '$' && isdigit (*(cp2 + 1)))
-           cp_subst (&cp2, &cp1, toks, tp, te, name, &buf, &buf_len);
+           {
+             if (cp_subst (&cp2, &cp1, toks, tp, te, name, &buf, &buf_len))
+               match = 1;
+           }
          else
            {
              while (*cp2 && *cp2 != ',' && *cp2 != ']')

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

Summary of changes:
 ChangeLog  |    8 +++++++
 ftp/cmds.c |   62 +++++++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 53 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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