summaryrefslogtreecommitdiff
path: root/sbin/pfctl/parse.y
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2007-09-23 21:00:01 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2007-09-23 21:00:01 +0000
commit5f6fd67864ae90d21af62c72ef95920255078cae (patch)
treef99fcbd9356d4b8f78721127731d7673c3997317 /sbin/pfctl/parse.y
parent12c6e1091233851f57058bc75701015cafe00237 (diff)
Allow numbers to be used as unquoted strings again.
While there, also restrict the use of concatenated, unquoted strings for variable assignments only. Eyeballed by markus@, OK henning@
Diffstat (limited to 'sbin/pfctl/parse.y')
-rw-r--r--sbin/pfctl/parse.y41
1 files changed, 25 insertions, 16 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 6c43347a8f5..e165ff99989 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.522 2007/09/12 18:49:03 deraadt Exp $ */
+/* $OpenBSD: parse.y,v 1.523 2007/09/23 20:59:59 mpf Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -447,7 +447,7 @@ typedef struct {
%type <v.gid> gids gid_list gid_item
%type <v.route> route
%type <v.redirection> redirection redirpool
-%type <v.string> label string tag anchorname
+%type <v.string> label string strings tag anchorname
%type <v.keep_state> keep
%type <v.state_opt> state_opt_spec state_opt_list state_opt_item
%type <v.logquick> logquick quick log logopts logopt
@@ -627,16 +627,25 @@ option : SET OPTIMIZATION STRING {
}
;
-string : string STRING {
+strings : strings string {
if (asprintf(&$$, "%s %s", $1, $2) == -1)
err(1, "string: asprintf");
free($1);
free($2);
}
- | STRING
+ | string
+ ;
+
+string : STRING
+ | NUMBER {
+ if (asprintf(&$$, "%lld", $1) == -1) {
+ yyerror("string: asprintf");
+ YYERROR;
+ }
+ }
;
-varset : STRING '=' string {
+varset : STRING '=' strings {
if (pf->opts & PF_OPT_VERBOSE)
printf("%s = \"%s\"\n", $1, $3);
if (symset($1, $3, 0) == -1)
@@ -646,7 +655,7 @@ varset : STRING '=' string {
}
;
-anchorname : STRING { $$ = $1; }
+anchorname : string { $$ = $1; }
| /* empty */ { $$ = NULL; }
;
@@ -1279,7 +1288,7 @@ table_opt : STRING {
entries);
table_opts.init_addr = 1;
}
- | FILENAME STRING {
+ | FILENAME string {
struct node_tinit *ti;
if (!(ti = calloc(1, sizeof(*ti))))
@@ -1315,7 +1324,7 @@ altqif : ALTQ interface queue_opts QUEUE qassign {
}
;
-queuespec : QUEUE STRING interface queue_opts qassign {
+queuespec : QUEUE string interface queue_opts qassign {
struct pf_altq a;
if (check_rulestate(PFCTL_STATE_QUEUE)) {
@@ -1659,7 +1668,7 @@ qassign_list : qassign_item { $$ = $1; }
}
;
-qassign_item : STRING {
+qassign_item : string {
$$ = calloc(1, sizeof(struct node_queue));
if ($$ == NULL)
err(1, "qassign_item: calloc");
@@ -2620,7 +2629,7 @@ host : STRING {
for (n = $1; n != NULL; n = n->next)
set_ipmask(n, $3);
}
- | '<' STRING '>' {
+ | '<' string '>' {
if (strlen($2) >= PF_TABLE_NAME_SIZE) {
yyerror("table name '%s' too long", $2);
free($2);
@@ -3285,7 +3294,7 @@ state_opt_item : MAXIMUM NUMBER {
$$->next = NULL;
$$->tail = $$;
}
- | OVERLOAD '<' STRING '>' flush {
+ | OVERLOAD '<' string '>' flush {
if (strlen($3) >= PF_TABLE_NAME_SIZE) {
yyerror("table name '%s' too long", $3);
free($3);
@@ -3366,18 +3375,18 @@ state_opt_item : MAXIMUM NUMBER {
}
;
-label : LABEL STRING {
+label : LABEL string {
$$ = $2;
}
;
-qname : QUEUE STRING {
+qname : QUEUE string {
$$.qname = $2;
}
- | QUEUE '(' STRING ')' {
+ | QUEUE '(' string ')' {
$$.qname = $3;
}
- | QUEUE '(' STRING comma STRING ')' {
+ | QUEUE '(' string comma string ')' {
$$.qname = $3;
$$.pqname = $5;
}
@@ -3943,7 +3952,7 @@ binatrule : no BINAT natpasslog interface af proto FROM host TO ipspec tag
;
tag : /* empty */ { $$ = NULL; }
- | TAG STRING { $$ = $2; }
+ | TAG string { $$ = $2; }
;
tagged : /* empty */ { $$.neg = 0; $$.name = NULL; }