fix bug for trigger

Signed-off-by: cheng_jinsong <chengjinsong2@huawei.com>
This commit is contained in:
cheng_jinsong 2022-10-17 09:50:33 +08:00
parent 333d6985d9
commit fe79926f23
2 changed files with 15 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}