Commit f3489d5c authored by Ralph Boehme's avatar Ralph Boehme Committed by Andreas Schneider

swrap: Simplify cmspace calculation in swrap_sendmsg_copy_cmsg()

With cmsg->cmsg_len = CMSG_LEN(len) =>

CMSG_ALIGN(cmsg->cmsg_len) =

CMSG_ALIGN(CMSG_LEN(len)) =

CMSG_ALIGN(CMSG_ALIGN(sizeof(struct cmsghdr)) + len) =

CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len) =

CMSG_SPACE(len) =

CMSG_SPACE(CMSG_ALIGN(sizeof(struct cmsghdr)) + len - CMSG_ALIGN(sizeof(struct cmsghdr))) =

CMSG_SPACE(CMSG_LEN(len) - CMSG_ALIGN(sizeof(struct cmsghdr))) =

CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr)))

:)
Signed-off-by: default avatarRalph Boehme <slow@samba.org>
Reviewed-by: default avatarAndreas Schneider <asn@samba.org>
parent c5e809fe
......@@ -3739,9 +3739,7 @@ static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg,
size_t cmspace;
uint8_t *p;
cmspace =
(*cm_data_space) +
CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr)));
cmspace = *cm_data_space + CMSG_ALIGN(cmsg->cmsg_len);
p = realloc((*cm_data), cmspace);
if (p == NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment