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

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

From: Guy Harris <guy@xxxxxxxxxxxxxxxxx>
Date: Wed, 4 Jun 2003 16:51:54 -0500 (CDT)
guy         2003/06/04 16:51:54 CDT

  Modified files:
    epan                 proto.c 
  Log:
  When "proto_tree_add_item()" is used with an FT_STRINGZ and given a
  length (rather than being given -1), the length is, in most cases, the
  maximum length of a null-*padded* string, rather than the actual length
  of a null-*terminated* string.  Treat it as such - allocate a buffer one
  larger than the length (to leave room for a terminating '\0'), and pass
  the size of that buffer to "tvb_get_nstringz0()".  (Otherwise, in those
  cases, the last character of the string is chopped off.)
  
  Allow "proto_tree_add_string()" to add FT_STRINGZ items to the protocol
  tree, as well as FT_STRING items.
  
  In "alloc_field_info()", if we're passed a length of -1 and the field is
  an FT_STRINGZ, don't make the length be the length remaining in the
  tvbuff; that way, you *can* use a length of -1 in
  "proto_tree_add_item()" for an FT_STRINGZ item, and have it get the
  actual length by looking for the terminating '\0'.
  
  (We might want to distinguish between null-terminated and null-padded
  strings, e.g. with an FT_STRINGZPAD type.  Null-terminated strings
  rarely, if ever, have a specified length; the length is found by
  scanning for the terminating '\0'.  Null-padded strings presumably
  always have a specified length, which is the length to which the string
  is padded.)
  
  Revision  Changes    Path
  1.87      +67 -24    ethereal/epan/proto.c