Skip to contentSkip to conversation

the method to get nlmsg_len in audit_send() is error

PATCH Applied Yu Zhiguo 2 participants 2 messages Jul 28, 2008 Library code

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

Hello Steve,

I think micro NLMSG_ALIGN is needless for nlmsg_len, NLMSG_SPACE is sufficient. because NLMSG_SPACE includes the rounded netlink header size.

Now no errors occurred because struct req has been set to all 0.

---
 lib/netlink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/netlink.c +1 -1
index 2f78a96..2e2e6be 100644
@@ -220,7 +220,7 @@ int audit_send(int fd, int type, const void *data, unsigned int size)
 		sequence = 1;
 
 	memset(&req, 0, sizeof(req));
-	req.nlh.nlmsg_len = NLMSG_ALIGN(req.nlh.nlmsg_len) + NLMSG_SPACE(size);
+	req.nlh.nlmsg_len = NLMSG_SPACE(size);
 	req.nlh.nlmsg_type = type;
 	req.nlh.nlmsg_flags = NLM_F_REQUEST|NLM_F_ACK;
 	req.nlh.nlmsg_seq = sequence;
Applied
#1 lore raw
Quoted 2 lines · On Monday 28 July 2008 05:02:53 Yu Zhiguo wrote:

I think micro NLMSG_ALIGN is needless for nlmsg_len, NLMSG_SPACE is sufficient. because NLMSG_SPACE includes the rounded netlink header size.

I guess you are right. I checked the macros just be sure since this is some of the oldest code in the audit project and hasn't changed in a very long time.

Applied. Thanks for the patch.

-Steve