diff options
Diffstat (limited to 'tests/netlink_sock_diag.c')
-rw-r--r-- | tests/netlink_sock_diag.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/netlink_sock_diag.c b/tests/netlink_sock_diag.c index c2ebf129c..c9e1232f9 100644 --- a/tests/netlink_sock_diag.c +++ b/tests/netlink_sock_diag.c @@ -127,10 +127,11 @@ test_nlmsg_flags(const int fd) static void test_odd_family_req(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); + uint8_t family = 0; + char buf[sizeof(family) + 4]; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(buf)); /* unspecified family only */ - uint8_t family = 0; TEST_NETLINK(fd, nlh0, SOCK_DIAG_BY_FAMILY, NLM_F_REQUEST, @@ -153,7 +154,6 @@ test_odd_family_req(const int fd) printf("%p", NLMSG_DATA(TEST_NETLINK_nlh))); /* unspecified family and string */ - char buf[sizeof(family) + 4]; family = 0; memcpy(buf, &family, sizeof(family)); memcpy(buf + sizeof(family), "1234", 4); @@ -177,10 +177,11 @@ test_odd_family_req(const int fd) static void test_odd_family_msg(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); + uint8_t family = 0; + char buf[sizeof(family) + 4]; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(buf)); /* unspecified family only */ - uint8_t family = 0; TEST_NETLINK(fd, nlh0, SOCK_DIAG_BY_FAMILY, NLM_F_DUMP, sizeof(family), &family, sizeof(family), @@ -200,7 +201,6 @@ test_odd_family_msg(const int fd) printf("%p", NLMSG_DATA(TEST_NETLINK_nlh))); /* unspecified family and string */ - char buf[sizeof(family) + 4]; family = 0; memcpy(buf, &family, sizeof(family)); memcpy(buf + sizeof(family), "1234", 4); @@ -222,7 +222,6 @@ test_odd_family_msg(const int fd) static void test_unix_diag_req(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); static const struct unix_diag_req req = { .sdiag_family = AF_UNIX, .sdiag_protocol = 253, @@ -231,6 +230,7 @@ test_unix_diag_req(const int fd) .udiag_show = UDIAG_SHOW_NAME, .udiag_cookie = { 0xdeadbeef, 0xbadc0ded } }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); TEST_SOCK_DIAG(fd, nlh0, AF_UNIX, SOCK_DIAG_BY_FAMILY, NLM_F_REQUEST, req, printf("{sdiag_family=AF_UNIX"), @@ -245,7 +245,6 @@ test_unix_diag_req(const int fd) static void test_unix_diag_msg(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); static const struct unix_diag_msg msg = { .udiag_family = AF_UNIX, .udiag_type = SOCK_STREAM, @@ -253,6 +252,7 @@ test_unix_diag_msg(const int fd) .udiag_ino = 0xfacefeed, .udiag_cookie = { 0xdeadbeef, 0xbadc0ded } }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(msg)); TEST_SOCK_DIAG(fd, nlh0, AF_UNIX, SOCK_DIAG_BY_FAMILY, NLM_F_DUMP, msg, printf("{udiag_family=AF_UNIX"), @@ -266,7 +266,6 @@ test_unix_diag_msg(const int fd) static void test_netlink_diag_req(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct netlink_diag_req req = { .sdiag_family = AF_NETLINK, .sdiag_protocol = NDIAG_PROTO_ALL, @@ -274,6 +273,7 @@ test_netlink_diag_req(const int fd) .ndiag_show = NDIAG_SHOW_MEMINFO, .ndiag_cookie = { 0xdeadbeef, 0xbadc0ded } }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); TEST_SOCK_DIAG(fd, nlh0, AF_NETLINK, SOCK_DIAG_BY_FAMILY, NLM_F_REQUEST, req, printf("{sdiag_family=AF_NETLINK"), @@ -298,7 +298,6 @@ test_netlink_diag_req(const int fd) static void test_netlink_diag_msg(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); static const struct netlink_diag_msg msg = { .ndiag_family = AF_NETLINK, .ndiag_type = SOCK_RAW, @@ -310,6 +309,7 @@ test_netlink_diag_msg(const int fd) .ndiag_ino = 0xdaeefacd, .ndiag_cookie = { 0xbadc0ded, 0xdeadbeef } }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(msg)); TEST_SOCK_DIAG(fd, nlh0, AF_NETLINK, SOCK_DIAG_BY_FAMILY, NLM_F_DUMP, msg, printf("{ndiag_family=AF_NETLINK"), @@ -327,7 +327,6 @@ test_netlink_diag_msg(const int fd) static void test_packet_diag_req(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); static const struct packet_diag_req req = { .sdiag_family = AF_PACKET, .sdiag_protocol = ETH_P_LOOP, @@ -335,6 +334,7 @@ test_packet_diag_req(const int fd) .pdiag_show = PACKET_SHOW_INFO, .pdiag_cookie = { 0xdeadbeef, 0xbadc0ded } }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); TEST_SOCK_DIAG(fd, nlh0, AF_PACKET, SOCK_DIAG_BY_FAMILY, NLM_F_REQUEST, req, printf("{sdiag_family=AF_PACKET"), @@ -348,7 +348,6 @@ test_packet_diag_req(const int fd) static void test_packet_diag_msg(const int fd) { - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); static const struct packet_diag_msg msg = { .pdiag_family = AF_PACKET, .pdiag_type = SOCK_STREAM, @@ -356,6 +355,7 @@ test_packet_diag_msg(const int fd) .pdiag_ino = 0xfacefeed, .pdiag_cookie = { 0xdeadbeef, 0xbadc0ded } }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(msg)); TEST_SOCK_DIAG(fd, nlh0, AF_PACKET, SOCK_DIAG_BY_FAMILY, NLM_F_DUMP, msg, printf("{pdiag_family=AF_PACKET"), @@ -371,7 +371,6 @@ test_inet_diag_sockid(const int fd) { const char address[] = "12.34.56.78"; const char address6[] = "12:34:56:78:90:ab:cd:ef"; - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct inet_diag_req_v2 req = { .sdiag_family = AF_INET, .idiag_ext = 1 << (INET_DIAG_CONG - 1), @@ -384,6 +383,7 @@ test_inet_diag_sockid(const int fd) .idiag_cookie = { 0xdeadbeef, 0xbadc0ded } }, }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); if (!inet_pton(AF_INET, address, &req.id.idiag_src) || !inet_pton(AF_INET, address, &req.id.idiag_dst)) @@ -435,7 +435,6 @@ static void test_inet_diag_req(const int fd) { const char address[] = "12.34.56.78"; - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct inet_diag_req req = { .idiag_family = AF_INET, .idiag_src_len = 0xde, @@ -450,6 +449,7 @@ test_inet_diag_req(const int fd) .idiag_states = 1 << TCP_LAST_ACK, .idiag_dbs = 0xfacefeed, }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); if (!inet_pton(AF_INET, address, &req.id.idiag_src) || !inet_pton(AF_INET, address, &req.id.idiag_dst)) @@ -479,7 +479,6 @@ static void test_inet_diag_req_v2(const int fd) { const char address[] = "87.65.43.21"; - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct inet_diag_req_v2 req = { .sdiag_family = AF_INET, .idiag_ext = 1 << (INET_DIAG_CONG - 1), @@ -492,6 +491,7 @@ test_inet_diag_req_v2(const int fd) .idiag_cookie = { 0xdeadbeef, 0xbadc0ded } }, }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); if (!inet_pton(AF_INET, address, &req.id.idiag_src) || !inet_pton(AF_INET, address, &req.id.idiag_dst)) @@ -519,7 +519,6 @@ static void test_inet_diag_msg(const int fd) { const char address[] = "11.22.33.44"; - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct inet_diag_msg msg = { .idiag_family = AF_INET, .idiag_state = TCP_LISTEN, @@ -537,6 +536,7 @@ test_inet_diag_msg(const int fd) .idiag_uid = 0xdecefaeb, .idiag_inode = 0xbadc0ded, }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(msg)); if (!inet_pton(AF_INET, address, &msg.id.idiag_src) || !inet_pton(AF_INET, address, &msg.id.idiag_dst)) @@ -570,7 +570,6 @@ static void test_smc_diag_req(const int fd) { const char address[] = "43.21.56.78"; - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct smc_diag_req req = { .diag_family = AF_SMC, .diag_ext = 1 << (SMC_DIAG_CONNINFO - 1), @@ -581,6 +580,7 @@ test_smc_diag_req(const int fd) .idiag_cookie = { 0xdeadbeef, 0xbadc0ded }, }, }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(req)); if (!inet_pton(AF_INET, address, &req.id.idiag_src) || !inet_pton(AF_INET, address, &req.id.idiag_dst)) @@ -606,7 +606,6 @@ static void test_smc_diag_msg(const int fd) { const char address[] = "34.87.12.90"; - void *const nlh0 = tail_alloc(NLMSG_HDRLEN); struct smc_diag_msg msg = { .diag_family = AF_SMC, .diag_state = SMC_ACTIVE, @@ -621,6 +620,7 @@ test_smc_diag_msg(const int fd) .diag_uid = 0xadcdfafc, .diag_inode = 0xbadc0ded, }; + void *const nlh0 = midtail_alloc(NLMSG_HDRLEN, sizeof(msg)); if (!inet_pton(AF_INET, address, &msg.id.idiag_src) || !inet_pton(AF_INET, address, &msg.id.idiag_dst)) |