From 278f8d5c4d74b0a10cd96ee3f8225a673517dbf4 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 12 Jan 2025 15:57:26 +0100 Subject: [PATCH] socket/tst-cmsghdr: Fix alignment of cmsghdr The computation was correct on Linux only by luck because the cmsghdr size is already aligned there. --- socket/tst-cmsghdr-skeleton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socket/tst-cmsghdr-skeleton.c b/socket/tst-cmsghdr-skeleton.c index e2b743a368..9ad2d59d5f 100644 --- a/socket/tst-cmsghdr-skeleton.c +++ b/socket/tst-cmsghdr-skeleton.c @@ -56,7 +56,7 @@ RUN_TEST_FUNCNAME (CMSG_NXTHDR_IMPL) (void) /* The first header leaves just enough space to hold another header. */ cmsg = CMSG_FIRSTHDR (&m); TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf); - cmsg->cmsg_len = sizeof (cmsgbuf) - sizeof (struct cmsghdr); + cmsg->cmsg_len = sizeof (cmsgbuf) - CMSG_ALIGN (sizeof (struct cmsghdr)); cmsg = CMSG_NXTHDR_IMPL (&m, cmsg); TEST_VERIFY_EXIT (cmsg != NULL); @@ -75,7 +75,7 @@ RUN_TEST_FUNCNAME (CMSG_NXTHDR_IMPL) (void) TEST_VERIFY_EXIT (cmsg != NULL); cmsg->cmsg_len = sizeof (cmsgbuf) - CMSG_SPACE (sizeof (PAYLOAD)) /* First header. */ - - sizeof (struct cmsghdr); + - CMSG_ALIGN (sizeof (struct cmsghdr)); cmsg = CMSG_NXTHDR_IMPL (&m, cmsg); TEST_VERIFY_EXIT (cmsg != NULL);