[PATCH] coroipcs: Ensure rb data are not overwritten

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

 



With introduce of rb alignment (55600762), it's not enough to subtract
one from number of free bytes, but also alignment must be taken to
account. Easiest solution is to subtract 9 bytes.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/coroipcs.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/exec/coroipcs.c b/exec/coroipcs.c
index 1adb7ae..36d18a4 100644
--- a/exec/coroipcs.c
+++ b/exec/coroipcs.c
@@ -1225,8 +1225,16 @@ static int shared_mem_dispatch_bytes_left (const struct conn_info *conn_info)
 	} else {
 		bytes_left = n_read - n_write;
 	}
-	if (bytes_left > 0) {
-		bytes_left--;
+
+	/*
+	 * Pointers in ring buffer are 64-bit alignment (in memcpy_dwrap)
+	 * To ensure we will not overwrite previous data,
+	 * 9 bytes (64-bit + 1 byte) are subtracted from bytes_left
+	 */
+	if (bytes_left < 9) {
+		bytes_left = 0;
+	} else {
+		bytes_left = bytes_left - 9;
 	}
 
 	return (bytes_left);
-- 
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