[PATCH 2/4] Check size of message to mcast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Corosync limit to send/receive message is 1 megabyte. Patch ensures this
limit is never overrun.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/main.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/exec/main.c b/exec/main.c
index cd972b5..3068ac9 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -714,10 +714,25 @@ int main_mcast (
 	const struct qb_ipc_request_header *req = iovec->iov_base;
 	int32_t service;
 	int32_t fn_id;
+	size_t msg_len;
+	unsigned int i;
 
 	service = req->id >> 16;
 	fn_id = req->id & 0xffff;
 
+	msg_len = 0;
+
+	for (msg_len = 0, i = 0; i < iov_len; msg_len += iovec[i].iov_len, i++)
+	    ;
+
+	if (msg_len > MESSAGE_SIZE_MAX) {
+		log_printf(LOGSYS_LEVEL_ERROR,
+			"IPC client is trying to send message larger (%zu bytes) then allowed maximum %u bytes",
+			msg_len, MESSAGE_SIZE_MAX);
+
+		return (-1);
+	}
+
 	if (corosync_service[service]) {
 		icmap_fast_inc(service_stats_tx[service][fn_id]);
 	}
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss



[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux