]> git.ipfire.org Git - thirdparty/nftables.git/commit
datatype: clamp boolean value to 0 and 1
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 31 Jan 2025 11:54:32 +0000 (12:54 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 7 Feb 2025 10:53:32 +0000 (11:53 +0100)
commitafb6a8e66a11178cbdbfc152c4aa9dda961b2140
treea324b6a69b3cc2a621ac14b58b1c12ae746a88b2
parentc029dcb14940936dbeddc2947316c9dbc5b93656
datatype: clamp boolean value to 0 and 1

If user provides a numeric value larger than 0 or 1, match never
happens:

 # nft --debug=netlink add rule x y tcp option sack-perm 4
 ip x y
  [ exthdr load tcpopt 1b @ 4 + 0 present => reg 1 ]
  [ cmp eq reg 1 0x00000004 ]

After this update:

 # nft --debug=netlink add rule x y tcp option sack-perm 4
 ip x y
  [ exthdr load tcpopt 1b @ 4 + 0 present => reg 1 ]
  [ cmp eq reg 1 0x00000001 ]

This is to address a rare corner case, in case user specifies the
boolean value through the integer base type.

Fixes: 9fd9baba43c8 ("Introduce boolean datatype and boolean expression")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/datatype.c