Blame SOURCES/0005-parser_json-Fix-for-memleak-in-tcp-option-error-path.patch

195495
From a79e92c0f6761a748ef3cbffd26a4f1db82b4b3e Mon Sep 17 00:00:00 2001
195495
From: Phil Sutter <phil@nwl.cc>
195495
Date: Fri, 11 Jun 2021 16:07:02 +0200
195495
Subject: [PATCH] parser_json: Fix for memleak in tcp option error path
195495
195495
If 'kind' value is invalid, the function returned without freeing 'expr'
195495
first. Fix this by performing the check before allocation.
195495
195495
Fixes: cb21869649208 ("json: tcp: add raw tcp option match support")
195495
Signed-off-by: Phil Sutter <phil@nwl.cc>
195495
(cherry picked from commit f7b0eef8391ae7f89a3a82f6eeecaebe199224d7)
195495
Signed-off-by: Phil Sutter <psutter@redhat.com>
195495
---
195495
 src/parser_json.c | 6 +++---
195495
 1 file changed, 3 insertions(+), 3 deletions(-)
195495
195495
diff --git a/src/parser_json.c b/src/parser_json.c
195495
index f0486b77a225a..85d05ce27eef3 100644
195495
--- a/src/parser_json.c
195495
+++ b/src/parser_json.c
195495
@@ -611,12 +611,12 @@ static struct expr *json_parse_tcp_option_expr(struct json_ctx *ctx,
195495
 			"base", &kind, "offset", &offset, "len", &len)) {
195495
 		uint32_t flag = 0;
195495
 
195495
-		expr = tcpopt_expr_alloc(int_loc, kind,
195495
-					 TCPOPT_COMMON_KIND);
195495
-
195495
 		if (kind < 0 || kind > 255)
195495
 			return NULL;
195495
 
195495
+		expr = tcpopt_expr_alloc(int_loc, kind,
195495
+					 TCPOPT_COMMON_KIND);
195495
+
195495
 		if (offset == TCPOPT_COMMON_KIND && len == 8)
195495
 			flag = NFT_EXTHDR_F_PRESENT;
195495
 
195495
-- 
195495
2.31.1
195495