diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-02-25 09:31:07 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-02-25 09:31:07 +0000 |
commit | 857318d3b760aa1ee27b9025746e1f39ce946a53 (patch) | |
tree | 4e9d5900443b375741a9966dee096dee52c01a1c /packet-nlm.c | |
parent | 3353ca1d5a8307ce1ae6afd49b3f7525596e0910 (diff) | |
download | wireshark-857318d3b760aa1ee27b9025746e1f39ce946a53.tar.gz wireshark-857318d3b760aa1ee27b9025746e1f39ce946a53.tar.bz2 wireshark-857318d3b760aa1ee27b9025746e1f39ce946a53.zip |
Use "tvb_get_string()" instead of allocating a (len+1)-sized buffer,
"tvb_memcpy()"ing to it, and putting in a null terminator;
"tvb_get_string()" will check whether all bytes of the string are
present before allocating the buffer, so that you don't leak memory if
the copy throws an exception, and don't crash if the length is absurdly
large.
Use "tvb_memdup()" instead of allocating a buffer and "tvb_memcpy()"ing
to it, so that an exception is thrown before you try to allocate the
buffer (for the same reasons as listed above).
Before allocating a buffer used when processing a chunk of data from a
packet, get a pointer to the chunk with "tvb_get_ptr()", or check that
the data is all there with "tvb_ensure_bytes_exist()", so that an
exception is thrown before you try to allocate the buffer (for the same
reasons as listed above).
Fix up the lengths of the tvbuff used when dissecting ONC RPC opaque data
with a particular dissector.
svn path=/trunk/; revision=10236
Diffstat (limited to 'packet-nlm.c')
-rw-r--r-- | packet-nlm.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/packet-nlm.c b/packet-nlm.c index 01a4bdeea0..a7fa6f8220 100644 --- a/packet-nlm.c +++ b/packet-nlm.c @@ -1,7 +1,7 @@ /* packet-nlm.c * Routines for nlm dissection * - * $Id: packet-nlm.c,v 1.35 2003/08/17 21:34:22 sahlberg Exp $ + * $Id: packet-nlm.c,v 1.36 2004/02/25 09:31:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -296,7 +296,6 @@ nlm_register_unmatched_msg(packet_info *pinfo, tvbuff_t *tvb, int offset) { nlm_msg_res_unmatched_data *umd; nlm_msg_res_unmatched_data *old_umd; - char *cookie; /* allocate and build the unmatched structure for this request */ umd=g_malloc(sizeof(nlm_msg_res_unmatched_data)); @@ -304,9 +303,7 @@ nlm_register_unmatched_msg(packet_info *pinfo, tvbuff_t *tvb, int offset) umd->ns.secs=pinfo->fd->abs_secs; umd->ns.nsecs=pinfo->fd->abs_usecs*1000; umd->cookie_len=tvb_get_ntohl(tvb, offset); - cookie=g_malloc(umd->cookie_len); - tvb_memcpy(tvb, (guint8 *)cookie, offset+4, umd->cookie_len); - umd->cookie=cookie; + umd->cookie=tvb_memdup(tvb, offset+4, umd->cookie_len); /* remove any old duplicates */ old_umd=g_hash_table_lookup(nlm_msg_res_unmatched, (gconstpointer)umd); |