Commit 35a8a3bd authored by Fernando Fernandez Mancera's avatar Fernando Fernandez Mancera Committed by Pablo Neira Ayuso

netfilter: nft_osf: use NFT_OSF_MAXGENRELEN instead of IFNAMSIZ

As no "genre" on pf.os exceed 16 bytes of length, we reduce
NFT_OSF_MAXGENRELEN parameter to 16 bytes and use it instead of IFNAMSIZ.
Signed-off-by: default avatarFernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 98146703
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define NFT_SET_MAXNAMELEN NFT_NAME_MAXLEN #define NFT_SET_MAXNAMELEN NFT_NAME_MAXLEN
#define NFT_OBJ_MAXNAMELEN NFT_NAME_MAXLEN #define NFT_OBJ_MAXNAMELEN NFT_NAME_MAXLEN
#define NFT_USERDATA_MAXLEN 256 #define NFT_USERDATA_MAXLEN 256
#define NFT_OSF_MAXGENRELEN 16
/** /**
* enum nft_registers - nf_tables registers * enum nft_registers - nf_tables registers
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include <net/netfilter/nf_tables.h> #include <net/netfilter/nf_tables.h>
#include <linux/netfilter/nfnetlink_osf.h> #include <linux/netfilter/nfnetlink_osf.h>
#define OSF_GENRE_SIZE 32
struct nft_osf { struct nft_osf {
enum nft_registers dreg:8; enum nft_registers dreg:8;
}; };
...@@ -37,9 +35,9 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs, ...@@ -37,9 +35,9 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
os_name = nf_osf_find(skb, nf_osf_fingers); os_name = nf_osf_find(skb, nf_osf_fingers);
if (!os_name) if (!os_name)
strncpy((char *)dest, "unknown", IFNAMSIZ); strncpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN);
else else
strncpy((char *)dest, os_name, IFNAMSIZ); strncpy((char *)dest, os_name, NFT_OSF_MAXGENRELEN);
} }
static int nft_osf_init(const struct nft_ctx *ctx, static int nft_osf_init(const struct nft_ctx *ctx,
...@@ -51,7 +49,7 @@ static int nft_osf_init(const struct nft_ctx *ctx, ...@@ -51,7 +49,7 @@ static int nft_osf_init(const struct nft_ctx *ctx,
priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]); priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]);
err = nft_validate_register_store(ctx, priv->dreg, NULL, err = nft_validate_register_store(ctx, priv->dreg, NULL,
NFTA_DATA_VALUE, OSF_GENRE_SIZE); NFTA_DATA_VALUE, NFT_OSF_MAXGENRELEN);
if (err < 0) if (err < 0)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment