From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu Zhiguo Subject: the method to get nlmsg_len in audit_send() is error Date: Mon, 28 Jul 2008 17:02:53 +0800 Message-ID: <488D8B3D.5040405@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: Steve Grubb Cc: audit-list List-Id: linux-audit@redhat.com 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 --- 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;