From a8e9a5e73b391ece34df40e89ebe9dfc76370d50 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 19 Feb 2026 13:23:35 -0700 Subject: [PATCH] ipcd: use first segment size for limits of mmap --- ipcd/src/shm.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ipcd/src/shm.rs b/ipcd/src/shm.rs index 82c94fc9ed..0e80ddcf72 100644 --- a/ipcd/src/shm.rs +++ b/ipcd/src/shm.rs @@ -217,11 +217,12 @@ impl SchemeSync for ShmScheme { .buffer { Some(ref mut buf) => { - if total_size > buf.len() { + // TODO: This will not work well if there's multiple segments! + let segment = buf.segments.first().ok_or_else(|| Error::new(ERANGE))?; + if total_size > segment.size { return Err(Error::new(ERANGE)); } - /// TODO: This will not work well if there's multiple segments! - Ok(buf.as_ptr() + offset as usize) + Ok(segment.base + offset as usize) } //TODO: this should be only handled by ftruncate ref mut buf @ None => {