1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

uri_parser: unittests: add validity check for unterminated string

This commit is contained in:
Cenk Gündoğan 2020-04-02 10:03:05 +02:00
parent e3d9097974
commit 1bfc1fbcb3

View File

@ -303,10 +303,31 @@ static void test_uri_parser__validate(void)
}
}
static void test_uri_parser__unterminated_string(void)
{
uri_parser_result_t ures;
char uri[64];
/* initialize with a non-null character */
memset(uri, 'Z', sizeof(uri));
memcpy(uri, validate_uris[0].uri, strlen(validate_uris[0].uri));
int res = uri_parser_process(&ures, uri, strlen(validate_uris[0].uri));
TEST_ASSERT_EQUAL_INT(0, res);
VEC_CHECK(scheme, 0, _failure_msg);
VEC_CHECK(userinfo, 0, _failure_msg);
VEC_CHECK(host, 0, _failure_msg);
VEC_CHECK(port, 0, _failure_msg);
VEC_CHECK(path, 0, _failure_msg);
VEC_CHECK(query, 0, _failure_msg);
}
Test *tests_uri_parser_tests(void)
{
EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(test_uri_parser__validate),
new_TestFixture(test_uri_parser__unterminated_string),
};
EMB_UNIT_TESTCALLER(uri_parser_tests, NULL, NULL, fixtures);