diff options
| author | Kristof Provost <kp@FreeBSD.org> | 2024-08-29 10:08:32 +0000 |
|---|---|---|
| committer | Kristof Provost <kp@FreeBSD.org> | 2024-09-16 11:48:58 +0000 |
| commit | 80eb861dc2a7960e1acc74796cf0c937472a5dba (patch) | |
| tree | c4802fb365f2d48c2f7a4b092785f8ab2dd247e2 | |
| parent | 357c95ea4663225803e6f1fa89499286a018eb89 (diff) | |
pfctl: lex <=, >=, and != into a single token
lex <=, >=, and != into a single token for correctness and to reduce the
lookahead in the parser
ok henning otto
Reviewed by: zlei
Obtained from: OpenBSD, deraadt <deraadt@openbsd.org>, e6e3ecf338
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D46582
| -rw-r--r-- | sbin/pfctl/parse.y | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 55b5310b61e3..cfa6c85b5c0a 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -517,7 +517,7 @@ int parseport(char *, struct range *r, int); %token STICKYADDRESS ENDPI MAXSRCSTATES MAXSRCNODES SOURCETRACK GLOBAL RULE %token MAXSRCCONN MAXSRCCONNRATE OVERLOAD FLUSH SLOPPY PFLOW %token TAGGED TAG IFBOUND FLOATING STATEPOLICY STATEDEFAULTS ROUTE SETTOS -%token DIVERTTO DIVERTREPLY BRIDGE_TO RECEIVEDON +%token DIVERTTO DIVERTREPLY BRIDGE_TO RECEIVEDON NE LE GE %token <v.string> STRING %token <v.number> NUMBER %token <v.i> PORTBINARY @@ -5249,10 +5249,10 @@ yesno : NO { $$ = 0; } ; unaryop : '=' { $$ = PF_OP_EQ; } - | '!' '=' { $$ = PF_OP_NE; } - | '<' '=' { $$ = PF_OP_LE; } + | NE { $$ = PF_OP_NE; } + | LE { $$ = PF_OP_LE; } | '<' { $$ = PF_OP_LT; } - | '>' '=' { $$ = PF_OP_GE; } + | GE { $$ = PF_OP_GE; } | '>' { $$ = PF_OP_GT; } ; @@ -6630,12 +6630,19 @@ top: if (yylval.v.string == NULL) err(1, "yylex: strdup"); return (STRING); + case '!': + next = lgetc(0); + if (next == '=') + return (NE); + lungetc(next); + break; case '<': next = lgetc(0); if (next == '>') { yylval.v.i = PF_OP_XRG; return (PORTBINARY); - } + } else if (next == '=') + return (LE); lungetc(next); break; case '>': @@ -6643,7 +6650,8 @@ top: if (next == '<') { yylval.v.i = PF_OP_IRG; return (PORTBINARY); - } + } else if (next == '=') + return (GE); lungetc(next); break; case '-': |
