aboutsummaryrefslogtreecommitdiffstats
path: root/packet-nlm.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2004-02-25 09:31:07 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2004-02-25 09:31:07 +0000
commit72640317de9493fbe6501ce35bce5a290d71f109 (patch)
tree4e9d5900443b375741a9966dee096dee52c01a1c /packet-nlm.c
parent965bdb9528126d44b30daed2f340f031748068e9 (diff)
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. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@10236 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-nlm.c')
-rw-r--r--packet-nlm.c7
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);