Ethereal-dev: Re: [Ethereal-dev] bug in TNS dissector

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Thu, 17 Jan 2002 12:57:45 -0800 (PST)
> I think I have found a bug in ethereal TNS dissector. When I try to load
> attached packet then ethereal crashes.

I've checked in a fix, which also cleans up a number of calls in the
dissector (including a bug I'd introduced in tvbuffifying the dissector
a while ago).  I've attached the patch for it.

However, the packet doesn't seem to be a valid packet, at least
according to the dissector; starting at the "Header Checksum" field, the
packet appears to have text strings, and if you take the byte *before*
the "OS Other system trap CPU time" string as a byte count, it's the
length of that string.

"OS Other system trap CPU time" *does*, from a Google search, appear to
be the name of a statistic Oracle can report in what I presume is a
database table the server can supply, so there might be another problem
in the TNS dissector.
? errs
? .pure
? Makefile.gprof
? WORK
? gtkdialogbox.c
? gtkdialogbox.h
? errs.DU
? errs.hpux
? capture.c.WARNING
? simple_dialog.h.WARNING
? packet-ipx.c.NEW
? gtk/simple_dialog.c.WARNING
? wiretap/SAVE
? wiretap/filter-fddi
? wiretap/Makefile.gprof
? wiretap/.pure
? wiretap/iptrace.c.HACK
Index: packet-tns.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-tns.c,v
retrieving revision 1.24
diff -c -r1.24 packet-tns.c
*** packet-tns.c	2001/12/10 00:25:40	1.24
--- packet-tns.c	2002/01/17 20:47:17
***************
*** 195,212 ****
  	{
  		proto_tree *df_tree = NULL;
  		
! 		ti = proto_tree_add_uint(data_tree, hf_tns_data_flag, tvb, offset, 2, FALSE);
  		
  		df_tree = proto_item_add_subtree(ti, ett_tns_data_flag);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_send, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_rc, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_c, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_reserved, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_more, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_eof, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_dic, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_rts, tvb, offset, 2, FALSE);
! 		proto_tree_add_uint(df_tree, hf_tns_data_flag_sntt, tvb, offset, 2, FALSE);
  	}
  	offset += 2;
  
--- 195,212 ----
  	{
  		proto_tree *df_tree = NULL;
  		
! 		ti = proto_tree_add_item(data_tree, hf_tns_data_flag, tvb, offset, 2, FALSE);
  		
  		df_tree = proto_item_add_subtree(ti, ett_tns_data_flag);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_send, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_rc, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_c, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_reserved, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_more, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_eof, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_dic, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_rts, tvb, offset, 2, FALSE);
! 		proto_tree_add_item(df_tree, hf_tns_data_flag_sntt, tvb, offset, 2, FALSE);
  	}
  	offset += 2;
  
***************
*** 270,312 ****
  	if ( connect_tree )
  	{
  		/* need to break down w/ bitfield */
! 		proto_tree_add_uint(connect_tree, hf_tns_service_options, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_sdu_size, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_max_tdu_size, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_nt_proto_characteristics, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_line_turnaround, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_bytes(connect_tree, hf_tns_value_of_one, tvb,
! 			offset, 2, tvb_get_ptr(tvb, offset, 2));
  	}
  	offset += 2;
  
--- 270,312 ----
  	if ( connect_tree )
  	{
  		/* need to break down w/ bitfield */
! 		proto_tree_add_item(connect_tree, hf_tns_service_options, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_sdu_size, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_max_tdu_size, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_nt_proto_characteristics, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_line_turnaround, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_value_of_one, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
***************
*** 328,379 ****
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_connect_data_max, tvb,
! 			offset, 4, tvb_get_ntohl(tvb, offset));
  	}
  	offset += 4;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_connect_flags0, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_connect_flags1, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_trace_cf1, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_trace_cf2, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_uint(connect_tree, hf_tns_trace_cid, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( connect_tree && cd_len > 0)
  	{
! 		proto_tree_add_string(connect_tree, hf_tns_connect_data, tvb,
! 			tns_offset+cd_offset, tvb_length(tvb)-(tns_offset+cd_offset), 
! 			tvb_get_ptr(tvb, tns_offset+cd_offset,
! 			tvb_length(tvb)-(tns_offset+cd_offset)));
  	}
  	return;
  }
--- 328,378 ----
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_connect_data_max, tvb,
! 			offset, 4, FALSE);
  	}
  	offset += 4;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_connect_flags0, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_connect_flags1, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_trace_cf1, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_trace_cf2, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree )
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_trace_cid, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( connect_tree && cd_len > 0)
  	{
! 		proto_tree_add_item(connect_tree, hf_tns_connect_data, tvb,
! 			tns_offset+cd_offset,
! 			tvb_length(tvb)-(tns_offset+cd_offset), FALSE);
  	}
  	return;
  }
