diff mbox series

[nft] src: Fix literal check for inet_service type

Message ID 20180910141810.29070-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] src: Fix literal check for inet_service type | expand

Commit Message

Phil Sutter Sept. 10, 2018, 2:18 p.m. UTC
Since literal option is supposed to be a level, matching for equality is
not correct here since the level may be higher than NFT_LITERAL_PORT.

This fixes for ports being printed numerically if '-l' option was given
twice.

Fixes: b0f6a45b25dd1 ("src: add --literal option")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/datatype.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Sept. 10, 2018, 2:24 p.m. UTC | #1
On Mon, Sep 10, 2018 at 04:18:10PM +0200, Phil Sutter wrote:
> Since literal option is supposed to be a level, matching for equality is
> not correct here since the level may be higher than NFT_LITERAL_PORT.
> 
> This fixes for ports being printed numerically if '-l' option was given
> twice.

Applied, thanks.
diff mbox series

Patch

diff --git a/src/datatype.c b/src/datatype.c
index bc3df214074c1..50af3df04f744 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -648,7 +648,7 @@  static void inet_service_print(const struct expr *expr, struct output_ctx *octx)
 
 void inet_service_type_print(const struct expr *expr, struct output_ctx *octx)
 {
-	if (octx->literal == NFT_LITERAL_PORT) {
+	if (octx->literal >= NFT_LITERAL_PORT) {
 		inet_service_print(expr, octx);
 		return;
 	}