summaryrefslogtreecommitdiff
path: root/src/vhost_user
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhost_user')
-rw-r--r--src/vhost_user/master.rs5
-rw-r--r--src/vhost_user/slave_req_handler.rs7
2 files changed, 9 insertions, 3 deletions
diff --git a/src/vhost_user/master.rs b/src/vhost_user/master.rs
index 906932c..65c7960 100644
--- a/src/vhost_user/master.rs
+++ b/src/vhost_user/master.rs
@@ -569,7 +569,10 @@ impl MasterInternal {
&mut self,
hdr: &VhostUserMsgHeader<MasterReq>,
) -> VhostUserResult<(T, Vec<u8>, Option<Vec<RawFd>>)> {
- if mem::size_of::<T>() > MAX_MSG_SIZE || hdr.is_reply() {
+ if mem::size_of::<T>() > MAX_MSG_SIZE
+ || hdr.get_size() as usize <= mem::size_of::<T>()
+ || hdr.is_reply()
+ {
return Err(VhostUserError::InvalidParam);
}
self.check_state()?;
diff --git a/src/vhost_user/slave_req_handler.rs b/src/vhost_user/slave_req_handler.rs
index 95e23d1..985693f 100644
--- a/src/vhost_user/slave_req_handler.rs
+++ b/src/vhost_user/slave_req_handler.rs
@@ -552,7 +552,10 @@ impl<S: VhostUserSlaveReqHandler> SlaveReqHandler<S> {
req: &VhostUserMsgHeader<MasterReq>,
payload_size: usize,
) -> Result<VhostUserMsgHeader<MasterReq>> {
- if mem::size_of::<T>() > MAX_MSG_SIZE {
+ if mem::size_of::<T>() > MAX_MSG_SIZE
+ || payload_size > MAX_MSG_SIZE
+ || mem::size_of::<T>() + payload_size > MAX_MSG_SIZE
+ {
return Err(Error::InvalidParam);
}
self.check_state()?;
@@ -568,7 +571,7 @@ impl<S: VhostUserSlaveReqHandler> SlaveReqHandler<S> {
req: &VhostUserMsgHeader<MasterReq>,
res: Result<()>,
) -> Result<()> {
- if self.reply_ack_enabled {
+ if self.reply_ack_enabled && req.is_need_reply() {
let hdr = self.new_reply_header::<VhostUserU64>(req, 0)?;
let val = match res {
Ok(_) => 0,