Ethereal-dev: Re: [ethereal-dev] Re: [ethereal-users] Ethereal crash reading tcpdump '-r' file
On Wed, Sep 13, 2000 at 01:06:29PM -0700, Marc Solsona Palomar wrote:
> Thanks. As far as I know our platform is BSD based but not exactly
> standard FreeBSD. There may be an issue there.
>
> marc.
>
Here's a diff against the current CVS, and it might actually apply
cleanly against your 0.8.10, to guard against ethereal blowing up on
the file. The capture file is indeed very different than what ethereal
expects.
--gilbert
? tvbtest
Index: packet.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet.c,v
retrieving revision 1.107
diff -u -r1.107 packet.c
--- packet.c 2000/09/12 08:38:44 1.107
+++ packet.c 2000/09/13 20:16:29
@@ -998,7 +998,7 @@
proto_tree *fh_tree;
proto_item *ti;
struct timeval tv;
- tvbuff_t *tvb;
+ static tvbuff_t *tvb;
/* Put in frame header information. */
if (tree) {
@@ -1040,14 +1040,16 @@
pi.len = fd->pkt_len;
pi.captured_len = fd->cap_len;
- tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
pi.fd = fd;
- pi.compat_top_tvb = tvb;
pi.pseudo_header = pseudo_header;
+ pi.current_proto = "Frame";
col_set_writable(fd, TRUE);
TRY {
+ tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
+ pi.compat_top_tvb = tvb;
+
switch (fd->lnk_t) {
case WTAP_ENCAP_ETHERNET :
dissect_eth(tvb, &pi, tree);
Index: tvbuff.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/tvbuff.c,v
retrieving revision 1.15
diff -u -r1.15 tvbuff.c
--- tvbuff.c 2000/09/11 20:05:13 1.15
+++ tvbuff.c 2000/09/13 20:16:30
@@ -278,8 +278,11 @@
{
g_assert(tvb->type == TVBUFF_REAL_DATA);
g_assert(!tvb->initialized);
- g_assert(reported_length >= -1);
+ if (reported_length < -1) {
+ THROW(ReportedBoundsError);
+ }
+
tvb->real_data = (gpointer) data;
tvb->length = length;
tvb->reported_length = reported_length;
@@ -292,8 +295,13 @@
tvbuff_t *tvb;
tvb = tvb_new(TVBUFF_REAL_DATA);
+
+ CLEANUP_PUSH(tvb_free, tvb);
+
tvb_set_real_data(tvb, data, length, reported_length);
+ CLEANUP_POP;
+
return tvb;
}
@@ -426,6 +434,10 @@
g_assert(tvb->type == TVBUFF_SUBSET);
g_assert(!tvb->initialized);
+ if (reported_length < -1) {
+ THROW(ReportedBoundsError);
+ }
+
check_offset_length(backing, backing_offset, backing_length,
&tvb->tvbuffs.subset.offset,
&tvb->tvbuffs.subset.length);
@@ -433,7 +445,7 @@
tvb_increment_usage_count(backing, 1);
tvb->tvbuffs.subset.tvb = backing;
tvb->length = tvb->tvbuffs.subset.length;
- g_assert(reported_length >= -1);
+
if (reported_length == -1) {
tvb->reported_length = backing->reported_length - tvb->tvbuffs.subset.offset;
}
@@ -457,7 +469,12 @@
tvbuff_t *tvb;
tvb = tvb_new(TVBUFF_SUBSET);
+
+ CLEANUP_PUSH(tvb_free, tvb);
+
tvb_set_subset(tvb, backing, backing_offset, backing_length, reported_length);
+
+ CLEANUP_POP;
return tvb;
}
Index: tvbuff.h
===================================================================
RCS file: /usr/local/cvsroot/ethereal/tvbuff.h,v
retrieving revision 1.11
diff -u -r1.11 tvbuff.h
--- tvbuff.h 2000/09/08 06:16:58 1.11
+++ tvbuff.h 2000/09/13 20:16:30
@@ -124,10 +124,10 @@
void tvb_set_free_cb(tvbuff_t*, tvbuff_free_cb_t);
-/* Sets parameters for TVBUFF_REAL_DATA */
+/* Sets parameters for TVBUFF_REAL_DATA. Can throw ReportedBoundsError. */
void tvb_set_real_data(tvbuff_t*, const guint8* data, guint length, gint reported_length);
-/* Combination of tvb_new() and tvb_set_real_data() */
+/* Combination of tvb_new() and tvb_set_real_data(). Can throw ReportedBoundsError. */
tvbuff_t* tvb_new_real_data(const guint8* data, guint length, gint reported_length);
@@ -142,11 +142,13 @@
* 'backing_length' of -1 means "to the end of the backing buffer"
*
* Will throw BoundsError if 'backing_offset'/'length'
- * is beyond the bounds of the backing tvbuff. */
+ * is beyond the bounds of the backing tvbuff.
+ * Can throw ReportedBoundsError. */
void tvb_set_subset(tvbuff_t* tvb, tvbuff_t* backing,
gint backing_offset, gint backing_length, gint reported_length);
-/* Combination of tvb_new() and tvb_set_subset() */
+/* Combination of tvb_new() and tvb_set_subset()
+ * Can throw ReportedBoundsError. */
tvbuff_t* tvb_new_subset(tvbuff_t* backing,
gint backing_offset, gint backing_length, gint reported_length);