diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-12-10 03:12:11 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-12-10 03:12:11 +0000 |
commit | b7d8f269b22f18e363a9e714f5009be4a7ab2601 (patch) | |
tree | 9d58c243c9e09fbe588a76afa323c08db303e536 | |
parent | b2f28fb3709b664e676b6b83810a1cfc4608f645 (diff) | |
download | wireshark-b7d8f269b22f18e363a9e714f5009be4a7ab2601.tar.gz wireshark-b7d8f269b22f18e363a9e714f5009be4a7ab2601.tar.bz2 wireshark-b7d8f269b22f18e363a9e714f5009be4a7ab2601.zip |
Make sure we don't try to allocate a negative number.
svn path=/trunk/; revision=23820
-rw-r--r-- | epan/dissectors/packet-cip.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c index 236fee2499..8b2b2ff9f9 100644 --- a/epan/dissectors/packet-cip.c +++ b/epan/dissectors/packet-cip.c @@ -405,6 +405,9 @@ add_byte_array_text_to_proto_tree( proto_tree *tree, tvbuff_t *tvb, gint start, tmp2_length = ( length * 2 ) + 1; } + + /* Throw an exception if tmp_length is negative */ + tvb_ensure_bytes_exist( tvb, start, tmp_length ); tmp = tvb_get_ptr( tvb, start, tmp_length ); tmp2 = (char*)ep_alloc( tmp2_length ); @@ -1053,7 +1056,7 @@ dissect_cip_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, int item_len /* Add reply status to info column */ if(check_col(pinfo->cinfo, COL_INFO)) { - col_append_str( pinfo->cinfo, COL_INFO, + col_append_str( pinfo->cinfo, COL_INFO, val_to_str( ( tvb_get_guint8( tvb, offset+2 ) ), cip_gs_vals , "Unknown Response (%x)") ); } @@ -1304,7 +1307,7 @@ dissect_cip_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, int item_len /* Add service to info column */ if(check_col(pinfo->cinfo, COL_INFO)) { - col_append_str( pinfo->cinfo, COL_INFO, + col_append_str( pinfo->cinfo, COL_INFO, val_to_str( ( tvb_get_guint8( tvb, offset ) & 0x7F ), cip_sc_vals , "Unknown Service (%x)") ); } |