From b3b353659ac863c94e9705047710a99fa58fe0b1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 25 Sep 2003 12:21:19 +0000 Subject: [PATCH] updates from libc,automake --- config/ChangeLog | 4 ++++ lib/ChangeLog | 4 ++++ lib/argp-fmtstream.c | 7 ++++--- lib/argp-help.c | 10 +++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/config/ChangeLog b/config/ChangeLog index 9d26fc89f9..744a27c6f5 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,7 @@ +2003-09-25 Karl Berry + + * install-sh: update from automake. + 2003-09-14 Karl Berry * srclist.txt (strdup.c): disable for c89 changes. diff --git a/lib/ChangeLog b/lib/ChangeLog index 60bf66490a..aa2153a4b1 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2003-09-25 Karl Berry + + * argp-fmtstream.c, argp-help.c: update from libc. + 2003-09-25 Bruno Haible * version-etc-2.h: New file, from version-etc.h with modifications. diff --git a/lib/argp-fmtstream.c b/lib/argp-fmtstream.c index c6d79a56fc..c88c3db214 100644 --- a/lib/argp-fmtstream.c +++ b/lib/argp-fmtstream.c @@ -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; diff --git a/lib/argp-help.c b/lib/argp-help.c index 497bae1488..0b85284392 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -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 /* 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, -- 2.30.2