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.
Unified · Split
| @@ -8,6 +8,7 @@ · 7 unmodified lines | ||
| 8 | 8 | #define NFT_SET_MAXNAMELEN NFT_NAME_MAXLEN |
| 9 | 9 | #define NFT_OBJ_MAXNAMELEN NFT_NAME_MAXLEN |
| 10 | 10 | #define NFT_USERDATA_MAXLEN 256 |
| 11 | +#define NFT_OSF_MAXGENRELEN 16 | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * enum nft_registers - nf_tables registers |
| @@ -4,8 +4,6 @@ · 3 unmodified lines | ||
| 4 | 4 | #include <net/netfilter/nf_tables.h> |
| 5 | 5 | #include <linux/netfilter/nfnetlink_osf.h> |
| 6 | 6 | |
| 7 | −#define OSF_GENRE_SIZE 32 | |
| 8 | − | |
| 9 | 7 | struct nft_osf { |
| 10 | 8 | enum nft_registers dreg:8; |
| 11 | 9 | }; |
| @@ -37,9 +35,9 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs, · 25 unmodified lines | ||
| 37 | 35 | |
| 38 | 36 | os_name = nf_osf_find(skb, nf_osf_fingers); |
| 39 | 37 | if (!os_name) |
| 40 | − strncpy((char *)dest, "unknown", IFNAMSIZ); | |
| 38 | + strncpy((char *)dest, "unknown", NFT_OSF_MAXGENRELEN); | |
| 41 | 39 | else |
| 42 | − strncpy((char *)dest, os_name, IFNAMSIZ); | |
| 40 | + strncpy((char *)dest, os_name, NFT_OSF_MAXGENRELEN); | |
| 43 | 41 | } |
| 44 | 42 | |
| 45 | 43 | 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 | ||
| 51 | 49 | |
| 52 | 50 | priv->dreg = nft_parse_register(tb[NFTA_OSF_DREG]); |
| 53 | 51 | err = nft_validate_register_store(ctx, priv->dreg, NULL, |
| 54 | − NFTA_DATA_VALUE, OSF_GENRE_SIZE); | |
| 52 | + NFTA_DATA_VALUE, NFT_OSF_MAXGENRELEN); | |
| 55 | 53 | if (err < 0) |
| 56 | 54 | return err; |
| 57 | 55 | |