Blame SOURCES/0013-rule-Fix-for-potential-off-by-one-in-cmd_add_loc.patch

168a1c
From 5fbf4169fba1dfef0f461c4fe31bed70610ebce2 Mon Sep 17 00:00:00 2001
168a1c
From: Phil Sutter <phil@nwl.cc>
168a1c
Date: Fri, 11 Jun 2021 17:08:34 +0200
168a1c
Subject: [PATCH] rule: Fix for potential off-by-one in cmd_add_loc()
168a1c
168a1c
Using num_attrs as index means it must be at max one less than the
168a1c
array's size at function start.
168a1c
168a1c
Fixes: 27362a5bfa433 ("rule: larger number of error locations")
168a1c
Signed-off-by: Phil Sutter <phil@nwl.cc>
168a1c
(cherry picked from commit 2d0a7a9adeb30708d6fbbee57476c0d4b9214dbd)
168a1c
Signed-off-by: Phil Sutter <psutter@redhat.com>
168a1c
---
168a1c
 src/rule.c | 2 +-
168a1c
 1 file changed, 1 insertion(+), 1 deletion(-)
168a1c
168a1c
diff --git a/src/rule.c b/src/rule.c
168a1c
index e4bb6bae276a0..03422da3a7560 100644
168a1c
--- a/src/rule.c
168a1c
+++ b/src/rule.c
168a1c
@@ -1491,7 +1491,7 @@ struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj,
168a1c
 
168a1c
 void cmd_add_loc(struct cmd *cmd, uint16_t offset, const struct location *loc)
168a1c
 {
168a1c
-	if (cmd->num_attrs > NFT_NLATTR_LOC_MAX)
168a1c
+	if (cmd->num_attrs >= NFT_NLATTR_LOC_MAX)
168a1c
 		return;
168a1c
 
168a1c
 	cmd->attr[cmd->num_attrs].offset = offset;
168a1c
-- 
168a1c
2.31.1
168a1c