Use "proto_tree_add_item()", not "proto_tree_add_string()" with a

"tvb_get_ptr()" call using the same offset and length as the
"proto_tree_add_string()" call, to add FT_STRING fields to the tree.
(The value argument to "proto_tree_add_string()" must be
null-terminated, and there's no guarantee that the string you get from
the "tvb_get_ptr()" call will be null-terminated;
"proto_tree_add_item()" with an FT_STRING field, however, will
null-terminate the value.)

Fix the length argument in the call for the last item in the Yahoo
Messenger tree.

svn path=/trunk/; revision=3729
This commit is contained in:
Guy Harris 2001-07-16 06:09:02 +00:00
parent f338bd3ffc
commit 30c935a72e
2 changed files with 27 additions and 32 deletions

View File

@ -2,7 +2,7 @@
* Routines for yahoo messenger packet dissection
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
*
* $Id: packet-yhoo.c,v 1.17 2001/07/03 04:56:46 guy Exp $
* $Id: packet-yhoo.c,v 1.18 2001/07/16 06:09:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -154,44 +154,44 @@ dissect_yhoo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tvb_length_remaining(tvb, offset), FALSE);
yhoo_tree = proto_item_add_subtree(ti, ett_yhoo);
proto_tree_add_string(yhoo_tree, hf_yhoo_version, tvb,
offset, 8, tvb_get_ptr(tvb, offset, 8));
proto_tree_add_item(yhoo_tree, hf_yhoo_version, tvb,
offset, 8, TRUE);
offset += 8;
proto_tree_add_uint(yhoo_tree, hf_yhoo_len, tvb,
offset, 4, tvb_get_letohl(tvb, offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_len, tvb,
offset, 4, TRUE);
offset += 4;
proto_tree_add_uint(yhoo_tree, hf_yhoo_service, tvb,
offset, 4, tvb_get_letohl(tvb, offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_service, tvb,
offset, 4, TRUE);
offset += 4;
proto_tree_add_uint(yhoo_tree, hf_yhoo_connection_id, tvb,
offset, 4, tvb_get_letohl(tvb, offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_connection_id, tvb,
offset, 4, TRUE);
offset += 4;
proto_tree_add_uint(yhoo_tree, hf_yhoo_magic_id, tvb,
offset, 4, tvb_get_letohl(tvb, offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_magic_id, tvb,
offset, 4, TRUE);
offset += 4;
proto_tree_add_uint(yhoo_tree, hf_yhoo_unknown1, tvb,
offset, 4, tvb_get_letohl(tvb, offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_unknown1, tvb,
offset, 4, TRUE);
offset += 4;
proto_tree_add_uint(yhoo_tree, hf_yhoo_msgtype, tvb,
offset, 4, tvb_get_letohl(tvb, offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_msgtype, tvb,
offset, 4, TRUE);
offset += 4;
proto_tree_add_string(yhoo_tree, hf_yhoo_nick1, tvb,
offset, 36, tvb_get_ptr(tvb, offset, 36));
proto_tree_add_item(yhoo_tree, hf_yhoo_nick1, tvb,
offset, 36, TRUE);
offset += 36;
proto_tree_add_string(yhoo_tree, hf_yhoo_nick2, tvb,
offset, 36, tvb_get_ptr(tvb, offset, 36));
proto_tree_add_item(yhoo_tree, hf_yhoo_nick2, tvb,
offset, 36, TRUE);
offset += 36;
proto_tree_add_string(yhoo_tree, hf_yhoo_content, tvb,
offset, length, tvb_get_ptr(tvb, offset, length-offset));
proto_tree_add_item(yhoo_tree, hf_yhoo_content, tvb,
offset, length-offset, TRUE);
}
return TRUE;

View File

@ -3,12 +3,11 @@
*
* Jochen Friedrich <jochen@scram.de>
*
* $Id: packet-zebra.c,v 1.13 2001/06/18 02:17:58 guy Exp $
* $Id: packet-zebra.c,v 1.14 2001/07/16 06:09:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -23,8 +22,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*/
#ifdef HAVE_CONFIG_H
@ -214,9 +211,8 @@ dissect_zebra_request(proto_tree *tree, gboolean request, tvbuff_t *tvb,
if (request) break;
/* Request just subscribes to messages */
proto_tree_add_string(tree, hf_zebra_interface,
tvb, offset, INTERFACE_NAMSIZ,
tvb_get_ptr(tvb, offset, INTERFACE_NAMSIZ));
proto_tree_add_item(tree, hf_zebra_interface,
tvb, offset, INTERFACE_NAMSIZ, FALSE);
offset += INTERFACE_NAMSIZ;
proto_tree_add_item(tree, hf_zebra_index, tvb,
@ -241,9 +237,8 @@ dissect_zebra_request(proto_tree *tree, gboolean request, tvbuff_t *tvb,
break;
case ZEBRA_INTERFACE_DELETE:
proto_tree_add_string(tree, hf_zebra_interface,
tvb, offset, INTERFACE_NAMSIZ,
tvb_get_ptr(tvb, offset, INTERFACE_NAMSIZ));
proto_tree_add_item(tree, hf_zebra_interface,
tvb, offset, INTERFACE_NAMSIZ, FALSE);
offset += INTERFACE_NAMSIZ;
proto_tree_add_item(tree, hf_zebra_index, tvb,