Merge pull request #125 from plieven/iscsi-test

iscsi-test: check for invalid descriptors offsets in get_lba_status
This commit is contained in:
Ronnie Sahlberg
2014-07-13 16:35:19 -07:00

View File

@@ -1894,6 +1894,8 @@ struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len)
{
struct scsi_task *task;
struct scsi_get_lba_status *lbas = NULL;
struct scsi_lba_status_descriptor *lbasd = NULL;
logging(LOG_VERBOSE, "Send GET_LBA_STATUS LBA:%" PRIu64 " alloc_len:%d",
lba, len);
@@ -1919,6 +1921,21 @@ int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t
scsi_free_scsi_task(task);
return -1;
}
lbas = scsi_datain_unmarshall(task);
if (lbas == NULL) {
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
"failed to unmarschall data.");
scsi_free_scsi_task(task);
return -1;
}
lbasd = &lbas->descriptors[0];
if (lbasd->lba != lba) {
logging(LOG_NORMAL, "[FAILED] GET_LBA_STATUS command: "
"lba offset in first descriptor does not match request (0x%" PRIx64 " != 0x%" PRIx64 ").",
lbasd->lba, lba);
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] GET_LBA_STATUS returned SUCCESS.");