From 1062d16c233907cb546d02b714ad16c6c72388cc Mon Sep 17 00:00:00 2001 From: kp Date: Wed, 17 Aug 2016 09:21:55 +0000 Subject: [PATCH] MFC r303663: MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit pfctl: Allow TOS bits to be cleared TOS value 0 is valid, so use 256 as an invalid value rather than zero. This allows users to enforce TOS == 0 with pf. Reported by: Radek Krejča git-svn-id: svn://svn.freebsd.org/base/stable/10@304281 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sbin/pfctl/parse.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 56ccd1101..e468a38b2 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -3517,8 +3517,8 @@ tos : STRING { else if ($1[0] == '0' && $1[1] == 'x') $$ = strtoul($1, NULL, 16); else - $$ = 0; /* flag bad argument */ - if (!$$ || $$ > 255) { + $$ = 256; /* flag bad argument */ + if ($$ < 0 || $$ > 255) { yyerror("illegal tos value %s", $1); free($1); YYERROR; @@ -3527,7 +3527,7 @@ tos : STRING { } | NUMBER { $$ = $1; - if (!$$ || $$ > 255) { + if ($$ < 0 || $$ > 255) { yyerror("illegal tos value %s", $1); YYERROR; } -- 2.45.0