***************
*** 410,438 ****
  	
  	if ( accept_tree )
  	{
! 		proto_tree_add_uint(accept_tree, hf_tns_service_options, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_uint(accept_tree, hf_tns_sdu_size, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_uint(accept_tree, hf_tns_max_tdu_size, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_bytes(accept_tree, hf_tns_value_of_one, tvb,
! 			offset, 2, tvb_get_ptr(tvb, offset, 2));
  	}
  	offset += 2;
  
--- 409,437 ----
  	
  	if ( accept_tree )
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_service_options, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_sdu_size, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_max_tdu_size, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_value_of_one, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
***************
*** 454,477 ****
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_uint(accept_tree, hf_tns_connect_flags0, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_uint(accept_tree, hf_tns_connect_flags1, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( accept_tree && accept_len > 0)
  	{
! 		proto_tree_add_string(accept_tree, hf_tns_accept_data, tvb,
! 			tns_offset+accept_offset, tvb_length(tvb)-(tns_offset+accept_offset), 
! 			tvb_get_ptr(tvb, tns_offset+accept_offset,
! 			tvb_length(tvb)-(tns_offset+accept_offset)));
  	}
  	return;
  }
--- 453,475 ----
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_connect_flags0, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( accept_tree )
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_connect_flags1, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( accept_tree && accept_len > 0)
  	{
! 		proto_tree_add_item(accept_tree, hf_tns_accept_data, tvb,
! 			tns_offset+accept_offset,
! 			tvb_length(tvb)-(tns_offset+accept_offset), FALSE);
  	}
  	return;
  }
***************
*** 499,528 ****
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_uint(refuse_tree, hf_tns_refuse_reason_user, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_uint(refuse_tree, hf_tns_refuse_reason_system, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_uint(refuse_tree, hf_tns_refuse_data_length, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_string(refuse_tree, hf_tns_refuse_data, tvb,
! 			offset, tvb_length(tvb)-offset, 
! 			tvb_get_ptr(tvb, offset, tvb_length(tvb)-offset));
  	}
  	return;
  }
--- 497,525 ----
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_item(refuse_tree, hf_tns_refuse_reason_user, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_item(refuse_tree, hf_tns_refuse_reason_system, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_item(refuse_tree, hf_tns_refuse_data_length, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( refuse_tree )
  	{
! 		proto_tree_add_item(refuse_tree, hf_tns_refuse_data, tvb,
! 			offset, tvb_length(tvb)-offset, FALSE);
  	}
  	return;
  }
***************
*** 550,572 ****
  
  	if ( abort_tree )
  	{
! 		proto_tree_add_uint(abort_tree, hf_tns_abort_reason_user, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( abort_tree )
  	{
! 		proto_tree_add_uint(abort_tree, hf_tns_abort_reason_system, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( abort_tree )
  	{
! 		proto_tree_add_string(abort_tree, hf_tns_abort_data, tvb,
! 			offset, tvb_length_remaining(tvb,offset), 
! 			tvb_get_ptr(tvb, offset, tvb_length_remaining(tvb,offset)));
  	}
  	return;
  }
--- 547,568 ----
  
  	if ( abort_tree )
  	{
! 		proto_tree_add_item(abort_tree, hf_tns_abort_reason_user, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( abort_tree )
  	{
! 		proto_tree_add_item(abort_tree, hf_tns_abort_reason_system, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( abort_tree )
  	{
! 		proto_tree_add_item(abort_tree, hf_tns_abort_data, tvb,
! 			offset, tvb_length_remaining(tvb,offset), FALSE);
  	}
  	return;
  }
***************
*** 609,630 ****
  
  	if ( marker_tree )
  	{
! 		proto_tree_add_uint(marker_tree, hf_tns_marker_type, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( marker_tree )
  	{
! 		proto_tree_add_uint(marker_tree, hf_tns_marker_data_byte, tvb,
! 			offset, 1, tvb_get_guint8(tvb, offset));
  	}
  	offset += 1;
  
  	if ( marker_tree )
  	{
! 		proto_tree_add_uint(marker_tree, hf_tns_marker_data_byte, tvb,
! 			offset, 1, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 1;
  
--- 605,626 ----
  
  	if ( marker_tree )
  	{
! 		proto_tree_add_item(marker_tree, hf_tns_marker_type, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( marker_tree )
  	{
! 		proto_tree_add_item(marker_tree, hf_tns_marker_data_byte, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
  	if ( marker_tree )
  	{
! 		proto_tree_add_item(marker_tree, hf_tns_marker_data_byte, tvb,
! 			offset, 1, FALSE);
  	}
  	offset += 1;
  
***************
*** 653,668 ****
  
  	if ( redirect_tree )
  	{
! 		proto_tree_add_uint(redirect_tree, hf_tns_redirect_data_length, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( redirect_tree )
  	{
! 		proto_tree_add_string(redirect_tree, hf_tns_redirect_data, tvb,
! 			offset, tvb_length(tvb)-offset, 
! 			tvb_get_ptr(tvb, offset, tvb_length(tvb)-offset));
  	}
  	return;
  }
--- 649,663 ----
  
  	if ( redirect_tree )
  	{
! 		proto_tree_add_item(redirect_tree, hf_tns_redirect_data_length, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( redirect_tree )
  	{
! 		proto_tree_add_item(redirect_tree, hf_tns_redirect_data, tvb,
! 			offset, tvb_length(tvb)-offset, FALSE);
  	}
  	return;
  }
***************
*** 689,704 ****
  
  	if ( control_tree )
  	{
! 		proto_tree_add_uint(control_tree, hf_tns_control_cmd, tvb,
! 			offset, 2, tvb_get_ntohs(tvb, offset));
  	}
  	offset += 2;
  
  	if ( control_tree )
  	{
! 		proto_tree_add_string(control_tree, hf_tns_control_data, tvb,
! 			offset, tvb_length(tvb)-offset, 
! 			tvb_get_ptr(tvb, offset, tvb_length(tvb)-offset));
  	}
  	return;
  }
--- 684,698 ----
  
  	if ( control_tree )
  	{
! 		proto_tree_add_item(control_tree, hf_tns_control_cmd, tvb,
! 			offset, 2, FALSE);
  	}
  	offset += 2;
  
  	if ( control_tree )
  	{
! 		proto_tree_add_item(control_tree, hf_tns_control_data, tvb,
! 			offset, tvb_length(tvb)-offset, FALSE);
  	}
  	return;
  }