the method to get nlmsg_len in audit_send() is error

Yu Zhiguo yuzg at cn.fujitsu.com
Mon Jul 28 09:02:53 UTC 2008


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.

Signed-off-by: Yu Zhiguo<yuzg at cn.fujitsu.com>
---
  lib/netlink.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/netlink.c b/lib/netlink.c
index 2f78a96..2e2e6be 100644
--- a/lib/netlink.c
+++ b/lib/netlink.c
@@ -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;





More information about the Linux-audit mailing list