sgutils: allow command which does not transfer any data

This commit is contained in:
Dietmar Maurer 2021-01-24 15:19:43 +01:00
parent f9d71e8b17
commit 7c78d54231
1 changed files with 4 additions and 4 deletions

View File

@ -216,11 +216,11 @@ impl <'a, F: AsRawFd> SgRaw<'a, F> {
bail!("unknown scsi error - status response {}", status); bail!("unknown scsi error - status response {}", status);
} }
let data_len = self.buffer.len() - let resid = unsafe { get_scsi_pt_resid(&*ptvp) } as usize;
(unsafe { get_scsi_pt_resid(&*ptvp) } as usize); if resid > self.buffer.len() {
if data_len == 0 { bail!("do_scsi_pt failed - got strange resid (value too big)");
bail!("do_scsi_pt failed - no data received");
} }
let data_len = self.buffer.len() - resid;
Ok(&self.buffer[..data_len]) Ok(&self.buffer[..data_len])
} }