Explorar el Código

coroipcs: Ensure rb data are not overwritten

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@redhat.com>
Reviewed-by: Steven Dake <sdake@redhat.com>
Jan Friesse hace 13 años
padre
commit
c7e686181b
Se han modificado 1 ficheros con 10 adiciones y 2 borrados
  1. 10 2
      exec/coroipcs.c

+ 10 - 2
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);