diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-06-09 07:27:42 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-06-09 07:27:42 +0000 |
commit | 7d8effcbb326cff0de49ae958940e99e3a185e26 (patch) | |
tree | 8552ed4195b99e5e6dfa8074cb8857a567f10131 /epan/tvbuff.c | |
parent | e231ffbd00548fcdaf319d174cc1d85256ad8ccc (diff) |
Fix "tvb_strneql()", "tvb_strncaseeql()", and "tvb_memeql()" not to
throw an exception if there aren't enough bytes in the tvbuff to
compare.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@7813 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 443287342a..ec66db45d7 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.45 2003/06/04 21:45:49 guy Exp $ + * $Id: tvbuff.c,v 1.46 2003/06/09 07:27:42 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -844,11 +844,15 @@ composite_ensure_contiguous(tvbuff_t *tvb, guint abs_offset, guint abs_length) } static guint8* -ensure_contiguous(tvbuff_t *tvb, gint offset, gint length) +ensure_contiguous_no_exception(tvbuff_t *tvb, gint offset, gint length, + int *exception) { guint abs_offset, abs_length; - check_offset_length(tvb, offset, length, &abs_offset, &abs_length); + if (!check_offset_length_no_exception(tvb, offset, length, + &abs_offset, &abs_length, exception)) { + return NULL; + } if (tvb->real_data) { return tvb->real_data + abs_offset; @@ -870,6 +874,20 @@ ensure_contiguous(tvbuff_t *tvb, gint offset, gint length) return NULL; } +static guint8* +ensure_contiguous(tvbuff_t *tvb, gint offset, gint length) +{ + int exception; + guint8 *p; + + p = ensure_contiguous_no_exception(tvb, offset, length, &exception); + if (p == NULL) { + g_assert(exception > 0); + THROW(exception); + } + return p; +} + static const guint8* guint8_find(const guint8* haystack, size_t haystacklen, guint8 needle) { @@ -1545,7 +1563,7 @@ tvb_strneql(tvbuff_t *tvb, gint offset, const guint8 *str, gint size) { guint8 *ptr; - ptr = ensure_contiguous(tvb, offset, size); + ptr = ensure_contiguous_no_exception(tvb, offset, size, NULL); if (ptr) { int cmp = strncmp(ptr, str, size); @@ -1572,7 +1590,7 @@ tvb_strncaseeql(tvbuff_t *tvb, gint offset, const guint8 *str, gint size) { guint8 *ptr; - ptr = ensure_contiguous(tvb, offset, size); + ptr = ensure_contiguous_no_exception(tvb, offset, size, NULL); if (ptr) { int cmp = strncasecmp(ptr, str, size); @@ -1599,7 +1617,7 @@ tvb_memeql(tvbuff_t *tvb, gint offset, const guint8 *str, gint size) { guint8 *ptr; - ptr = ensure_contiguous(tvb, offset, size); + ptr = ensure_contiguous_no_exception(tvb, offset, size, NULL); if (ptr) { int cmp = memcmp(ptr, str, size); |