diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index c114a45fbd01b4aadeb026bbec6276aec17154dd..992fdbd1378571398137deb2af223fd5d3bcfa77 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1132,9 +1132,9 @@ static bool validateStateOper(const SValueNode* pVal) { if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) { return false; } - return (0 == strcasecmp(varDataVal(pVal->datum.p), "GT") || 0 == strcasecmp(varDataVal(pVal->datum.p), "GE") || - 0 == strcasecmp(varDataVal(pVal->datum.p), "LT") || 0 == strcasecmp(varDataVal(pVal->datum.p), "LE") || - 0 == strcasecmp(varDataVal(pVal->datum.p), "EQ") || 0 == strcasecmp(varDataVal(pVal->datum.p), "NE")); + return (0 == strncasecmp(varDataVal(pVal->datum.p), "GT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "GE", 2) || + 0 == strncasecmp(varDataVal(pVal->datum.p), "LT", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "LE", 2) || + 0 == strncasecmp(varDataVal(pVal->datum.p), "EQ", 2) || 0 == strncasecmp(varDataVal(pVal->datum.p), "NE", 2)); } static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 12b796c5ca37c3f7369352782c1ecb1694c9d0c0..3f8a5fce71987b4a92e75994ffa33abc0325bcaa 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -4416,17 +4416,17 @@ bool getStateFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { static int8_t getStateOpType(char* opStr) { int8_t opType; - if (strcasecmp(opStr, "LT") == 0) { + if (strncasecmp(opStr, "LT", 2) == 0) { opType = STATE_OPER_LT; - } else if (strcasecmp(opStr, "GT") == 0) { + } else if (strncasecmp(opStr, "GT", 2) == 0) { opType = STATE_OPER_GT; - } else if (strcasecmp(opStr, "LE") == 0) { + } else if (strncasecmp(opStr, "LE", 2) == 0) { opType = STATE_OPER_LE; - } else if (strcasecmp(opStr, "GE") == 0) { + } else if (strncasecmp(opStr, "GE", 2) == 0) { opType = STATE_OPER_GE; - } else if (strcasecmp(opStr, "NE") == 0) { + } else if (strncasecmp(opStr, "NE", 2) == 0) { opType = STATE_OPER_NE; - } else if (strcasecmp(opStr, "EQ") == 0) { + } else if (strncasecmp(opStr, "EQ", 2) == 0) { opType = STATE_OPER_EQ; } else { opType = STATE_OPER_INVALID; diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 509745383229314f0dddd206c10ce4554ef5cd23..2e32d903aa24ef9a39ce099b3edab792a132b9f9 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -2470,17 +2470,17 @@ typedef enum { static int8_t getStateOpType(char* opStr) { int8_t opType; - if (strcasecmp(opStr, "LT") == 0) { + if (strncasecmp(opStr, "LT", 2) == 0) { opType = STATE_OPER_LT; - } else if (strcasecmp(opStr, "GT") == 0) { + } else if (strncasecmp(opStr, "GT", 2) == 0) { opType = STATE_OPER_GT; - } else if (strcasecmp(opStr, "LE") == 0) { + } else if (strncasecmp(opStr, "LE", 2) == 0) { opType = STATE_OPER_LE; - } else if (strcasecmp(opStr, "GE") == 0) { + } else if (strncasecmp(opStr, "GE", 2) == 0) { opType = STATE_OPER_GE; - } else if (strcasecmp(opStr, "NE") == 0) { + } else if (strncasecmp(opStr, "NE", 2) == 0) { opType = STATE_OPER_NE; - } else if (strcasecmp(opStr, "EQ") == 0) { + } else if (strncasecmp(opStr, "EQ", 2) == 0) { opType = STATE_OPER_EQ; } else { opType = STATE_OPER_INVALID;