History

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.

Fernando Fernandez Mancera committed 8 years ago

Commit 35a8a3b1 parent 98146702 files · +4 −5Browse files

Unified · Split

2 files
  1. include/uapi/linux/netfilter/nf_tables.h +1 −0
  2. net/netfilter/nft_osf.c +3 −5
include/uapi/linux/netfilter/nf_tables.h+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #define NFT_SET_MAXNAMELEN NFT_NAME_MAXLEN
99 #define NFT_OBJ_MAXNAMELEN NFT_NAME_MAXLEN
1010 #define NFT_USERDATA_MAXLEN 256
11+#define NFT_OSF_MAXGENRELEN 16
1112
1213 /**
1314 * enum nft_registers - nf_tables registers
net/netfilter/nft_osf.c+3−5
@@ -4,8 +4,6 @@ · 3 unmodified lines
44 #include <net/netfilter/nf_tables.h>
55 #include <linux/netfilter/nfnetlink_osf.h>
66
7−#define OSF_GENRE_SIZE 32
8−
97 struct nft_osf {
108 enum nft_registers dreg:8;
119 };
@@ -37,9 +35,9 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs, · 25 unmodified lines
3735
3836 os_name = nf_osf_find(skb, nf_osf_fingers);
3937 if (!os_name)
40− strncpy((char *)dest, "unknown", IFNAMSIZ);
38+ strncpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN);
4139 else
42− strncpy((char *)dest, os_name, IFNAMSIZ);
40+ strncpy((char *)dest, os_name, NFT_OSF_MAXGENRELEN);
4341 }
4442
4543 static int nft_osf_init(const struct nft_ctx *ctx,
@@ -51,7 +49,7 @@ static int nft_osf_init(const struct nft_ctx *ctx, · 5 unmodified lines
5149
5250 priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]);
5351 err = nft_validate_register_store(ctx, priv->dreg, NULL,
54− NFTA_DATA_VALUE, OSF_GENRE_SIZE);
52+ NFTA_DATA_VALUE, NFT_OSF_MAXGENRELEN);
5553 if (err < 0)
5654 return err;
5755