Add a small extra check in fragment_add() to make it idempotent.
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 17 Apr 2003 10:31:35 +0000 (10:31 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 17 Apr 2003 10:31:35 +0000 (10:31 +0000)
This solves a problem introduced by the recent rewrite of dcerpc-over-smb
reassembly which caused the last fragment for each dcerpc pdu to be duplicated and flagged as overlapping fragment.

This

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

reassemble.c

index b89b5bff72f631a51ec90d2be50bc553dfcdc678..e29fd32ccb841e7218392bd805fb13b6c4bffaeb 100644 (file)
@@ -1,7 +1,7 @@
 /* reassemble.c
  * Routines for {fragment,segment} reassembly
  *
- * $Id: reassemble.c,v 1.30 2003/04/09 09:04:08 sahlberg Exp $
+ * $Id: reassemble.c,v 1.31 2003/04/17 10:31:35 sahlberg Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -429,10 +429,12 @@ fragment_add(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id,
 {
        fragment_key key, *new_key;
        fragment_data *fd_head;
+       fragment_data *fd_item;
        fragment_data *fd;
        fragment_data *fd_i;
        guint32 max, dfpos;
        unsigned char *old_data;
+       gboolean already_added=FALSE;
 
        /* create key to search hash with */
        key.src = pinfo->src;
@@ -441,8 +443,20 @@ fragment_add(tvbuff_t *tvb, int offset, packet_info *pinfo, guint32 id,
 
        fd_head = g_hash_table_lookup(fragment_table, &key);
 
+       /* Just check if we have seen this fragment before, i.e.
+          if we have already added it to reassembly.
+          We can not trust the flags.visited field since we sometimes
+          might call a subdissector multiple times.
+          As an additional check just make sure we have not already added 
+          this frame to the reassembly list
+       */
+       for(fd_item=fd_head;fd_item;fd_item=fd_item->next){
+               if(pinfo->fd->num==fd_item->frame){
+                       already_added=TRUE;
+               }
+       }
        /* have we already seen this frame ?*/
-       if (pinfo->fd->flags.visited) {
+       if (pinfo->fd->flags.visited || already_added) {
                if (fd_head != NULL && fd_head->flags & FD_DEFRAGMENTED) {
                        return fd_head;
                } else {