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