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-222-g67b49


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-222-g67b49c5
Date: Fri, 07 Dec 2012 00:57:59 +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  67b49c54c0304942737f5409ec4e0c0435443114 (commit)
      from  188433bc0760e8ea8f2947831d1a53b78bc523e5 (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=67b49c54c0304942737f5409ec4e0c0435443114


commit 67b49c54c0304942737f5409ec4e0c0435443114
Author: Mats Erik Andersson <address@hidden>
Date:   Fri Dec 7 01:52:36 2012 +0100

    rcp: Tracking of allocated buffer.

diff --git a/ChangeLog b/ChangeLog
index 483ecc6..f1caf37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2012-12-07  Mats Erik Andersson  <address@hidden>
+
+       Keep track of allocations.  Was an unlimited use of malloc()!
+
+       * src/rcp.c (sink): Change CURSIZE to size_t.  Initialize
+       NAMEBUF and CURSIZE.  Free buffer at each allocation, and
+       set CURSIZE.  Capture error condition after failed malloc(),
+       resetting CURSIZE and continuing with next loop iteration.
+
+       Signedness warnings in src/.
+
+       * src/hostname.c (parse_file): Use ssize_t for NREAD.
+       * src/logger.c (IU_MAX_FAC): New macro.
+       (decode): Remove C.  Use `n >= IU_MAX_FAC' to detect
+       input error.  Return N for successful values.
+       (send_to_syslog): Cast LEN as ssize_t in comparison.
+       * src/rcp.c (allocbuf): Cast `bp->cnt' as size_t in comparison.
+       * src/rexecd.c (die): Cast `sizeof buf' as int in comparison.
+       (getstr): Cast `buf_len >> 3' as ssize_t in comparison.
+       * src/rshd.c (getstr): Likewise.
+
 2012-12-06  Mats Erik Andersson  <address@hidden>
 
        ifconfig: Allow `--up', `--down' to be used before
diff --git a/src/hostname.c b/src/hostname.c
index ed89d7f..83cd564 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -372,7 +372,7 @@ parse_file (const char *const file_name)
   char *buffer = NULL;
   char *name;
   FILE *file;
-  size_t nread;
+  ssize_t nread;
   size_t size = 0;
 
   file = fopen (file_name, "r");
diff --git a/src/logger.c b/src/logger.c
index 5b003f1..6da5b84 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -71,6 +71,12 @@ static int host_family = AF_INET;
 
 
 
+#ifdef LOG_NFACILITIES
+# define IU_MAX_FAC LOG_NFACILITIES
+#else
+# define IU_MAX_FAC 32
+#endif
+
 int
 decode (char *name, CODE *codetab, const char *what)
 {
@@ -79,12 +85,12 @@ decode (char *name, CODE *codetab, const char *what)
   if (isdigit (*name))
     {
       char *p;
-      int c;
       unsigned long n = strtoul (name, &p, 0);
 
-      if (*p || (c = n) != n)
+      if (*p || n >= IU_MAX_FAC)       /* Includes range errors.  */
        error (EXIT_FAILURE, 0, "%s: invalid %s number", what, name);
-      return c;
+
+      return n;
     }
 
   for (cp = codetab; cp->c_name; cp++)
@@ -374,7 +380,7 @@ send_to_syslog (const char *msg)
   free (pbuf);
   if (rc == -1)
     error (0, errno, "send failed");
-  else if (rc != len)
+  else if (rc != (ssize_t) len)
     error (0, errno, "sent less bytes than expected (%lu vs. %lu)",
           (unsigned long) rc, (unsigned long) len);
 }
diff --git a/src/rcp.c b/src/rcp.c
index 2a35112..7bbe9ff 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -972,17 +972,25 @@ sink (int argc, char *argv[])
        SCREWUP ("size not delimited");
       if (targisdir)
        {
-         static char *namebuf;
-         static int cursize;
+         static char *namebuf = NULL;
+         static size_t cursize = 0;
          size_t need;
 
          need = strlen (targ) + strlen (cp) + 250;
          if (need > cursize)
            {
-             if (!(namebuf = malloc (need)))
-               run_err ("%s", strerror (errno));
+             free (namebuf);
+             namebuf = malloc (need);
+             if (namebuf)
+               cursize = need;
+             else
+               {
+                 run_err ("%s", strerror (errno));
+                 cursize = 0;
+                 continue;
+               }
            }
-         snprintf (namebuf, need, "%s%s%s", targ, *targ ? "/" : "", cp);
+         snprintf (namebuf, cursize, "%s%s%s", targ, *targ ? "/" : "", cp);
          np = namebuf;
        }
       else
@@ -1457,7 +1465,7 @@ allocbuf (BUF * bp, int fd, int blksize)
   size = roundup (BUFSIZ, blksize);
   if (size == 0)
     size = blksize;
-  if (bp->cnt >= size)
+  if ((size_t) bp->cnt >= size)
     return (bp);
   if ((bp->buf = realloc (bp->buf, size)) == NULL)
     {
diff --git a/src/rexecd.c b/src/rexecd.c
index b7ff3b2..15bee0e 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -652,10 +652,10 @@ die (int code, const char *fmt, ...)
   int n;
 
   va_start (ap, fmt);
-  buf[0] = 1;
+  buf[0] = 1;          /* Error condition.  */
   n = vsnprintf (buf + 1, sizeof buf - 1, fmt, ap);
   va_end (ap);
-  if (n > sizeof buf - 1)
+  if (n + 1 > (int) sizeof buf)
     n = sizeof buf - 1;
   buf[n++] = '\n';
   write (STDERR_FILENO, buf, n);
@@ -688,7 +688,7 @@ getstr (const char *err)
        }
 
       end += rd;
-      if ((buf + buf_len - end) < (buf_len >> 3))
+      if ((buf + buf_len - end) < (ssize_t) (buf_len >> 3))
        {
          /* Not very much room left in our buffer, grow it. */
          size_t end_offs = end - buf;
diff --git a/src/rshd.c b/src/rshd.c
index 0feda9d..4ba6c09 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -1695,6 +1695,7 @@ getstr (const char *err)
     {
       /* Oh this is efficient, oh yes.  [But what can be done?] */
       int rd = read (STDIN_FILENO, end, 1);
+
       if (rd <= 0)
        {
          if (rd == 0)
@@ -1705,7 +1706,7 @@ getstr (const char *err)
        }
 
       end += rd;
-      if ((buf + buf_len - end) < (buf_len >> 3))
+      if ((buf + buf_len - end) < (ssize_t) (buf_len >> 3))
        {
          /* Not very much room left in our buffer, grow it. */
          size_t end_offs = end - buf;

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

Summary of changes:
 ChangeLog      |   21 +++++++++++++++++++++
 src/hostname.c |    2 +-
 src/logger.c   |   14 ++++++++++----
 src/rcp.c      |   20 ++++++++++++++------
 src/rexecd.c   |    6 +++---
 src/rshd.c     |    3 ++-
 6 files changed, 51 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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