shishi-commit
[Top][All Lists]
Advanced

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

shishi/gl argp-fmtstream.c argp-help.c


From: shishi-commit
Subject: shishi/gl argp-fmtstream.c argp-help.c
Date: Mon, 29 Sep 2003 16:24:51 -0400

CVSROOT:        /cvsroot/shishi
Module name:    shishi
Branch:         
Changes by:     Simon Josefsson <address@hidden>        03/09/29 16:24:51

Modified files:
        gl             : argp-fmtstream.c argp-help.c 

Log message:
        Upstream sync.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/gl/argp-fmtstream.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/gl/argp-help.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: shishi/gl/argp-fmtstream.c
diff -u shishi/gl/argp-fmtstream.c:1.3 shishi/gl/argp-fmtstream.c:1.4
--- shishi/gl/argp-fmtstream.c:1.3      Fri Aug 22 14:47:09 2003
+++ shishi/gl/argp-fmtstream.c  Mon Sep 29 16:24:50 2003
@@ -385,10 +385,11 @@
       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: shishi/gl/argp-help.c
diff -u shishi/gl/argp-help.c:1.9 shishi/gl/argp-help.c:1.10
--- shishi/gl/argp-help.c:1.9   Fri Aug 22 17:24:06 2003
+++ shishi/gl/argp-help.c       Mon Sep 29 16:24:51 2003
@@ -84,6 +84,10 @@
 #include "argp.h"
 #include "argp-fmtstream.h"
 #include "argp-namefrob.h"
+
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif 
 
 /* User-selectable (using an environment variable) formatting parameters.
 
@@ -452,7 +456,8 @@
       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;
@@ -844,6 +849,9 @@
          unsigned hol_so_len = strlen (hol->short_options);
          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)),




reply via email to

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