Skip to content

Commit cb3e80c

Browse files
committed
Fixed overflows in dns-dhcp test
1 parent 0f9024d commit cb3e80c

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/test/unit/unit_tests_dns_dhcp.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,23 @@ static void build_dhcp_ack_msg(struct dhcp_msg *msg, uint32_t server_ip, uint32_
5656

5757
START_TEST(test_dhcp_option_u32_macros_round_trip_wire_order)
5858
{
59-
struct dhcp_option opt;
59+
struct PACKED {
60+
struct dhcp_option opt;
61+
uint8_t data[4];
62+
} opt_buf;
63+
struct dhcp_option *opt = &opt_buf.opt;
6064
uint32_t value = 0x0A000001U;
6165

62-
memset(&opt, 0, sizeof(opt));
63-
opt.len = 4;
66+
memset(&opt_buf, 0, sizeof(opt_buf));
67+
opt->len = 4;
6468

65-
DHCP_OPT_u32_to_data(&opt, value);
69+
DHCP_OPT_u32_to_data(opt, value);
6670

67-
ck_assert_uint_eq(opt.data[0], 0x0AU);
68-
ck_assert_uint_eq(opt.data[1], 0x00U);
69-
ck_assert_uint_eq(opt.data[2], 0x00U);
70-
ck_assert_uint_eq(opt.data[3], 0x01U);
71-
ck_assert_uint_eq(DHCP_OPT_data_to_u32(&opt), value);
71+
ck_assert_uint_eq(opt->data[0], 0x0AU);
72+
ck_assert_uint_eq(opt->data[1], 0x00U);
73+
ck_assert_uint_eq(opt->data[2], 0x00U);
74+
ck_assert_uint_eq(opt->data[3], 0x01U);
75+
ck_assert_uint_eq(DHCP_OPT_data_to_u32(opt), value);
7276
}
7377
END_TEST
7478

0 commit comments

Comments
 (0)