fixed crash when receiving notify messages
[lcr.git] / route.c
diff --git a/route.c b/route.c
index 3381251..8c158bf 100644 (file)
--- a/route.c
+++ b/route.c
@@ -848,6 +848,7 @@ struct route_ruleset *ruleset_parse(void)
        struct route_param      *param;
        struct route_param      **param_pointer = NULL;
        char                    failure[256];
+       unsigned long long      allowed_params;
 
        /* check the integrity of IDs for ACTION_* and PARAM_* */
        i = 0;
@@ -973,7 +974,7 @@ struct route_ruleset *ruleset_parse(void)
 
                        /* reading ruleset name text */
                        i = 0;
-                       while((*p>='a' && *p<='z') || (*p>='A' && *p<='Z') || (*p>='0' && *p<='9'))
+                       while(*p>' ' && *p<127 && *p!=']')
                        {
                                if (*p>='A' && *p<='Z') *p = *p-'A'+'a'; /* lower case */
                                key[i++] = *p++;
@@ -1461,6 +1462,7 @@ struct route_ruleset *ruleset_parse(void)
                        SPRINT(failure, "Unknown action name '%s'.", key);
                        goto parse_error;
                }
+               allowed_params = action_defs[index].params;
 
                /* alloc memory for action */
                action = (struct route_action *)MALLOC(sizeof(struct route_action));
@@ -1510,6 +1512,13 @@ struct route_ruleset *ruleset_parse(void)
                                goto parse_error;
                        }
 
+                       /* check if item is allowed for the action */
+                       if (!(param_defs[index].id & allowed_params))
+                       {
+                               SPRINT(failure, "Param name '%s' exists, but not for this action.", key);
+                               goto parse_error;
+                       }
+
                        /* params without values must not have any parameter */
                        if (param_defs[index].type == PARAM_TYPE_NULL)
                        {
@@ -2216,7 +2225,7 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset)
                                admin = admin_first;
                                while(admin)
                                {
-                                       if (admin->remote[0] && !strcmp(cond->string_value, admin->remote))
+                                       if (admin->remote_name[0] && !strcmp(cond->string_value, admin->remote_name))
                                                break;
                                        admin = admin->next;
                                }