]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[150-add-sub-option-classification] Accept only integers for sub-option codes
authorFrancis Dupont <fdupont@isc.org>
Fri, 14 Jun 2019 18:52:25 +0000 (20:52 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Wed, 14 Aug 2019 08:13:02 +0000 (10:13 +0200)
src/lib/eval/parser.yy

index 4f8626c1f8877d9e2436061b33ce3ecb027c64b6..e4fef3709c11854824bcff5966f8880d61ff1bbc 100644 (file)
@@ -152,12 +152,12 @@ bool_expr : "(" bool_expr ")"
                     TokenPtr opt(new TokenOption($3, TokenOption::EXISTS));
                     ctx.expression.push_back(opt);
                 }
-          | OPTION "[" option_code "]" "." OPTION "[" option_code "]" "." EXISTS
+          | OPTION "[" option_code "]" "." OPTION "[" sub_option_code "]" "." EXISTS
                 {
                     TokenPtr opt(new TokenSubOption($3, $8, TokenOption::EXISTS));
                     ctx.expression.push_back(opt);
                 }
-          | RELAY4 "[" option_code "]" "." EXISTS
+          | RELAY4 "[" sub_option_code "]" "." EXISTS
                 {
                    switch (ctx.getUniverse()) {
                    case Option::V4:
@@ -177,7 +177,7 @@ bool_expr : "(" bool_expr ")"
                        error(@1, "relay4 can only be used in DHCPv4.");
                    }
                 }
-          | RELAY6 "[" nest_level "]" "." OPTION "[" option_code "]" "." EXISTS
+          | RELAY6 "[" nest_level "]" "." OPTION "[" sub_option_code "]" "." EXISTS
                 {
                     switch (ctx.getUniverse()) {
                     case Option::V6:
@@ -209,7 +209,7 @@ bool_expr : "(" bool_expr ")"
                   TokenPtr exist(new TokenVendor(ctx.getUniverse(), $3, TokenOption::EXISTS));
                   ctx.expression.push_back(exist);
               }
-          | VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." EXISTS
+          | VENDOR "[" enterprise_id "]" "." OPTION "[" sub_option_code "]" "." EXISTS
               {
                   // Expression vendor[1234].option[123].exists
                   //
@@ -256,12 +256,12 @@ string_expr : STRING
                       TokenPtr opt(new TokenOption($3, $6));
                       ctx.expression.push_back(opt);
                   }
-            | OPTION "[" option_code "]" "." OPTION "[" option_code "]" "." option_repr_type
+            | OPTION "[" option_code "]" "." OPTION "[" sub_option_code "]" "." option_repr_type
                   {
                       TokenPtr opt(new TokenSubOption($3, $8, $11));
                       ctx.expression.push_back(opt);
                   }
-            | RELAY4 "[" option_code "]" "." option_repr_type
+            | RELAY4 "[" sub_option_code "]" "." option_repr_type
                   {
                      switch (ctx.getUniverse()) {
                      case Option::V4:
@@ -282,7 +282,7 @@ string_expr : STRING
                      }
                   }
 
-            | RELAY6 "[" nest_level "]" "." OPTION "[" option_code "]" "." option_repr_type
+            | RELAY6 "[" nest_level "]" "." OPTION "[" sub_option_code "]" "." option_repr_type
                   {
                      switch (ctx.getUniverse()) {
                      case Option::V6:
@@ -384,7 +384,7 @@ string_expr : STRING
                                                          TokenVendor::ENTERPRISE_ID));
                     ctx.expression.push_back(vendor);
                 }
-            | VENDOR "[" enterprise_id "]" "." OPTION "[" option_code "]" "." option_repr_type
+            | VENDOR "[" enterprise_id "]" "." OPTION "[" sub_option_code "]" "." option_repr_type
                 {
                     // This token will search for vendor option with
                     // specified enterprise-id.  If found, will search
@@ -442,6 +442,12 @@ option_code : INTEGER
                  }
             ;
 
+sub_option_code : INTEGER
+                 {
+                     $$ = ctx.convertOptionCode($1, @1);
+                 }
+                ;
+
 option_repr_type : TEXT
                       {
                           $$ = TokenOption::TEXTUAL;