In the SEQUENCE OF dissector helper
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 29 Aug 2005 08:24:15 +0000 (08:24 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 29 Aug 2005 08:24:15 +0000 (08:24 +0000)
Only count the number of items in the SEQUENCE OF   IFF we have the full TVB containing the entire blob.
Dont count the items if the tvb is "short" since then this would just lead to a [short frame]  before a single item in the SEQUENCE OF has been dissected.

Do we really need to count the items and create a FT_UINT field with the number of items at all?
Then count the items as we are calling the subdissectors and
append the '# item[s]' text to the FT_NONE items after we finished the loop?

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15607 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-ber.c

index 0ccf2b3a86b4c6635033eded6b5dbc90f86ec37b..06ab7ed2abd4b86cf34426714c0d8bee11b91eec 100644 (file)
@@ -1679,22 +1679,29 @@ printf("SQ OF dissect_ber_sq_of(%s) entered\n",name);
        /* count number of items */
        cnt = 0;
        hoffset = offset;
-       while (offset < end_offset){
-               guint32 len;
-
-               if(ind){ /* this sequence of was of indefinite length, so check for EOC */
-                       if((tvb_get_guint8(tvb, offset)==0)&&(tvb_get_guint8(tvb, offset+1)==0)){                               
-                               break;
+       /* only count the number of items IFF we have the full blob,
+        * else this will just generate a [short frame] before we even start
+        * dissecting a single item.
+        */
+       /* XXX Do we really need to count them at all ?  ronnie */
+       if(tvb_length_remaining(tvb, offset)==tvb_reported_length_remaining(tvb, offset)){
+               while (offset < end_offset){
+                       guint32 len;
+       
+                       if(ind){ /* this sequence of was of indefinite length, so check for EOC */
+                               if((tvb_get_guint8(tvb, offset)==0)&&(tvb_get_guint8(tvb, offset+1)==0)){                               
+                                       break;
+                               }
                        }
-               }
 
-               /* read header and len for next field */
-               offset = get_ber_identifier(tvb, offset, NULL, NULL, NULL);
-               offset = get_ber_length(tree, tvb, offset, &len, NULL);
-               /* best place to get real length of implicit sequence of or set of is here... */
-               /* adjust end_offset if we find somthing that doesnt match */
-               offset += len;
-               cnt++;
+                       /* read header and len for next field */
+                       offset = get_ber_identifier(tvb, offset, NULL, NULL, NULL);
+                       offset = get_ber_length(tree, tvb, offset, &len, NULL);
+                       /* best place to get real length of implicit sequence of or set of is here... */
+                       /* adjust end_offset if we find somthing that doesnt match */
+                       offset += len;
+                       cnt++;
+               }
        }
        offset = hoffset;
 
@@ -1768,16 +1775,15 @@ printf("SQ OF dissect_ber_sq_of(%s) entered\n",name);
                                /* hold on if we are implicit and the result is zero, i.e. the item in the sequence of 
                                doesnt match the next item, thus this implicit sequence is over, return the number of bytes
                                we have eaten to allow the possible upper sequence continue... */
+               cnt++; /* rubbish*/
                if(ind_field){
                        /* previous field was of indefinite length so we have
                         * no choice but use whatever the subdissector told us
                         * as size for the field.
                         * not any more the length should be correct
                         */
-                       cnt++; /* rubbish*/
                        offset = eoffset;
                } else {
-                       cnt++; /* more rusbbish */
                        offset = eoffset;
                }
        }