Module: kamailio
Branch: master
Commit: fbc6b275be1467871e26ea8c72f4ad6df724e2dd
URL:
https://github.com/kamailio/kamailio/commit/fbc6b275be1467871e26ea8c72f4ad6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-06-06T11:18:30+02:00
core: catch use of numbers or reserved tokens in cfg var definitions
---
Modified: src/core/cfg.y
---
Diff:
https://github.com/kamailio/kamailio/commit/fbc6b275be1467871e26ea8c72f4ad6…
Patch:
https://github.com/kamailio/kamailio/commit/fbc6b275be1467871e26ea8c72f4ad6…
---
diff --git a/src/core/cfg.y b/src/core/cfg.y
index 2cfc7516e1..890f964cfb 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -594,6 +594,7 @@ extern char *default_routename;
%type <intval> avpflag_oper
%type <intval> rve_un_op
%type <strval> cfg_var_id
+%type <strval> cfg_var_idn
/* %type <intval> rve_op */
/*%type <route_el> rules;
@@ -1588,36 +1589,44 @@ cfg_var_id: ID
| DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
;
+cfg_var_idn: ID
+ | DEFAULT { $$="default" ; } /*needed to allow default as cfg var. name*/
+ | NUMBER {
+ yyerror("cfg var field name - use of number or reserved token not allowed:
%s",
+ yy_number_str);
+ }
+ ;
+
cfg_var:
- cfg_var_id DOT cfg_var_id EQUAL NUMBER {
+ cfg_var_id DOT cfg_var_idn EQUAL NUMBER {
if (cfg_declare_int($1, $3, $5, 0, 0, NULL)) {
yyerror("variable cannot be declared");
}
}
- | cfg_var_id DOT cfg_var_id EQUAL STRING {
+ | cfg_var_id DOT cfg_var_idn EQUAL STRING {
if (cfg_declare_str($1, $3, $5, NULL)) {
yyerror("variable cannot be declared");
}
}
- | cfg_var_id DOT cfg_var_id EQUAL NUMBER CFG_DESCRIPTION STRING {
+ | cfg_var_id DOT cfg_var_idn EQUAL NUMBER CFG_DESCRIPTION STRING {
if (cfg_declare_int($1, $3, $5, 0, 0, $7)) {
yyerror("variable cannot be declared");
}
}
- | cfg_var_id DOT cfg_var_id EQUAL STRING CFG_DESCRIPTION STRING {
+ | cfg_var_id DOT cfg_var_idn EQUAL STRING CFG_DESCRIPTION STRING {
if (cfg_declare_str($1, $3, $5, $7)) {
yyerror("variable cannot be declared");
}
}
- | cfg_var_id DOT cfg_var_id EQUAL error {
+ | cfg_var_id DOT cfg_var_idn EQUAL error {
yyerror("number or string expected");
}
- | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL NUMBER {
+ | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_idn EQUAL NUMBER {
if (cfg_ginst_var_int($1, $3, $6, $8)) {
yyerror("variable cannot be added to the group instance");
}
}
- | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_id EQUAL STRING {
+ | cfg_var_id LBRACK NUMBER RBRACK DOT cfg_var_idn EQUAL STRING {
if (cfg_ginst_var_string($1, $3, $6, $8)) {
yyerror("variable cannot be added to the group instance");
}