Re: [PATCH nft 3/3,v2] netlink_linearize: skip set element expression in map statement key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 26, 2023 at 06:02:16PM +0200, Pablo Neira Ayuso wrote:
[...]
> diff --git a/src/parser_json.c b/src/parser_json.c
> index 16961d6013af..78895befbc6c 100644
> --- a/src/parser_json.c
> +++ b/src/parser_json.c
> @@ -2416,6 +2416,63 @@ static struct stmt *json_parse_set_stmt(struct json_ctx *ctx,
>  	return stmt;
>  }
>  
> +static struct stmt *json_parse_map_stmt(struct json_ctx *ctx,
> +					const char *key, json_t *value)
> +{
> +	struct expr *expr, *expr2, *expr_data;
> +	json_t *elem, *data, *stmt_json;
> +	const char *opstr, *set;
> +	struct stmt *stmt;
> +	int op;
> +
> +	if (json_unpack_err(ctx, value, "{s:s, s:o, s:o, s:s}",
> +			    "op", &opstr, "elem", &elem, "data", &data, "map", &set))
> +		return NULL;
> +
> +	if (!strcmp(opstr, "add")) {
> +		op = NFT_DYNSET_OP_ADD;
> +	} else if (!strcmp(opstr, "update")) {
> +		op = NFT_DYNSET_OP_UPDATE;
> +	} else if (!strcmp(opstr, "delete")) {
> +		op = NFT_DYNSET_OP_DELETE;
> +	} else {
> +		json_error(ctx, "Unknown set statement op '%s'.", opstr);

s/set/map/

> +		return NULL;
> +	}
> +
> +	expr = json_parse_set_elem_expr_stmt(ctx, elem);
> +	if (!expr) {
> +		json_error(ctx, "Illegal set statement element.");

s/set/map/

> +		return NULL;
> +	}
> +
> +	expr_data = json_parse_set_elem_expr_stmt(ctx, data);
> +	if (!expr_data) {
> +		json_error(ctx, "Illegal map expression data.");
> +		expr_free(expr);
> +		return NULL;
> +	}
> +
> +	if (set[0] != '@') {
> +		json_error(ctx, "Illegal set reference in set statement.");

s/set/map/g

Cheers, Phil



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux