When parsing the optional "field" property, use return code of json_unpack() directly to check if it was present or not. Signed-off-by: Phil Sutter <phil@xxxxxx> --- src/parser_json.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/parser_json.c b/src/parser_json.c index f3d2c0f1d3dfc..bd1c0a04993c8 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -479,20 +479,19 @@ static struct expr *json_parse_payload_expr(struct json_ctx *ctx, static struct expr *json_parse_tcp_option_expr(struct json_ctx *ctx, const char *type, json_t *root) { - const char *desc, *field = NULL; + const char *desc, *field; int descval, fieldval; struct expr *expr; if (json_unpack_err(ctx, root, "{s:s}", "name", &desc)) return NULL; - json_unpack(root, "{s:s}", "field", &field); if (json_parse_tcp_option_type(desc, &descval)) { json_error(ctx, "Unknown tcp option name '%s'.", desc); return NULL; } - if (!field) { + if (json_unpack(root, "{s:s}", "field", &field)) { expr = tcpopt_expr_alloc(int_loc, descval, TCPOPTHDR_FIELD_KIND); expr->exthdr.flags = NFT_EXTHDR_F_PRESENT; -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html