diff --git a/epan/dissectors/packet-finger.c b/epan/dissectors/packet-finger.c index 676491548f..6c894a0e07 100644 --- a/epan/dissectors/packet-finger.c +++ b/epan/dissectors/packet-finger.c @@ -14,6 +14,8 @@ #include #include +#include "packet-tcp.h" + void proto_register_finger(void); void proto_reg_handoff_finger(void); @@ -38,7 +40,7 @@ typedef struct _finger_transaction_t { static int dissect_finger(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) + void *data) { proto_item *ti, *expert_ti; proto_tree *finger_tree; @@ -46,6 +48,7 @@ dissect_finger(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, finger_transaction_t *finger_trans; gboolean is_query; guint len; + struct tcpinfo *tcpinfo = (struct tcpinfo*)data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "FINGER"); @@ -76,7 +79,11 @@ dissect_finger(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, finger_trans->req_frame = pinfo->num; finger_trans->req_time = pinfo->abs_ts; } - } else { + } else if (!(tcpinfo && (IS_TH_FIN(tcpinfo->flags) || tcpinfo->is_reassembled))) { + /* If this is the FIN (or already desegmented, as with an out + * of order segment received after FIN) go ahead and dissect + * on the first pass. + */ pinfo->desegment_len = DESEGMENT_UNTIL_FIN; pinfo->desegment_offset = 0; return -1; diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 58e087d9a2..fd69c5e40c 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -7728,7 +7728,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) tcph->th_seq - msp->seq, tcph->th_seglen, FALSE ); - if(ipfd_head) { + if(ipfd_head && ipfd_head->reassembled_in == pinfo->num && ipfd_head->reas_in_layer_num == pinfo->curr_layer_num) { tvbuff_t *next_tvb; /* create a new TVB structure for desegmented data diff --git a/epan/dissectors/packet-whois.c b/epan/dissectors/packet-whois.c index 6ba43bc33d..448602da16 100644 --- a/epan/dissectors/packet-whois.c +++ b/epan/dissectors/packet-whois.c @@ -14,6 +14,8 @@ #include #include +#include "packet-tcp.h" + #define WHOIS_PORT 43 /* This is the registered IANA port (nicname) */ void proto_register_whois(void); @@ -39,7 +41,7 @@ typedef struct _whois_transaction_t { static int dissect_whois(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, - void *data _U_) + void *data) { proto_item *ti, *expert_ti; proto_tree *whois_tree; @@ -47,6 +49,7 @@ dissect_whois(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, whois_transaction_t *whois_trans; gboolean is_query; guint len; + struct tcpinfo *tcpinfo = (struct tcpinfo*)data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "WHOIS"); @@ -90,7 +93,11 @@ dissect_whois(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, whois_trans->req_frame = pinfo->num; whois_trans->req_time = pinfo->abs_ts; } - } else { + } else if (!(tcpinfo && (IS_TH_FIN(tcpinfo->flags) || tcpinfo->is_reassembled))) { + /* If this is the FIN (or already desegmented, as with an out + * of order segment received after FIN) go ahead and dissect + * on the first pass. + */ pinfo->desegment_len = DESEGMENT_UNTIL_FIN; pinfo->desegment_offset = 0; return -1;