Open Ulrond opened 4 weeks ago
Possible bug, do we need to check the length of the two strings during the comparison
Example of the problem.
Validation String: "ABC" Input String: "ABCDEF"
I think this will pass as the Validation String == Input String, when actually it should fail.
/**! Asserts that a string KVP field matches the expected value. */ #define UT_ASSERT_KVP_EQUAL_PROFILE_STRING(checkValue, key) \ { \ char result_kvp[UT_KVP_MAX_ELEMENT_SIZE]={0}; \ ut_kvp_status_t status; \ status = ut_kvp_getStringField(ut_kvp_profile_getInstance(), key, result_kvp, UT_KVP_MAX_ELEMENT_SIZE); \ UT_ASSERT( status == UT_KVP_STATUS_SUCCESS ); \ if ( status == UT_KVP_STATUS_SUCCESS ) \ { \ UT_ASSERT_STRING_EQUAL(checkValue, result_kvp); \ } \ else \ { \ UT_ASSERT(true);\ } \ }
Code that performs the validation is here, we may need to upgrade all the string macros to validate better
#define UT_ASSERT_STRING_EQUAL(expected, actual) \ { \ const char *_expected = (const char *)(expected); \ const char *_actual = (const char *)(actual); \ const int _result = strcmp(_actual, _expected); \ if (_result) \ { \ UT_LOG_ASSERT(UT_ASSERT_STRING_EQUAL, #actual, #expected); \ } \ CU_ASSERT_STRING_EQUAL(_actual, _expected); \ }
Possible bug, do we need to check the length of the two strings during the comparison
Example of the problem.
Validation String: "ABC" Input String: "ABCDEF"
I think this will pass as the Validation String == Input String, when actually it should fail.
Code that performs the validation is here, we may need to upgrade all the string macros to validate better