Browse code

core: catch use of numbers or reserved tokens in cfg var definitions

(cherry picked from commit fbc6b275be1467871e26ea8c72f4ad6df724e2dd)
(cherry picked from commit 106eb258c39bd0c1f9b61b9e0226601e62c6b97b)

Daniel-Constantin Mierla authored on 06/06/2017 09:18:30
Showing 1 changed files
... ...
@@ -587,6 +587,7 @@ extern char *default_routename;
587 587
 %type <intval> avpflag_oper
588 588
 %type <intval> rve_un_op
589 589
 %type <strval> cfg_var_id
590
+%type <strval> cfg_var_idn
590 591
 /* %type <intval> rve_op */
591 592
 
592 593
 /*%type <route_el> rules;
... ...
@@ -1548,36 +1549,44 @@ cfg_var_id: ID
1548 1549
 	| DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
1549 1550
 	;
1550 1551
 
1552
+cfg_var_idn: ID
1553
+	| DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
1554
+	| NUMBER {
1555
+		yyerror("cfg var field name - use of number or reserved token not allowed: %s",
1556
+				yy_number_str);
1557
+	}
1558
+	;
1559
+
1551 1560
 cfg_var:
1552
-	cfg_var_id DOT cfg_var_id EQUAL NUMBER {
1561
+	cfg_var_id DOT cfg_var_idn EQUAL NUMBER {
1553 1562
 		if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
1554 1563
 			yyerror("variable cannot be declared");
1555 1564
 		}
1556 1565
 	}
1557
-	| cfg_var_id DOT cfg_var_id EQUAL STRING {
1566
+	| cfg_var_id DOT cfg_var_idn EQUAL STRING {
1558 1567
 		if (cfg_declare_str($1, $3, $5, NULL)) {
1559 1568
 			yyerror("variable cannot be declared");
1560 1569
 		}
1561 1570
 	}
1562
-	| cfg_var_id DOT cfg_var_id EQUAL NUMBER CFG_DESCRIPTION STRING {
1571
+	| cfg_var_id DOT cfg_var_idn EQUAL NUMBER CFG_DESCRIPTION STRING {
1563 1572
 		if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
1564 1573
 			yyerror("variable cannot be declared");
1565 1574
 		}
1566 1575
 	}
1567
-	| cfg_var_id DOT cfg_var_id EQUAL STRING CFG_DESCRIPTION STRING {
1576
+	| cfg_var_id DOT cfg_var_idn EQUAL STRING CFG_DESCRIPTION STRING {
1568 1577
 		if (cfg_declare_str($1, $3, $5, $7)) {
1569 1578
 			yyerror("variable cannot be declared");
1570 1579
 		}
1571 1580
 	}
1572
-	| cfg_var_id DOT cfg_var_id EQUAL error {
1581
+	| cfg_var_id DOT cfg_var_idn EQUAL error {
1573 1582
 		yyerror("number or string expected");
1574 1583
 	}
1575
-	| cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL NUMBER {
1584
+	| cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_idn EQUAL NUMBER {
1576 1585
 		if (cfg_ginst_var_int($1, $3, $6, $8)) {
1577 1586
 			yyerror("variable cannot be added to the group instance");
1578 1587
 		}
1579 1588
 	}
1580
-	| cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL STRING {
1589
+	| cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_idn EQUAL STRING {
1581 1590
 		if (cfg_ginst_var_string($1, $3, $6, $8)) {
1582 1591
 			yyerror("variable cannot be added to the group instance");
1583 1592
 		}