mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 09:46:54 +00:00
Merge pull request #1624 from qlyoung/fix-cmd-argc-max-usage
lib, bgpd: fixup use of of CMD_ARGC_MAX
This commit is contained in:
commit
48442c0a9a
12
bgpd/bgpd.c
12
bgpd/bgpd.c
@ -1151,15 +1151,13 @@ struct peer *peer_new(struct bgp *bgp)
|
|||||||
* - We RX a BGP_UPDATE where the attributes alone are just
|
* - We RX a BGP_UPDATE where the attributes alone are just
|
||||||
* under BGP_MAX_PACKET_SIZE
|
* under BGP_MAX_PACKET_SIZE
|
||||||
* - The user configures an outbound route-map that does many as-path
|
* - The user configures an outbound route-map that does many as-path
|
||||||
* prepends or adds many communities. At most they can have
|
* prepends or adds many communities. At most they can have
|
||||||
* CMD_ARGC_MAX
|
* CMD_ARGC_MAX args in a route-map so there is a finite limit on how
|
||||||
* args in a route-map so there is a finite limit on how large they
|
* large they can make the attributes.
|
||||||
* can
|
|
||||||
* make the attributes.
|
|
||||||
*
|
*
|
||||||
* Having a buffer with BGP_MAX_PACKET_SIZE_OVERFLOW allows us to avoid
|
* Having a buffer with BGP_MAX_PACKET_SIZE_OVERFLOW allows us to avoid
|
||||||
* bounds
|
* bounds checking for every single attribute as we construct an
|
||||||
* checking for every single attribute as we construct an UPDATE.
|
* UPDATE.
|
||||||
*/
|
*/
|
||||||
peer->obuf_work =
|
peer->obuf_work =
|
||||||
stream_new(BGP_MAX_PACKET_SIZE + BGP_MAX_PACKET_SIZE_OVERFLOW);
|
stream_new(BGP_MAX_PACKET_SIZE + BGP_MAX_PACKET_SIZE_OVERFLOW);
|
||||||
|
@ -190,7 +190,7 @@ struct cmd_node {
|
|||||||
#define CMD_NOT_MY_INSTANCE 14
|
#define CMD_NOT_MY_INSTANCE 14
|
||||||
|
|
||||||
/* Argc max counts. */
|
/* Argc max counts. */
|
||||||
#define CMD_ARGC_MAX 25
|
#define CMD_ARGC_MAX 256
|
||||||
|
|
||||||
/* Turn off these macros when uisng cpp with extract.pl */
|
/* Turn off these macros when uisng cpp with extract.pl */
|
||||||
#ifndef VTYSH_EXTRACT_PL
|
#ifndef VTYSH_EXTRACT_PL
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack")
|
DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack")
|
||||||
|
|
||||||
#define MAXDEPTH 256
|
|
||||||
|
|
||||||
#ifdef TRACE_MATCHER
|
#ifdef TRACE_MATCHER
|
||||||
#define TM 1
|
#define TM 1
|
||||||
#else
|
#else
|
||||||
@ -84,7 +82,7 @@ static enum match_type match_mac(const char *, bool);
|
|||||||
enum matcher_rv command_match(struct graph *cmdgraph, vector vline,
|
enum matcher_rv command_match(struct graph *cmdgraph, vector vline,
|
||||||
struct list **argv, const struct cmd_element **el)
|
struct list **argv, const struct cmd_element **el)
|
||||||
{
|
{
|
||||||
struct graph_node *stack[MAXDEPTH];
|
struct graph_node *stack[CMD_ARGC_MAX];
|
||||||
enum matcher_rv status;
|
enum matcher_rv status;
|
||||||
*argv = NULL;
|
*argv = NULL;
|
||||||
|
|
||||||
@ -200,7 +198,7 @@ static enum matcher_rv command_match_r(struct graph_node *start, vector vline,
|
|||||||
/* check history/stack of tokens
|
/* check history/stack of tokens
|
||||||
* this disallows matching the same one more than once if there is a
|
* this disallows matching the same one more than once if there is a
|
||||||
* circle in the graph (used for keyword arguments) */
|
* circle in the graph (used for keyword arguments) */
|
||||||
if (n == MAXDEPTH)
|
if (n == CMD_ARGC_MAX)
|
||||||
return MATCHER_NO_MATCH;
|
return MATCHER_NO_MATCH;
|
||||||
if (!token->allowrepeat)
|
if (!token->allowrepeat)
|
||||||
for (size_t s = 0; s < n; s++)
|
for (size_t s = 0; s < n; s++)
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc")
|
DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc")
|
||||||
|
|
||||||
#define MAXDEPTH 64
|
|
||||||
|
|
||||||
/** headers **/
|
/** headers **/
|
||||||
void grammar_sandbox_init(void);
|
void grammar_sandbox_init(void);
|
||||||
void pretty_print_graph(struct vty *vty, struct graph_node *, int, int,
|
void pretty_print_graph(struct vty *vty, struct graph_node *, int, int,
|
||||||
@ -262,7 +260,7 @@ DEFUN (grammar_test_show,
|
|||||||
{
|
{
|
||||||
check_nodegraph();
|
check_nodegraph();
|
||||||
|
|
||||||
struct graph_node *stack[MAXDEPTH];
|
struct graph_node *stack[CMD_ARGC_MAX];
|
||||||
pretty_print_graph(vty, vector_slot(nodegraph->nodes, 0), 0, argc >= 3,
|
pretty_print_graph(vty, vector_slot(nodegraph->nodes, 0), 0, argc >= 3,
|
||||||
stack, 0);
|
stack, 0);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
@ -277,8 +275,8 @@ DEFUN (grammar_test_dot,
|
|||||||
{
|
{
|
||||||
check_nodegraph();
|
check_nodegraph();
|
||||||
|
|
||||||
struct graph_node *stack[MAXDEPTH];
|
struct graph_node *stack[CMD_ARGC_MAX];
|
||||||
struct graph_node *visited[MAXDEPTH * MAXDEPTH];
|
struct graph_node *visited[CMD_ARGC_MAX * CMD_ARGC_MAX];
|
||||||
size_t vpos = 0;
|
size_t vpos = 0;
|
||||||
|
|
||||||
FILE *ofd = fopen(argv[2]->arg, "w");
|
FILE *ofd = fopen(argv[2]->arg, "w");
|
||||||
@ -334,7 +332,7 @@ static void cmd_graph_permute(struct list *out, struct graph_node **stack,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++stackpos == MAXDEPTH)
|
if (++stackpos == CMD_ARGC_MAX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < vector_active(gn->to); i++) {
|
for (i = 0; i < vector_active(gn->to); i++) {
|
||||||
@ -354,7 +352,7 @@ static void cmd_graph_permute(struct list *out, struct graph_node **stack,
|
|||||||
static struct list *cmd_graph_permutations(struct graph *graph)
|
static struct list *cmd_graph_permutations(struct graph *graph)
|
||||||
{
|
{
|
||||||
char accumulate[2048] = "";
|
char accumulate[2048] = "";
|
||||||
struct graph_node *stack[MAXDEPTH];
|
struct graph_node *stack[CMD_ARGC_MAX];
|
||||||
|
|
||||||
struct list *rv = list_new();
|
struct list *rv = list_new();
|
||||||
rv->cmp = cmd_permute_cmp;
|
rv->cmp = cmd_permute_cmp;
|
||||||
@ -532,7 +530,7 @@ void pretty_print_graph(struct vty *vty, struct graph_node *start, int level,
|
|||||||
vty_out(vty, " ?'%s'", tok->desc);
|
vty_out(vty, " ?'%s'", tok->desc);
|
||||||
vty_out(vty, " ");
|
vty_out(vty, " ");
|
||||||
|
|
||||||
if (stackpos == MAXDEPTH) {
|
if (stackpos == CMD_ARGC_MAX) {
|
||||||
vty_out(vty, " -aborting! (depth limit)\n");
|
vty_out(vty, " -aborting! (depth limit)\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -586,7 +584,7 @@ static void pretty_print_dot(FILE *ofd, unsigned opts, struct graph_node *start,
|
|||||||
if (visited[i] == start)
|
if (visited[i] == start)
|
||||||
return;
|
return;
|
||||||
visited[(*visitpos)++] = start;
|
visited[(*visitpos)++] = start;
|
||||||
if ((*visitpos) == MAXDEPTH * MAXDEPTH)
|
if ((*visitpos) == CMD_ARGC_MAX * CMD_ARGC_MAX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
snprintf(tokennum, sizeof(tokennum), "%d?", tok->type);
|
snprintf(tokennum, sizeof(tokennum), "%d?", tok->type);
|
||||||
@ -626,7 +624,7 @@ static void pretty_print_dot(FILE *ofd, unsigned opts, struct graph_node *start,
|
|||||||
}
|
}
|
||||||
fprintf(ofd, ">, style = filled, fillcolor = \"%s\" ];\n", color);
|
fprintf(ofd, ">, style = filled, fillcolor = \"%s\" ];\n", color);
|
||||||
|
|
||||||
if (stackpos == MAXDEPTH)
|
if (stackpos == CMD_ARGC_MAX)
|
||||||
return;
|
return;
|
||||||
stack[stackpos++] = start;
|
stack[stackpos++] = start;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user