diff --git a/include/iscsi-private.h b/include/iscsi-private.h index fd4c5b7e..4842fce3 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -107,8 +107,8 @@ struct iscsi_context { uint32_t target_max_recv_data_segment_length; enum iscsi_initial_r2t want_initial_r2t; enum iscsi_initial_r2t use_initial_r2t; - enum iscsi_initial_r2t want_immediate_data; - enum iscsi_initial_r2t use_immediate_data; + enum iscsi_immediate_data want_immediate_data; + enum iscsi_immediate_data use_immediate_data; }; #define ISCSI_PDU_IMMEDIATE 0x40 diff --git a/include/iscsi.h b/include/iscsi.h index 4582ffd6..6064f8c9 100644 --- a/include/iscsi.h +++ b/include/iscsi.h @@ -195,7 +195,8 @@ enum iscsi_header_digest { ISCSI_HEADER_DIGEST_NONE = 0, ISCSI_HEADER_DIGEST_NONE_CRC32C = 1, ISCSI_HEADER_DIGEST_CRC32C_NONE = 2, - ISCSI_HEADER_DIGEST_CRC32C = 3 + ISCSI_HEADER_DIGEST_CRC32C = 3, + ISCSI_HEADER_DIGEST_LAST = ISCSI_HEADER_DIGEST_CRC32C }; /* diff --git a/lib/init.c b/lib/init.c index 826e04f8..705e4c5a 100644 --- a/lib/init.c +++ b/lib/init.c @@ -282,6 +282,10 @@ iscsi_set_header_digest(struct iscsi_context *iscsi, "logged in"); return -1; } + if ((unsigned)header_digest > ISCSI_HEADER_DIGEST_LAST) { + iscsi_set_error(iscsi, "invalid header digest value"); + return -1; + } iscsi->want_header_digest = header_digest; diff --git a/lib/login.c b/lib/login.c index 0d4d7e9b..24348e82 100644 --- a/lib/login.c +++ b/lib/login.c @@ -188,6 +188,9 @@ iscsi_login_add_headerdigest(struct iscsi_context *iscsi, struct iscsi_pdu *pdu) case ISCSI_HEADER_DIGEST_CRC32C: str = (char *)"HeaderDigest=CRC32C"; break; + default: + iscsi_set_error(iscsi, "invalid header digest value"); + return -1; } if (iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)str, strlen(str)+1) diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 0aff97ab..eb45d880 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -805,6 +805,10 @@ scsi_modesense_datain_unmarshall(struct scsi_task *task) case SCSI_MODESENSE_PAGECODE_INFORMATIONAL_EXCEPTIONS_CONTROL: scsi_parse_mode_informational_exceptions_control(task, pos, mp); break; + default: + /* TODO: process other pages, or add raw data to struct + * scsi_mode_page. */ + break; } mp->next = ms->pages; @@ -1082,7 +1086,7 @@ scsi_get_task_private_ptr(struct scsi_task *task) struct scsi_data_buffer { struct scsi_data_buffer *next; - int len; + uint32_t len; unsigned char *data; }; @@ -1091,6 +1095,9 @@ scsi_task_add_data_in_buffer(struct scsi_task *task, int len, unsigned char *buf { struct scsi_data_buffer *data_buf; + if (len < 0) { + return -1; + } data_buf = scsi_malloc(task, sizeof(struct scsi_data_buffer)); if (data_buf == NULL) { return -1;