expr: immediate: check for chain attribute to release chain name
Pablo Neira Ayuso
maintainerPATCH 1/3 expr: immediate: check for chain attribute to release chain name
Check for chain name attribute to release chain name, for consistency with other existing attributes.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/data_reg.h | 2 -- src/expr/data_reg.c | 12 ------------ src/expr/immediate.c | 4 ++-- 3 files changed, 2 insertions(+), 16 deletions(-)
include/data_reg.h +0 -2
@@ -35,8 +35,6 @@ int nftnl_data_reg_snprintf(char *buf, size_t size,struct nlattr ;int nftnl_parse_data (union nftnl_data_reg *data,struct nlattr *attr,int *type); -void nftnl_free_verdict (const union nftnl_data_reg *data); -int nftnl_data_cpy (union nftnl_data_reg *dreg,const void *src,uint32_t len);#endif
src/expr/data_reg.c +0 -12
@@ -206,18 +206,6 @@ int nftnl_parse_data(union nftnl_data_reg *data, struct nlattr *attr, int *type)return ret; } -void nftnl_free_verdict (const union nftnl_data_reg *data) -{ -switch (data->verdict) { -case NFT_JUMP : -case NFT_GOTO : -xfree (data->chain); -break ; -default : -break ; - } -} -int nftnl_data_cpy (union nftnl_data_reg *dreg,const void *src,uint32_t len) {int ret =0 ;
src/expr/immediate.c +2 -2
@@ -214,8 +214,8 @@ static void nftnl_expr_immediate_free(const struct nftnl_expr *e) {struct nftnl_expr_immediate *imm =nftnl_expr_data (e); -if (e->flags & (1 <<NFTNL_EXPR_IMM_VERDICT )) -nftnl_free_verdict (&imm->data); +if (e->flags & (1 <<NFTNL_EXPR_IMM_CHAIN )) +xfree (imm->data.chain); }struct expr_ops expr_ops_immediate = {
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 2/3 udata: incorrect userdata buffer size validation
Use the current remaining space in the buffer to ensure more userdata attributes still fit in, buf->size is the total size of the userdata buffer.
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- src/udata.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
src/udata.c +7 -1
@@ -42,6 +42,11 @@ uint32_t nftnl_udata_buf_len(const struct nftnl_udata_buf *buf)return (uint32_t )(buf->end - buf->data); } +static uint32_t nftnl_udata_buf_space (const struct nftnl_udata_buf *buf) +{ +return buf->size -nftnl_udata_buf_len (buf); +} +EXPORT_SYMBOL (nftnl_udata_buf_data);void *nftnl_udata_buf_data (const struct nftnl_udata_buf *buf) {
@@ -74,7 +79,8 @@ bool nftnl_udata_put(struct nftnl_udata_buf *buf, uint8_t type, uint32_t len, {struct nftnl_udata *attr; -if (len >UINT8_MAX || buf->size < len +sizeof (struct nftnl_udata )) +if (len >UINT8_MAX || +nftnl_udata_buf_space (buf) < len +sizeof (struct nftnl_udata ))return false; attr = (struct nftnl_udata *)buf->end;
Signature · 1 line
2.30.2
Pablo Neira Ayuso
maintainerPATCH 3/3 utils: remove unused code
In reply to Pablo Neira AyusoRemove several internal code that have no use these days:
- nftnl_str2family
- nftnl_strtoi
- nftnl_get_value
- enum nftnl_type
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- include/utils.h | 19 ----- src/utils.c | 194 ------------------------------------------------ 2 files changed, 213 deletions(-)
include/utils.h +0 -19
@@ -68,27 +68,8 @@ void __nftnl_assert_attr_exists(uint16_t attr, uint16_t attr_max,#define array_size (arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))const char *nftnl_family2str (uint32_t family); -int nftnl_str2family (const char *family); - -enum nftnl_type { -NFTNL_TYPE_U8 , -NFTNL_TYPE_U16 , -NFTNL_TYPE_U32 , -NFTNL_TYPE_U64 , -NFTNL_TYPE_S8 , -NFTNL_TYPE_S16 , -NFTNL_TYPE_S32 , -NFTNL_TYPE_S64 , -}; - -int nftnl_strtoi (const char *string,int base,void *number,enum nftnl_type type); -int nftnl_get_value (enum nftnl_type type,void *val,void *out);const char *nftnl_verdict2str (uint32_t verdict); -int nftnl_str2verdict (const char *verdict,int *verdict_num); - -const char *nftnl_cmd2tag (enum nftnl_cmd_type cmd); -uint32_t nftnl_str2cmd (const char *cmd);enum nftnl_cmd_type nftnl_flag2cmd (uint32_t flags);
src/utils.c +0 -194
212 lines not on this page · raw message
Signature · 1 line
2.30.2