Skip to content

Commit

Permalink
tests/gnrc_sock_ip: add test case to test NULL pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Sep 7, 2020
1 parent b2da5d0 commit a6449af
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/gnrc_sock_ip/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static void test_sock_ip_recv_buf__success(void)
assert(_check_net());
}

static void test_sock_ip_send__EAFNOSUPPORT(void)
static void test_sock_ip_send__EAFNOSUPPORT_INET(void)
{
static const sock_ip_ep_t remote = { .addr = { .ipv6 = _TEST_ADDR_REMOTE },
.family = AF_INET };
Expand All @@ -376,6 +376,16 @@ static void test_sock_ip_send__EAFNOSUPPORT(void)
expect(_check_net());
}

static void test_sock_ip_send__EAFNOSUPPORT_UNSPEC(void)
{
static const sock_ip_ep_t remote = { .addr = { .ipv6 = _TEST_ADDR_REMOTE },
.family = AF_UNSPEC };

expect(-EAFNOSUPPORT == sock_ip_send(NULL, "ABCD", sizeof("ABCD"),
_TEST_PROTO, &remote));
expect(_check_net());
}

static void test_sock_ip_send__EINVAL_addr(void)
{
static const sock_ip_ep_t local = { .addr = { .ipv6 = _TEST_ADDR_LOCAL },
Expand Down Expand Up @@ -641,7 +651,8 @@ int main(void)
CALL(test_sock_ip_recv__non_blocking());
CALL(test_sock_ip_recv_buf__success());
_prepare_send_checks();
CALL(test_sock_ip_send__EAFNOSUPPORT());
CALL(test_sock_ip_send__EAFNOSUPPORT_INET());
CALL(test_sock_ip_send__EAFNOSUPPORT_UNSPEC());
CALL(test_sock_ip_send__EINVAL_addr());
CALL(test_sock_ip_send__EINVAL_netif());
CALL(test_sock_ip_send__ENOTCONN());
Expand Down

0 comments on commit a6449af

Please sign in to comment.