X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fargp-help.c;h=0b85284392252dad5f124eafe8507195f03b6d0f;hb=22c1c15d0a29a1b7ea75456abe3f7062f835c887;hp=eb15dfd9625e3b459a196eb151c1b5c3160ecdcf;hpb=cbe703a10b786dd2fd595d65e668ece801a4e767;p=gnulib.git diff --git a/lib/argp-help.c b/lib/argp-help.c index eb15dfd96..0b8528439 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. @@ -294,13 +298,13 @@ fill_in_uparams (const struct argp_state *state) {"no-parent", 'P', 0, 0, "Include processes without parents"}, {0, 'x', 0, OPTION_ALIAS}, {"all-fields",'Q', 0, 0, "Don't elide unusable fields (normally" - " if there's some reason ps can't" + " if there's some reason ps can't" " print a field for any process, it's" - " removed from the output entirely)" }, + " removed from the output entirely)" }, {"reverse", 'r', 0, 0, "Reverse the order of any sort"}, {"gratuitously-long-reverse-option", 0, 0, OPTION_ALIAS}, {"session", OPT_SESS, "SID", OPTION_ARG_OPTIONAL, - "Add the processes from the session" + "Add the processes from the session" " SID (which defaults to the sid of" " the current process)" }, @@ -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, @@ -1641,7 +1649,7 @@ Try `%s --help' or `%s --usage' for more information.\n"), __argp_fmtstream_putc (fs, '\n'); __argp_fmtstream_printf (fs, dgettext (argp->argp_domain, "Report bugs to %s.\n"), - argp_program_bug_address); + argp_program_bug_address); anything = 1; }