Skip to content

Commit 35a8a3b

Browse files
ffmanceraummakynes
authored andcommitted
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: Fernando Fernandez Mancera <ffmancera@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 9814670 commit 35a8a3b

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎include/uapi/linux/netfilter/nf_tables.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
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,
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,
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

0 commit comments

Comments
 (0)