]> granicus.if.org Git - strace/commit
tests: fix potential unaligned access in netlink_sock_diag.test
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 19 Jun 2017 21:36:47 +0000 (21:36 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 19 Jun 2017 21:45:58 +0000 (21:45 +0000)
commit0fb4b6e0cb345bb0aaaa69898473544284759b5c
tree7f088aaae561e373bb547ae184c2315f956a9fd9
parentc7f371df30f8e9c4f5b7daa8428bf9c956485c78
tests: fix potential unaligned access in netlink_sock_diag.test

Despite our efforts made to avoid unaligned access, gcc appears to be
generating instructions that might cause unaligned access when copying
structures to unaligned addresses.

Fix this issue by replacing copying of structures to unaligned addresses
with memcpy calls.

* tests/netlink_sock_diag.c (INIT_STRUCT): New macro.
(test_odd_family_req, test_odd_family_msg, test_unix_diag_req,
test_unix_diag_msg, test_netlink_diag_req, test_netlink_diag_msg,
test_packet_diag_req, test_packet_diag_msg, test_inet_diag_sockid,
test_inet_diag_req, test_inet_diag_req_v2, test_inet_diag_msg,
test_smc_diag_req, test_smc_diag_msg): Use it to initialize potentially
unaligned struct nlmsghdr.  Do not access nlh->nlmsg_len.
tests/netlink_sock_diag.c