]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: Fix for potential off-by-one in cmd_add_loc()
authorPhil Sutter <phil@nwl.cc>
Fri, 11 Jun 2021 15:08:34 +0000 (17:08 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 14 Jun 2021 11:31:07 +0000 (13:31 +0200)
Using num_attrs as index means it must be at max one less than the
array's size at function start.

Fixes: 27362a5bfa433 ("rule: larger number of error locations")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/rule.c

index dbbe744eee0d84a04618645a088040305b9d0aa9..92daf2f33b76b3f94bd00e0ceb031532dff629d2 100644 (file)
@@ -1275,7 +1275,7 @@ struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj,
 
 void cmd_add_loc(struct cmd *cmd, uint16_t offset, const struct location *loc)
 {
-       if (cmd->num_attrs > NFT_NLATTR_LOC_MAX)
+       if (cmd->num_attrs >= NFT_NLATTR_LOC_MAX)
                return;
 
        cmd->attr[cmd->num_attrs].offset = offset;