Ethereal-dev: [Ethereal-dev] Minor fixes for packet-iscsi and packet-scsi

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Mark Burton <markb@xxxxxxxxxx>
Date: Wed, 16 Jan 2002 11:33:20 GMT
The enclosed patch reinstates the data segment digest handling that
got zapped in the recent update and also stops the scsi dissector from
treating data digests as payload.


? foo
? foo.diff
? packet-iscsi.c-
Index: packet-iscsi.c
===================================================================
RCS file: /cvsroot/ethereal/packet-iscsi.c,v
retrieving revision 1.19
diff -u -3 -p -r1.19 packet-iscsi.c
--- packet-iscsi.c	2002/01/10 01:28:43	1.19
+++ packet-iscsi.c	2002/01/16 11:32:41
@@ -669,6 +669,9 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_
     conversation_t *conversation = NULL;
     iscsi_conv_data_t *cdata = NULL;
     iscsi_conv_key_t ckey, *req_key;
+    int paddedDataSegmentLength = data_segment_len;
+    if(paddedDataSegmentLength & 3)
+	paddedDataSegmentLength += 4 - (paddedDataSegmentLength & 3);
 
     /* Make entries in Protocol column and Info column on summary display */
     if (check_col(pinfo->cinfo, COL_PROTOCOL))
@@ -861,6 +864,9 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_
 	    proto_tree_add_item(ti, hf_iscsi_ExpDataSN, tvb, offset + 36, 4, FALSE);
 	    proto_tree_add_item(ti, hf_iscsi_SCSIResponse_BidiReadResidualCount, tvb, offset + 44, 4, FALSE);
 	    offset = handleHeaderDigest(ti, tvb, offset, 48);
+	    /* do not update offset here because the data segment is
+	     * dissected below */
+	    handleDataDigest(ti, tvb, offset, paddedDataSegmentLength);
 	}
 	else if(opcode == ISCSI_OPCODE_TASK_MANAGEMENT_FUNCTION) {
 	    /* Task Management Function */
@@ -1003,6 +1009,9 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_
 	    proto_tree_add_item(ti, hf_iscsi_DataSN, tvb, offset + 36, 4, FALSE);
 	    proto_tree_add_item(ti, hf_iscsi_BufferOffset, tvb, offset + 40, 4, FALSE);
 	    offset = handleHeaderDigest(ti, tvb, offset, 48);
+	    /* do not update offset here because the data segment is
+	     * dissected below */
+	    handleDataDigest(ti, tvb, offset, paddedDataSegmentLength);
 	}
 	else if(opcode == ISCSI_OPCODE_SCSI_DATA_IN) {
 	    /* SCSI Data In (read) */
@@ -1026,6 +1035,9 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_
 	    proto_tree_add_item(ti, hf_iscsi_DataSN, tvb, offset + 36, 4, FALSE);
 	    proto_tree_add_item(ti, hf_iscsi_BufferOffset, tvb, offset + 40, 4, FALSE);
 	    offset = handleHeaderDigest(ti, tvb, offset, 48);
+	    /* do not update offset here because the data segment is
+	     * dissected below */
+	    handleDataDigest(ti, tvb, offset, paddedDataSegmentLength);
 	}
 	else if(opcode == ISCSI_OPCODE_LOGOUT_COMMAND) {
 	    /* Logout Command */
Index: packet-scsi.c
===================================================================
RCS file: /cvsroot/ethereal/packet-scsi.c,v
retrieving revision 1.1
diff -u -3 -p -r1.1 packet-scsi.c
--- packet-scsi.c	2002/01/10 01:28:43	1.1
+++ packet-scsi.c	2002/01/16 11:32:44
@@ -2055,7 +2055,7 @@ dissect_scsi_payload (tvbuff_t *tvb, pac
     if (tree) {
         if (cmd == SCSI_CMND_SPC2) {
             ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
-                                                 tvb_length (tvb),
+                                                 payload_len,
                                                  "SCSI Payload (%s %s)",
                                                  val_to_str (opcode,
                                                              scsi_spc2_val,
@@ -2064,7 +2064,7 @@ dissect_scsi_payload (tvbuff_t *tvb, pac
         }
         else if (cmd == SCSI_CMND_SBC2) {
             ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
-                                                 tvb_length (tvb),
+                                                 payload_len,
                                                  "SCSI Payload (%s %s)",
                                                  val_to_str (opcode,
                                                              scsi_sbc2_val,
@@ -2073,7 +2073,7 @@ dissect_scsi_payload (tvbuff_t *tvb, pac
         }
         else {
             ti = proto_tree_add_protocol_format (tree, proto_scsi, tvb, offset,
-                                                 tvb_length (tvb),
+                                                 payload_len,
                                                  "SCSI Payload (0x%02x %s)",
                                                  opcode,
                                                  isreq ? "Request" : "Response");
This message has been 'sanitized'.  This means that potentially
dangerous content has been rewritten or removed.  The following
log describes which actions were taken.

Sanitizer (start="1011180821"):
  Replaced MIME boundary: >>--Next_Part--<<
                    with: >>MIMEStream=_0+77822_483121192116653_7435146337<<
  Writer (pos="1392"):
    Total modifications so far: 1

  Part (pos="1438"):
    SanitizeFile (filename="unnamed.txt", mimetype="Text/Plain"):
      Match (rule="2"):
        Enforced policy: accept

  Part (pos="1737"):
    SanitizeFile (filename="foo.diff", mimetype="Text/Plain"):
      Match (rule="default"):
        Enforced policy: accept


Anomy 0.0.0 : Sanitizer.pm
$Id: Sanitizer.pm,v 1.32 2001/10/11 19:27:15 bre Exp $