From 864247d6cabdc59b63a155a2f280d534de8e00b3 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 11 Jun 2019 17:28:12 +0200 Subject: [PATCH] unitttests/sock_util: Test null pointer in urlsplit --- tests/unittests/tests-sock_util/tests-sock_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unittests/tests-sock_util/tests-sock_util.c b/tests/unittests/tests-sock_util/tests-sock_util.c index ea46e538cd..d067704614 100644 --- a/tests/unittests/tests-sock_util/tests-sock_util.c +++ b/tests/unittests/tests-sock_util/tests-sock_util.c @@ -152,6 +152,18 @@ static void test_sock_util_urlsplit__urlpath_too_long(void) sock_urlsplit(TEST_URL_LONG_URLPATH, addr, urlpath)); } +static void test_sock_util_urlsplit__null_addr_buffer(void) +{ + TEST_ASSERT_EQUAL_INT(0, sock_urlsplit(TEST_URL, addr, NULL)); + TEST_ASSERT_EQUAL_STRING(TEST_URL_HOSTPART, (char*)addr); +} + +static void test_sock_util_urlsplit__null_path_buffer(void) +{ + TEST_ASSERT_EQUAL_INT(0, sock_urlsplit(TEST_URL, NULL, urlpath)); + TEST_ASSERT_EQUAL_STRING(TEST_URL_LOCALPART, (char*)urlpath); +} + static void test_sock_util_str2ep__ipv6_noport(void) { sock_udp_ep_t ep; @@ -210,6 +222,8 @@ Test *tests_sock_util_all(void) new_TestFixture(test_sock_util_urlsplit__no_schema), new_TestFixture(test_sock_util_urlsplit__hostport_too_long), new_TestFixture(test_sock_util_urlsplit__urlpath_too_long), + new_TestFixture(test_sock_util_urlsplit__null_addr_buffer), + new_TestFixture(test_sock_util_urlsplit__null_path_buffer), new_TestFixture(test_sock_util_str2ep__ipv6_noport), new_TestFixture(test_sock_util_str2ep__ipv4_noport), new_TestFixture(test_sock_util_str2ep__ipv4_port),