"ulong" is not a system-declared data type on all platforms;

casting an arbitrary pointer into a frame to point to something
	longer than 1 byte, and dereferencing it, is dangerous, as
	there's no guarantee that said pointer is properly aligned on
	machines that require alignment;

	the data in an RSVP packet is presumably big-endian in any case,
	so you should use "pntohl()" to access it, rather than just
	blithely dereferencing it;

so use "pntohl()" to extract fields from an RSVP packet rather than
casting pointers to "ulong *" and dereferencing them.

svn path=/trunk/; revision=1709
This commit is contained in:
Guy Harris 2000-03-10 08:41:02 +00:00
parent 5a89694778
commit 156b135d01
1 changed files with 6 additions and 6 deletions

View File

@ -3,7 +3,7 @@
*
* (c) Copyright Ashok Narayanan <ashokn@cisco.com>
*
* $Id: packet-rsvp.c,v 1.15 2000/03/09 18:31:51 ashokn Exp $
* $Id: packet-rsvp.c,v 1.16 2000/03/10 08:41:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -919,7 +919,7 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SESSION_IP],
offset2, 4, *(ulong *)(pd+offset2));
offset2, 4, pntohl(pd+offset2));
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SESSION_PROTO],
offset2+4, 1, *(pd+offset2+4));
@ -951,12 +951,12 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 7 - IPv4 LSP");
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SESSION_IP],
offset2, 4, *(ulong *)(pd+offset2));
offset2, 4, pntohl(pd+offset2));
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SESSION_TUNNEL_ID],
offset2+6, 2, pntohs(pd+offset2+6));
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SESSION_EXT_TUNNEL_ID],
offset2+8, 4, *(ulong *)(pd+offset2+8));
offset2+8, 4, pntohl(pd+offset2+8));
break;
}
@ -1247,7 +1247,7 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 1 - IPv4");
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SENDER_IP],
offset2, 4, *(ulong *)(pd+offset2));
offset2, 4, pntohl(pd+offset2));
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SENDER_PORT],
offset2+6, 2, pntohs(pd+offset2+6));
@ -1270,7 +1270,7 @@ dissect_rsvp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(rsvp_object_tree, offset+3, 1,
"C-type: 7 - IPv4 LSP");
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SENDER_IP],
offset2, 4, *(ulong *)(pd+offset2));
offset2, 4, pntohl(pd+offset2));
proto_tree_add_item(rsvp_object_tree, rsvp_filter[RSVPF_SENDER_LSP_ID],
offset2+6, 2, pntohs(pd+offset2+6));