aboutsummaryrefslogtreecommitdiffstats
path: root/packet-giop.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-05-13 01:24:47 +0000
committerGuy Harris <guy@alum.mit.edu>2002-05-13 01:24:47 +0000
commitb6e941027ff5b41a55bf23ce43d23e8ea5d49efc (patch)
tree3becaf90450ff578c7dc8dbcd051987b3ee15ba4 /packet-giop.c
parentef67bf2d2f260b3e58cfb19ba550b517fb1196c0 (diff)
Add a "tvb_ensure_bytes_exist()", which is like "tvb_bytes_exist()" only
it throws the appropriate exception if the bytes don't exist. Use it in the GIOP and ASN.1 code to check whether the bytes to be copied to a buffer exist before allocating the buffer. Make "check_offset_length_no_exception()" check for an overflow, so that it can be used in "tvb_ensure_bytes_exist()" and do all the checking that the code "tvb_ensure_bytes_exist()" replaces did. Make "get_CDR_wchar()" return a "gint", so that if the length octet it fetched has a value between 128 and 255, the length can be returned correctly. Fix some comments not to specify the exception thrown by various routines that can throw various exceptions. svn path=/trunk/; revision=5453
Diffstat (limited to 'packet-giop.c')
-rw-r--r--packet-giop.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/packet-giop.c b/packet-giop.c
index 8a8e12e3cb..09959b6853 100644
--- a/packet-giop.c
+++ b/packet-giop.c
@@ -9,7 +9,7 @@
* Frank Singleton <frank.singleton@ericsson.com>
* Trevor Shepherd <eustrsd@am1.ericsson.se>
*
- * $Id: packet-giop.c,v 1.60 2002/05/12 20:43:29 gerald Exp $
+ * $Id: packet-giop.c,v 1.61 2002/05/13 01:24:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -2327,17 +2327,15 @@ guint8 get_CDR_octet(tvbuff_t *tvb, int *offset) {
void get_CDR_octet_seq(tvbuff_t *tvb, gchar **seq, int *offset, guint32 len) {
- guint32 remain_len = tvb_length_remaining(tvb, *offset);
-
- if (remain_len < len) {
- /*
- * Generate an exception, and stop processing.
- * We do that now, rather than after allocating the buffer, so we
- * don't have to worry about freeing the buffer.
- * XXX - would we be better off using a cleanup routine?
- */
- tvb_ensure_length_remaining(tvb, *offset + remain_len + 1);
- }
+ /*
+ * Make sure that the entire sequence of octets is in the buffer before
+ * allocating the buffer, so that we don't have to worry about freeing
+ * the buffer, and so that we don't try to allocate a buffer bigger
+ * than the data we'll actually be copying, and thus don't run the risk
+ * of crashing if the buffer is *so* big that we fail to allocate it
+ * and "g_new0()" aborts.
+ */
+ tvb_ensure_bytes_exist(tvb, *offset, len);
/*
* XXX - should we just allocate "len" bytes, and have "get_CDR_string()"
@@ -2639,9 +2637,9 @@ guint16 get_CDR_ushort(tvbuff_t *tvb, int *offset, gboolean stream_is_big_endian
* Wchar is not supported for GIOP 1.0.
*/
-gint8 get_CDR_wchar(tvbuff_t *tvb, gchar **seq, int *offset, MessageHeader * header) {
+gint get_CDR_wchar(tvbuff_t *tvb, gchar **seq, int *offset, MessageHeader * header) {
- guint32 slength;
+ gint slength;
gchar *raw_wstring;
/* CORBA chapter 15: