summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2018-10-28 05:41:13 +0000
committerKristof Provost <kp@FreeBSD.org>2018-10-28 05:41:13 +0000
commitd3f65324948aeef11ed5fbe193e33e1e6898d206 (patch)
treeb0dd88a074e1279f41abd385e7e913a65e8a7c7c /sbin/pfctl
parent71f8908a1a49f7cb8fb4aa09670782fae017979e (diff)
downloadsrc-test-d3f65324948aeef11ed5fbe193e33e1e6898d206.tar.gz
src-test-d3f65324948aeef11ed5fbe193e33e1e6898d206.zip
pfctl: Do not allow whitespace in macro names
i.e. "this is" = "a variable" is not valid. It was accepted by the parser, but the variable could not be used afterwards. Obtained from: OpenBSD
Notes
Notes: svn path=/head/; revision=339837
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/parse.y8
1 files changed, 8 insertions, 0 deletions
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 3602ba8eb5aab..b0410f452b893 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -758,8 +758,16 @@ numberstring : NUMBER {
;
varset : STRING '=' varstring {
+ char *s = $1;
if (pf->opts & PF_OPT_VERBOSE)
printf("%s = \"%s\"\n", $1, $3);
+ while (*s++) {
+ if (isspace((unsigned char)*s)) {
+ yyerror("macro name cannot contain "
+ "whitespace");
+ YYERROR;
+ }
+ }
if (symset($1, $3, 0) == -1)
err(1, "cannot store variable %s", $1);
free($1);