diff --git a/services/param/trigger/trigger_checker.c b/services/param/trigger/trigger_checker.c index 6d61552e056b5e32981c52c9d68a4eaf03dd1d08..972ce925ec763885bc1dd62bdc6987b92c244515 100644 --- a/services/param/trigger/trigger_checker.c +++ b/services/param/trigger/trigger_checker.c @@ -328,8 +328,20 @@ int CheckMatchSubCondition(const char *condition, const char *input, int length) { PARAM_CHECK(condition != NULL, return 0, "Invalid condition"); PARAM_CHECK(input != NULL, return 0, "Invalid input"); - char *tmp = strstr(condition, input); - if ((tmp != NULL) && ((int)strlen(tmp) > length) && (tmp[length] == '=')) { + const char *tmp = strstr(condition, input); + if (tmp == NULL) { + return 0; + } + PARAM_LOGV("CheckMatchSubCondition Condition: '%s' content: '%s' length %d", condition, input, length); + if (((int)strlen(tmp) <= length) || (tmp[length] != '=')) { + return 0; + } + // for condition: parameter = 1 + if (tmp == condition) { + return 1; + } + // for condition: parameter1 = 1 && parameter2 = 1 + if (*(tmp - 1) == ' ') { return 1; } return 0; diff --git a/services/param/trigger/trigger_manager.c b/services/param/trigger/trigger_manager.c index 3f7d61fe5c5b280ea74726be07a679f7968846bf..982a983dfc020dedcf5cb6d5c809d73d73208039 100644 --- a/services/param/trigger/trigger_manager.c +++ b/services/param/trigger/trigger_manager.c @@ -448,8 +448,7 @@ int32_t CheckAndMarkTrigger_(const TriggerWorkSpace *workSpace, int type, const trigger = head->nextTrigger(head, trigger); continue; } - const char *tmp = strstr(head->getCondition(trigger), name); - if (tmp != NULL && strncmp(tmp + strlen(name), "=", 1) == 0) { + if (CheckMatchSubCondition(head->getCondition(trigger), name, strlen(name)) == 1) { TRIGGER_SET_FLAG(trigger, TRIGGER_FLAGS_RELATED); ret = 1; }