X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_pipeline%2Frte_swx_pipeline_spec.c;h=f7884491b37cbb0dede324d30e0b129a033f95b0;hb=5b38d8cd4663;hp=06e1ab4380ac7c807d6ebeb1a6a31e6f21bb5abe;hpb=c0c9dcef88d94fd8320068316a10dfab3d289887;p=dpdk.git diff --git a/lib/librte_pipeline/rte_swx_pipeline_spec.c b/lib/librte_pipeline/rte_swx_pipeline_spec.c index 06e1ab4380..f7884491b3 100644 --- a/lib/librte_pipeline/rte_swx_pipeline_spec.c +++ b/lib/librte_pipeline/rte_swx_pipeline_spec.c @@ -10,9 +10,8 @@ #include "rte_swx_pipeline.h" #include "rte_swx_ctl.h" -#define MAX_LINE_LENGTH 256 -#define MAX_TOKENS 16 -#define MAX_INSTRUCTION_LENGTH 256 +#define MAX_LINE_LENGTH RTE_SWX_INSTRUCTION_SIZE +#define MAX_TOKENS RTE_SWX_INSTRUCTION_TOKENS_MAX #define STRUCT_BLOCK 0 #define ACTION_BLOCK 1 @@ -35,9 +34,17 @@ struct extobj_spec { static void extobj_spec_free(struct extobj_spec *s) { + if (!s) + return; + free(s->name); + s->name = NULL; + free(s->extern_type_name); + s->extern_type_name = NULL; + free(s->pragma); + s->pragma = NULL; } static int @@ -246,8 +253,14 @@ struct header_spec { static void header_spec_free(struct header_spec *s) { + if (!s) + return; + free(s->name); + s->name = NULL; + free(s->struct_type_name); + s->struct_type_name = NULL; } static int @@ -297,7 +310,11 @@ struct metadata_spec { static void metadata_spec_free(struct metadata_spec *s) { + if (!s) + return; + free(s->struct_type_name); + s->struct_type_name = NULL; } static int @@ -424,7 +441,7 @@ action_block_parse(struct action_spec *s, uint32_t *err_line, const char **err_msg) { - char buffer[MAX_INSTRUCTION_LENGTH], *instr; + char buffer[RTE_SWX_INSTRUCTION_SIZE], *instr; const char **new_instructions; uint32_t i; @@ -988,7 +1005,7 @@ apply_block_parse(struct apply_spec *s, uint32_t *err_line, const char **err_msg) { - char buffer[MAX_INSTRUCTION_LENGTH], *instr; + char buffer[RTE_SWX_INSTRUCTION_SIZE], *instr; const char **new_instructions; uint32_t i; @@ -1108,6 +1125,17 @@ rte_swx_pipeline_build_from_spec(struct rte_swx_pipeline *p, goto error; } + /* Handle excessively long tokens. */ + if (strnlen(token, RTE_SWX_NAME_SIZE) >= + RTE_SWX_NAME_SIZE) { + if (err_line) + *err_line = n_lines; + if (err_msg) + *err_msg = "Token too big."; + status = -EINVAL; + goto error; + } + /* Save token. */ tokens[n_tokens] = token; n_tokens++;