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 => {