Wireshark-dev: [Wireshark-dev] [Patch] SCSI persistent reserve in
From: Patrick vd Lageweg <patrick@xxxxxxxxxxxx>
Date: Fri, 26 Jan 2007 13:17:44 +0100
Hi,

This patch fixes three problems with the SCSI persistent reserve in command:
- The Additional length starts at offset 4 and not 0
- The len field contains the length used by the keys and doesn't include the header length. So don't substract the header length from the length.
- The key list is traversed from the beginning to end end and not the other way around. 

	Patrick
Index: epan/dissectors/packet-scsi.c
===================================================================
--- epan/dissectors/packet-scsi.c	(revision 20564)
+++ epan/dissectors/packet-scsi.c	(working copy)
@@ -3050,20 +3050,20 @@
         proto_tree_add_text (tree, tvb, offset, 4, "Generation Number: 0x%08x",
                              tvb_get_ntohl (tvb, offset));
         len = tvb_get_ntohl (tvb, offset+4);
-        proto_tree_add_text (tree, tvb, offset, 4, "Additional Length: %u",
+        proto_tree_add_text (tree, tvb, offset+4, 4, "Additional Length: %u",
                              len);
         len = (payload_len > len) ? len : payload_len;
 
         if ((flags & 0x1F) == SCSI_SPC2_RESVIN_SVCA_RDKEYS) {
 	    /* XXX - what if len is < 8?  That may be illegal, but
 	       that doesn't make it impossible.... */
-            numrec = (len - 8)/8;
+            numrec = len / 8;
             offset += 8;
 
             for (i = 0; i < numrec; i++) {
                 proto_tree_add_item (tree, hf_scsi_persresv_key, tvb, offset,
                                      8, 0);
-                offset -= 8;
+                offset += 8;
             }
         }
         else if ((flags & 0x1F) == SCSI_SPC2_RESVIN_SVCA_RDRESV) {