mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 07:56:29 +00:00
Merge pull request #7145 from idryzhov/fix-regex-error
lib: fix regcomp error processing
This commit is contained in:
commit
8934c1f4dd
@ -1064,6 +1064,7 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in,
|
|||||||
/* look for `|` */
|
/* look for `|` */
|
||||||
char *orig, *working, *token, *u;
|
char *orig, *working, *token, *u;
|
||||||
char *pipe = strstr(cmd_in, "| ");
|
char *pipe = strstr(cmd_in, "| ");
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (!pipe)
|
if (!pipe)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1082,6 +1083,7 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in,
|
|||||||
|
|
||||||
if (!regexp) {
|
if (!regexp) {
|
||||||
vty_out(vty, "%% Need a regexp to filter with\n");
|
vty_out(vty, "%% Need a regexp to filter with\n");
|
||||||
|
ret = 1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,6 +1091,7 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in,
|
|||||||
|
|
||||||
if (!succ) {
|
if (!succ) {
|
||||||
vty_out(vty, "%% Bad regexp '%s'\n", regexp);
|
vty_out(vty, "%% Bad regexp '%s'\n", regexp);
|
||||||
|
ret = 1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
*cmd_out = XSTRDUP(MTYPE_TMP, cmd_in);
|
*cmd_out = XSTRDUP(MTYPE_TMP, cmd_in);
|
||||||
@ -1096,12 +1099,13 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in,
|
|||||||
strsep(&u, "|");
|
strsep(&u, "|");
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, "%% Unknown action '%s'\n", token);
|
vty_out(vty, "%% Unknown action '%s'\n", token);
|
||||||
|
ret = 1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
XFREE(MTYPE_TMP, orig);
|
XFREE(MTYPE_TMP, orig);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_pipe_action_done(struct vty *vty, const char *cmd_exec)
|
static int handle_pipe_action_done(struct vty *vty, const char *cmd_exec)
|
||||||
@ -1117,10 +1121,15 @@ int cmd_execute(struct vty *vty, const char *cmd,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *cmd_out = NULL;
|
char *cmd_out = NULL;
|
||||||
const char *cmd_exec;
|
const char *cmd_exec = NULL;
|
||||||
vector vline;
|
vector vline;
|
||||||
|
|
||||||
hook_call(cmd_execute, vty, cmd, &cmd_out);
|
ret = hook_call(cmd_execute, vty, cmd, &cmd_out);
|
||||||
|
if (ret) {
|
||||||
|
ret = CMD_WARNING;
|
||||||
|
goto free;
|
||||||
|
}
|
||||||
|
|
||||||
cmd_exec = cmd_out ? (const char *)cmd_out : cmd;
|
cmd_exec = cmd_out ? (const char *)cmd_out : cmd;
|
||||||
|
|
||||||
vline = cmd_make_strvec(cmd_exec);
|
vline = cmd_make_strvec(cmd_exec);
|
||||||
@ -1132,6 +1141,7 @@ int cmd_execute(struct vty *vty, const char *cmd,
|
|||||||
ret = CMD_SUCCESS;
|
ret = CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free:
|
||||||
hook_call(cmd_execute_done, vty, cmd_exec);
|
hook_call(cmd_execute_done, vty, cmd_exec);
|
||||||
|
|
||||||
XFREE(MTYPE_TMP, cmd_out);
|
XFREE(MTYPE_TMP, cmd_out);
|
||||||
|
@ -141,8 +141,8 @@ bool vty_set_include(struct vty *vty, const char *regexp)
|
|||||||
REG_EXTENDED | REG_NEWLINE | REG_NOSUB);
|
REG_EXTENDED | REG_NEWLINE | REG_NOSUB);
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
ret = false;
|
ret = false;
|
||||||
regerror(ret, &vty->include, errbuf, sizeof(errbuf));
|
regerror(errcode, &vty->include, errbuf, sizeof(errbuf));
|
||||||
vty_out(vty, "%% Regex compilation error: %s", errbuf);
|
vty_out(vty, "%% Regex compilation error: %s\n", errbuf);
|
||||||
} else {
|
} else {
|
||||||
vty->filter = true;
|
vty->filter = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user