diff options
author | Florian Westphal <fw@strlen.de> | 2018-04-28 11:43:09 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-04-29 10:45:26 +0200 |
commit | fb7ae9fdfe56d51c85ae7b4bcdb91e8ddbfae8ea (patch) | |
tree | 83e5fb8f90339b722414fd09daea0dcc57bb2914 /iptables | |
parent | 36976c4b54061b0147d56892ac9d402dae3069df (diff) |
xtables-compat: truncate comments to 254 bytes
Kernel clamps udata size at 256 bytes, udata size however also includes
internal bookkeeping which brings us over this limit.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables')
-rw-r--r-- | iptables/nft.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/iptables/nft.c b/iptables/nft.c index c18798c9..e7cb827b 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -1041,12 +1041,14 @@ enum udata_type { int add_comment(struct nftnl_rule *r, const char *comment) { struct nftnl_udata_buf *udata; + char comm[254]; udata = nftnl_udata_buf_alloc(NFT_USERDATA_MAXLEN); if (!udata) return -ENOMEM; - if (!nftnl_udata_put_strz(udata, UDATA_TYPE_COMMENT, comment)) + snprintf(comm, sizeof(comm), "%s", comment); + if (!nftnl_udata_put_strz(udata, UDATA_TYPE_COMMENT, comm)) return -ENOMEM; nftnl_rule_set_data(r, NFTNL_RULE_USERDATA, nftnl_udata_buf_data(udata), |