updates from libc,automake
authorKarl Berry <karl@freefriends.org>
Thu, 25 Sep 2003 12:21:19 +0000 (12:21 +0000)
committerKarl Berry <karl@freefriends.org>
Thu, 25 Sep 2003 12:21:19 +0000 (12:21 +0000)
config/ChangeLog
lib/ChangeLog
lib/argp-fmtstream.c
lib/argp-help.c

index 9d26fc89f997d59376ef357b923cc2d1ddf00371..744a27c6f50c2089e7c78fafb7f2e9057038dfd7 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-25  Karl Berry  <karl@gnu.org>
+
+       * install-sh: update from automake.
+
 2003-09-14  Karl Berry  <karl@gnu.org>
 
        * srclist.txt (strdup.c): disable for c89 changes.
index 60bf66490ad17f87f54a513b6776a691d7f39ee7..aa2153a4b1e5ed1d6ea5d280e8ed9b120cf3a3d1 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-25  Karl Berry  <karl@gnu.org>
+
+       * argp-fmtstream.c, argp-help.c: update from libc.
+
 2003-09-25  Bruno Haible  <bruno@clisp.org>
 
        * version-etc-2.h: New file, from version-etc.h with modifications.
index c6d79a56fcacdb14e3df67ae4ea996622f177576..c88c3db2147136dbb8931f0b50dc1953b050b940 100644 (file)
@@ -384,10 +384,11 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
       if ((size_t) (fs->end - fs->buf) < amount)
        /* Gotta grow the buffer.  */
        {
-         size_t new_size = fs->end - fs->buf + amount;
-         char *new_buf = realloc (fs->buf, new_size);
+         size_t old_size = fs->end - fs->buf;
+         size_t new_size = old_size + amount;
+         char *new_buf;
 
-         if (! new_buf)
+         if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
            {
              __set_errno (ENOMEM);
              return 0;
index 497bae148855bee17056d2bb1f4a660719b0833f..0b85284392252dad5f124eafe8507195f03b6d0f 100644 (file)
@@ -72,6 +72,10 @@ char *alloca ();
 #include "argp.h"
 #include "argp-fmtstream.h"
 #include "argp-namefrob.h"
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif 
 \f
 /* User-selectable (using an environment variable) formatting parameters.
 
@@ -440,7 +444,8 @@ make_hol (const struct argp *argp, struct hol_cluster *cluster)
       hol->entries = malloc (sizeof (struct hol_entry) * hol->num_entries);
       hol->short_options = malloc (num_short_options + 1);
 
-      assert (hol->entries && hol->short_options);
+      assert (hol->entries && hol->short_options
+             && hol->num_entries <= SIZE_MAX / sizeof (struct hol_entry));
 
       /* Fill in the entries.  */
       so = hol->short_options;
@@ -833,6 +838,9 @@ hol_append (struct hol *hol, struct hol *more)
          char *short_options =
            malloc (hol_so_len + strlen (more->short_options) + 1);
 
+         assert (entries && short_options
+                 && num_entries <= SIZE_MAX / sizeof (struct hol_entry));
+
          __mempcpy (__mempcpy (entries, hol->entries,
                                hol->num_entries * sizeof (struct hol_entry)),
                     more->entries,