mirror of
https://github.com/mirror/wget.git
synced 2025-01-03 00:40:28 +08:00
* src/init.c (parse_line): Remove use of alloca
This commit is contained in:
parent
c3c04ffeba
commit
e91e96ccb5
13
src/init.c
13
src/init.c
@ -827,6 +827,8 @@ parse_line (const char *line, char **com, char **val, int *comind)
|
||||
const char *end = line + strlen (line);
|
||||
const char *cmdstart, *cmdend;
|
||||
const char *valstart, *valend;
|
||||
char buf[1024];
|
||||
size_t len;
|
||||
|
||||
char *cmdcopy;
|
||||
int ind;
|
||||
@ -867,9 +869,18 @@ parse_line (const char *line, char **com, char **val, int *comind)
|
||||
|
||||
/* The line now known to be syntactically correct. Check whether
|
||||
the command is valid. */
|
||||
BOUNDED_TO_ALLOCA (cmdstart, cmdend, cmdcopy);
|
||||
len = cmdend - cmdstart;
|
||||
if (len < sizeof (buf))
|
||||
cmdcopy = buf;
|
||||
else
|
||||
cmdcopy = xmalloc (len + 1);
|
||||
memcpy (cmdcopy, cmdstart, len);
|
||||
cmdcopy[len] = 0;
|
||||
|
||||
dehyphen (cmdcopy);
|
||||
ind = command_by_name (cmdcopy);
|
||||
if (cmdcopy != buf)
|
||||
xfree (cmdcopy);
|
||||
if (ind == -1)
|
||||
return line_unknown_command;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user