From 85b89521f8f217755de26a4057bfdfc391e8f146 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 4 Feb 2012 16:39:26 +0000 Subject: [PATCH] iscsi-scstd: Make really sure that the buffer allocated for nl_read() is large enough git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4110 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/usr/event.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index 6555d5ae0..2ca90a288 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -160,7 +160,8 @@ static int handle_e_add_target(int fd, const struct iscsi_kern_event *event) /* Params are not 0-terminated */ - size = NLMSG_ALIGN(strlen("Target ") + event->param1_size + 2 + event->param2_size + 1); + size = strlen("Target ") + event->param1_size + 2 + event->param2_size + + 1 + NLMSG_ALIGNTO - 1; buf = malloc(size); if (buf == NULL) { @@ -759,7 +760,8 @@ static int handle_e_set_attr_value(int fd, const struct iscsi_kern_event *event) } /* Params are not 0-terminated */ - size = NLMSG_ALIGN(event->param1_size + 1 + 1 + event->param2_size + 1); + size = event->param1_size + 1 + 1 + event->param2_size + 1 + + NLMSG_ALIGNTO - 1; buf = malloc(size); if (buf == NULL) {