1
0
mirror of https://github.com/mirror/wget.git synced 2025-04-25 12:40:30 +08:00

Remove use of alloca in setoptval

* src/init.c (setoptval): Remove use of alloca
* src/init.h: Add define MAX_LONGOPTION
* src/main.c (struct cmdline_option): Make 'long_name' a char array
This commit is contained in:
Tim Rühsen 2020-02-13 16:39:31 +01:00
parent cbea3d41dd
commit c3c04ffeba
3 changed files with 5 additions and 4 deletions

View File

@ -946,9 +946,8 @@ void
setoptval (const char *com, const char *val, const char *optname)
{
/* Prepend "--" to OPTNAME. */
char *dd_optname = (char *) alloca (2 + strlen (optname) + 1);
dd_optname[0] = '-';
dd_optname[1] = '-';
char dd_optname[2 + MAX_LONGOPTION + 1] = "--";
strcpy (dd_optname + 2, optname);
assert (val != NULL);

View File

@ -42,4 +42,6 @@ void cleanup (void);
void defaults (void);
bool run_wgetrc (const char *file, file_stats_t *);
#define MAX_LONGOPTION 26
#endif /* INIT_H */

View File

@ -242,7 +242,7 @@ _Noreturn static void print_version (void);
#endif
struct cmdline_option {
const char *long_name;
char long_name[MAX_LONGOPTION];
char short_name;
enum {
OPT_VALUE,