Ethereal-cvs: [Ethereal-cvs] cvs commit: ethereal/epan proto.c tvbuff.c tvbuff.h

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

From: Gilbert Ramirez <gram@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 6 Mar 2002 16:38:44 -0600 (CST)
gram        2002/03/06 16:38:44 CST

  Modified files:        (Branch: Novell_NCP_branch)
    epan                 proto.c tvbuff.c tvbuff.h 
  Log:
  This is almost identical to the change made in the main branch. I need
  it in Novell_NCP_branch, too.
  
  tvb_get_nstringz() needs to terminate a string with a NUL if the
  end of the tvbuff is reached before the maximum_length passed by the
  caller is reached and before a terminating NUL is found. In this case,
  tvb_get_nstringz() returns a -1, but if the string is not artificially
  terminated with a NUL by tvb_get_nstringz(), the
  caller has no idea where the string should end because 1) the
  return value "-1" gives the impression that the string ends
  at the end of the buffer but 2) the string does
  not end at the end of the buffer, but somewhere in the middle, due
  to the packet being shorter than expected.
  
  tvb_get_nstringz() and tvb_get_nstringz0() were both modified.
  
  The FT_STRINGZ case in proto_tree_add_item() is made simpler.
  
  During regression testing, when investigating a regression that I later
  corrected, I discovered that strings added through proto_tree_add_item
  (FT_STRING, FT_STRINGZ, and FT_UINT_STRING) leaked memory due to double
  allocation of the string. The proto_tree_add_string*() functions do
  not leak memory, since they only copy the string once. The memory
  leak was fixed by adding another argument to the static function
  proto_tree_set_string() to let the string ftype code know to g_strdup()
  the string or not.
  
  Revision  Changes    Path
  1.51.2.3  +12 -12    ethereal/epan/proto.c
  1.29.2.1  +62 -13    ethereal/epan/tvbuff.c
  1.21.2.1  +8 -1      ethereal/epan/tvbuff.h