projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(error_tail): Don't cast alloca to (void *); it's already (void *).
[gnulib.git]
/
lib
/
argp-help.c
diff --git
a/lib/argp-help.c
b/lib/argp-help.c
index
497bae1
..
0b85284
100644
(file)
--- 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"
#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.
\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);
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;
/* 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);
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,
__mempcpy (__mempcpy (entries, hol->entries,
hol->num_entries * sizeof (struct hol_entry)),
more->entries,