]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
optimize: Do not return garbage from stack
authorPhil Sutter <phil@nwl.cc>
Fri, 13 Jan 2023 16:09:53 +0000 (17:09 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 13 Jan 2023 16:11:18 +0000 (17:11 +0100)
If input does not contain a single 'add' command (unusual, but
possible), 'ret' value was not initialized by nft_optimize() before
returning its value.

Fixes: fb298877ece27 ("src: add ruleset optimization infrastructure")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/optimize.c

index 12cae00da4ab42608376ae377f6435579f6f9bb0..289c442dc915eb833f0347e154c10a8242d3d6f5 100644 (file)
@@ -1217,7 +1217,7 @@ static int cmd_optimize(struct nft_ctx *nft, struct cmd *cmd)
 int nft_optimize(struct nft_ctx *nft, struct list_head *cmds)
 {
        struct cmd *cmd;
-       int ret;
+       int ret = 0;
 
        list_for_each_entry(cmd, cmds, list) {
                switch (cmd->op) {