aboutsummaryrefslogtreecommitdiffstats
path: root/packet-socks.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-08-06 10:04:15 +0000
committerGuy Harris <guy@alum.mit.edu>2000-08-06 10:04:15 +0000
commita056a4d4469a97fed144343020231083889aa987 (patch)
tree8674f6a4991e831c2e63ca459e868b72e3b29846 /packet-socks.c
parentef5f866b73430d1df38f2fdd0df16a6d83598744 (diff)
Use "BYTES_ARE_IN_FRAME()" rather than explicitly checking an offset and
packet length. Use "IS_DATA_IN_FRAME()", rather than checking if "offset+1" is greater than "pi.captured_len", to check whether there's any data left in the packet. Check whether data is in the packet *before* extracting it and stuffing an item into the tree with it. svn path=/trunk/; revision=2216
Diffstat (limited to 'packet-socks.c')
-rw-r--r--packet-socks.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/packet-socks.c b/packet-socks.c
index 62faa64703..aae33c7c96 100644
--- a/packet-socks.c
+++ b/packet-socks.c
@@ -2,7 +2,7 @@
* Routines for socks versions 4 &5 packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-socks.c,v 1.6 2000/08/06 07:22:38 guy Exp $
+ * $Id: packet-socks.c,v 1.7 2000/08/06 10:04:15 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -83,7 +83,7 @@
-#define CHECK_PACKET_LENGTH(X) if ((offset+X) > pi.captured_len){ \
+#define CHECK_PACKET_LENGTH(X) if (!BYTES_ARE_IN_FRAME(offset, X)){ \
proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***"); \
return; }
@@ -233,7 +233,7 @@ static int display_string( const u_char *pd, int offset, frame_data *fd,
char temp[ 256];
int length = GBYTE( pd, offset);
- if ((offset + 8) > pi.captured_len){
+ if (!BYTES_ARE_IN_FRAME(offset, 8)){
proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***");
return 0;
}
@@ -305,7 +305,7 @@ static int display_address( const u_char *pd, int offset,
++offset;
if ( a_type == 1){ /* IPv4 address */
- if ( (offset + 4) > pi.captured_len)
+ if (!BYTES_ARE_IN_FRAME(offset, 4))
proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***");
proto_tree_add_ipv4( tree, hf_socks_ip_dst, NullTVB, offset,
@@ -318,7 +318,7 @@ static int display_address( const u_char *pd, int offset,
"Remote name");
}
else if ( a_type == 4){ /* IPv6 address */
- if ((offset + 16) > pi.captured_len)
+ if (!BYTES_ARE_IN_FRAME(offset, 16))
proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***");
proto_tree_add_ipv6( tree, hf_socks_ip6_dst, NullTVB, offset,
@@ -739,7 +739,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
hash_info->state = Connecting; /* change state */
hash_info->connect_row = get_packet_ptr;
- if (( offset+ 1) > pi.captured_len){
+ if (!BYTES_ARE_IN_FRAME(offset, 1)){
hash_info->state = Done; /* change state */
return;
}
@@ -775,7 +775,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
guint temp;
- if (( offset+ 1) > pi.captured_len){
+ if (!BYTES_ARE_IN_FRAME(offset, 1)){
hash_info->state = Done; /* change state */
return;
}
@@ -793,7 +793,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
offset = get_address_v5( pd, offset, hash_info);
- if (( offset+ 1) > pi.captured_len){
+ if (!BYTES_ARE_IN_FRAME(offset, 1)){
hash_info->state = Done;
return;
}
@@ -827,7 +827,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
offset = get_address_v5( pd, offset, hash_info);
/* save server udp port and create upd conversation */
- if (( offset+ 2) > pi.captured_len){
+ if (!BYTES_ARE_IN_FRAME(offset, 2)){
hash_info->state = Done;
return;
}