diff options
-rw-r--r-- | epan/dfilter/syntax-tree.c | 4 | ||||
-rw-r--r-- | epan/ftypes/ftypes.c | 6 | ||||
-rw-r--r-- | epan/proto.c | 10 | ||||
-rw-r--r-- | epan/resolv.c | 4 | ||||
-rw-r--r-- | epan/tvbuff.c | 35 | ||||
-rw-r--r-- | epan/tvbuff.h | 6 |
6 files changed, 34 insertions, 31 deletions
diff --git a/epan/dfilter/syntax-tree.c b/epan/dfilter/syntax-tree.c index dafe440cc9..77136dcdce 100644 --- a/epan/dfilter/syntax-tree.c +++ b/epan/dfilter/syntax-tree.c @@ -1,5 +1,5 @@ /* - * $Id: syntax-tree.c,v 1.3 2001/02/27 19:23:28 gram Exp $ + * $Id: syntax-tree.c,v 1.4 2001/10/26 17:29:11 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -66,7 +66,6 @@ sttype_register(sttype_t *type) type_id = type->id; /* Check input */ - g_assert(type_id >= 0); g_assert(type_id < STTYPE_NUM_TYPES); /* Don't re-register. */ @@ -81,7 +80,6 @@ sttype_lookup(sttype_id_t type_id) sttype_t *result; /* Check input */ - g_assert(type_id >= 0); g_assert(type_id < STTYPE_NUM_TYPES); result = type_list[type_id]; diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c index d39ba6e03d..fab6d58a91 100644 --- a/epan/ftypes/ftypes.c +++ b/epan/ftypes/ftypes.c @@ -1,5 +1,5 @@ /* - * $Id: ftypes.c,v 1.4 2001/03/02 17:04:25 gram Exp $ + * $Id: ftypes.c,v 1.5 2001/10/26 17:29:12 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -80,7 +80,6 @@ void ftype_register(enum ftenum ftype, ftype_t *ft) { /* Check input */ - g_assert(ftype >= 0); g_assert(ftype < FT_NUM_TYPES); /* Don't re-register. */ @@ -96,7 +95,6 @@ ftype_lookup(enum ftenum ftype) ftype_t* result; /* Check input */ - g_assert(ftype >= 0); g_assert(ftype < FT_NUM_TYPES); result = type_list[ftype]; @@ -351,7 +349,7 @@ slice_func(gpointer data, gpointer user_data) /* g_debug("(NEW) start_offset=%d length=%d end_offset=%d", start_offset, length, end_offset); */ - if (start_offset > field_length || end_offset > field_length) { + if (start_offset > (int) field_length || end_offset > (int) field_length) { slice_data->slice_failure = TRUE; return; } diff --git a/epan/proto.c b/epan/proto.c index 95dbc8c6aa..ffb84a50b6 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.36 2001/10/23 05:40:36 guy Exp $ + * $Id: proto.c,v 1.37 2001/10/26 17:29:09 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -286,7 +286,7 @@ proto_tree_free_node(GNode *node, gpointer data) header_field_info* proto_registrar_get_nth(int hfindex) { - g_assert(hfindex >= 0 && hfindex < gpa_hfinfo->len); + g_assert(hfindex >= 0 && (guint) hfindex < gpa_hfinfo->len); return g_ptr_array_index(gpa_hfinfo, hfindex); } @@ -1468,7 +1468,7 @@ alloc_field_info(int hfindex, tvbuff_t *tvb, gint start, gint length) fi = g_mem_chunk_alloc(gmc_field_info); - g_assert(hfindex >= 0 && hfindex < gpa_hfinfo->len); + g_assert(hfindex >= 0 && (guint) hfindex < gpa_hfinfo->len); fi->hfinfo = proto_registrar_get_nth(hfindex); g_assert(fi->hfinfo != NULL); fi->start = start; @@ -2683,8 +2683,8 @@ check_for_offset(GNode *node, gpointer data) /* !fi == the top most container node which holds nothing */ if (fi && fi->visible && !strcmp( offsearch->name,fi->ds_name)) { - if (offsearch->offset >= fi->start && - offsearch->offset < (fi->start + fi->length)) { + if (offsearch->offset >= (guint) fi->start && + offsearch->offset < (guint) (fi->start + fi->length)) { offsearch->finfo = fi; return FALSE; /* keep traversing */ diff --git a/epan/resolv.c b/epan/resolv.c index 287e45bfe3..947853a9bd 100644 --- a/epan/resolv.c +++ b/epan/resolv.c @@ -1,7 +1,7 @@ /* resolv.c * Routines for network object lookup * - * $Id: resolv.c,v 1.16 2001/10/24 07:18:37 guy Exp $ + * $Id: resolv.c,v 1.17 2001/10/26 17:29:09 gram Exp $ * * Laurent Deniel <deniel@worldnet.fr> * @@ -1381,7 +1381,7 @@ gboolean get_host_ipaddr(const char *host, guint32 *addrp) return FALSE; /* Apparently, some versions of gethostbyaddr can * return IPv6 addresses. */ - } else if (hp->h_length <= sizeof (struct in_addr)) { + } else if (hp->h_length <= (int) sizeof (struct in_addr)) { memcpy(&ipaddr, hp->h_addr, hp->h_length); } else { return FALSE; diff --git a/epan/tvbuff.c b/epan/tvbuff.c index f98358271a..095c2c5862 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.c,v 1.18 2001/07/02 07:11:40 guy Exp $ + * $Id: tvbuff.c,v 1.19 2001/10/26 17:29:09 gram Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org> * @@ -360,13 +360,13 @@ compute_offset_length(tvbuff_t *tvb, gint offset, gint length, /* Compute the offset */ if (offset >= 0) { /* Positive offset - relative to the beginning of the packet. */ - if (offset > tvb->reported_length) { + if ((guint) offset > tvb->reported_length) { if (exception) { *exception = ReportedBoundsError; } return FALSE; } - else if (offset > tvb->length) { + else if ((guint) offset > tvb->length) { if (exception) { *exception = BoundsError; } @@ -378,13 +378,13 @@ compute_offset_length(tvbuff_t *tvb, gint offset, gint length, } else { /* Negative offset - relative to the end of the packet. */ - if (-offset > tvb->reported_length) { + if ((guint) -offset > tvb->reported_length) { if (exception) { *exception = ReportedBoundsError; } return FALSE; } - else if (-offset > tvb->length) { + else if ((guint) -offset > tvb->length) { if (exception) { *exception = BoundsError; } @@ -553,7 +553,7 @@ tvb_composite_finalize(tvbuff_t* tvb) composite->end_offsets = g_new(guint, num_members); for (slist = composite->tvbs; slist != NULL; slist = slist->next) { - g_assert(i < num_members); + g_assert((guint) i < num_members); member_tvb = slist->data; composite->start_offsets[i] = tvb->length; tvb->length += member_tvb->length; @@ -805,7 +805,7 @@ guint8_find(const guint8* haystack, size_t haystacklen, guint8 needle) const guint8 *b; int i; - for (b = haystack, i = 0; i < haystacklen; i++, b++) { + for (b = haystack, i = 0; (guint) i < haystacklen; i++, b++) { if (*b == needle) { return b; } @@ -821,7 +821,7 @@ guint8_pbrk(const guint8* haystack, size_t haystacklen, guint8 *needles) int i; guint8 item, *needlep, needle; - for (b = haystack, i = 0; i < haystacklen; i++, b++) { + for (b = haystack, i = 0; (guint) i < haystacklen; i++, b++) { item = *b; needlep = needles; while ((needle = *needlep) != '\0') { @@ -1040,7 +1040,7 @@ tvb_get_letohll(tvbuff_t *tvb, gint offset) * in that case, -1 will be returned if the boundary is reached before * finding needle. */ gint -tvb_find_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 needle) +tvb_find_guint8(tvbuff_t *tvb, gint offset, gint maxlength, guint8 needle) { const guint8 *result; guint abs_offset, junk_length; @@ -1055,7 +1055,7 @@ tvb_find_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 needle) /* No maximum length specified; search to end of tvbuff. */ limit = tvbufflen; } - else if (tvbufflen < maxlength) { + else if (tvbufflen < (guint) maxlength) { /* Maximum length goes past end of tvbuff; search to end of tvbuff. */ limit = tvbufflen; @@ -1103,7 +1103,7 @@ tvb_find_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 needle) * in that case, -1 will be returned if the boundary is reached before * finding needle. */ gint -tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 *needles) +tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, gint maxlength, guint8 *needles) { const guint8 *result; guint abs_offset, junk_length; @@ -1118,7 +1118,7 @@ tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, guint maxlength, guint8 *needles) /* No maximum length specified; search to end of tvbuff. */ limit = tvbufflen; } - else if (tvbufflen < maxlength) { + else if (tvbufflen < (guint) maxlength) { /* Maximum length goes past end of tvbuff; search to end of tvbuff. */ limit = tvbufflen; @@ -1330,7 +1330,7 @@ tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint maxlength, guint8* buffer) { gint stringlen; guint abs_offset, junk_length; - gint limit; + gint limit, len; check_offset_length(tvb, offset, 0, &abs_offset, &junk_length); @@ -1340,7 +1340,14 @@ tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint maxlength, guint8* buffer) } /* Only copy to end of tvbuff, w/o throwing exception. */ - if (tvb_length_remaining(tvb, abs_offset) < maxlength) { + len = tvb_length_remaining(tvb, abs_offset); + + /* This should not happen because check_offset_length() would + * have already thrown an exception if 'offset' were out-of-bounds. + */ + g_assert(len != -1); + + if ((guint)len < maxlength) { limit = maxlength - (tvb_length(tvb) - abs_offset); } else { diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 794c998a7f..00e713e572 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.h,v 1.14 2001/07/02 07:11:40 guy Exp $ + * $Id: tvbuff.h,v 1.15 2001/10/26 17:29:09 gram Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@xiexie.org> * @@ -277,14 +277,14 @@ const guint8* tvb_get_ptr(tvbuff_t*, gint offset, gint length); * Will not throw an exception, even if maxlength exceeds boundary of tvbuff; * in that case, -1 will be returned if the boundary is reached before * finding needle. */ -gint tvb_find_guint8(tvbuff_t*, gint offset, guint maxlength, guint8 needle); +gint tvb_find_guint8(tvbuff_t*, gint offset, gint maxlength, guint8 needle); /* Find first occurence of any of the needles in tvbuff, starting at offset. * Searches at most maxlength number of bytes. Returns the offset of the * found needle, or -1 if not found. Will not throw an exception, even if * maxlength exceeds boundary of tvbuff; in that case, -1 will be returned if * the boundary is reached before finding needle. */ -gint tvb_pbrk_guint8(tvbuff_t *, gint offset, guint maxlength, guint8 *needles); +gint tvb_pbrk_guint8(tvbuff_t *, gint offset, gint maxlength, guint8 *needles); /* Find size of stringz (NUL-terminated string) by looking for terminating * NUL. The size of the string includes the terminating NUL. |