summaryrefslogtreecommitdiff
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2013-08-01 16:54:22 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2013-08-01 16:54:22 +0000
commit10e40c163873816cf4afa8fd3ac10975498f21eb (patch)
tree943a9cbcf10649111c16eca7a89477eaa59f66a4 /epan/tvbuff.c
parent565211c938c7f852e337c86aa0a63794d36bef56 (diff)
downloadwireshark-10e40c163873816cf4afa8fd3ac10975498f21eb.tar.gz
tvb: check_offset_length() can calculate remaining length, use it.
svn path=/trunk/; revision=51081
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 0e029fdc73..3a54ae68b5 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -1510,16 +1510,15 @@ gint
tvb_find_guint8(tvbuff_t *tvb, const gint offset, const gint maxlength, const guint8 needle)
{
const guint8 *result;
- guint abs_offset, junk_length;
+ guint abs_offset;
guint tvbufflen;
guint limit;
DISSECTOR_ASSERT(tvb && tvb->initialized);
- check_offset_length(tvb, offset, 0, &abs_offset, &junk_length);
+ check_offset_length(tvb, offset, -1, &abs_offset, &tvbufflen);
/* Only search to end of tvbuff, w/o throwing exception. */
- tvbufflen = tvb_length_remaining(tvb, abs_offset);
if (maxlength == -1) {
/* No maximum length specified; search to end of tvbuff. */
limit = tvbufflen;
@@ -1566,16 +1565,15 @@ gint
tvb_pbrk_guint8(tvbuff_t *tvb, const gint offset, const gint maxlength, const guint8 *needles, guchar *found_needle)
{
const guint8 *result;
- guint abs_offset, junk_length;
+ guint abs_offset;
guint tvbufflen;
guint limit;
DISSECTOR_ASSERT(tvb && tvb->initialized);
- check_offset_length(tvb, offset, 0, &abs_offset, &junk_length);
+ check_offset_length(tvb, offset, -1, &abs_offset, &tvbufflen);
/* Only search to end of tvbuff, w/o throwing exception. */
- tvbufflen = tvb_length_remaining(tvb, abs_offset);
if (maxlength == -1) {
/* No maximum length specified; search to end of tvbuff. */
limit = tvbufflen;
@@ -2396,11 +2394,12 @@ static gint
_tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer, gint *bytes_copied)
{
gint stringlen;
- guint abs_offset, junk_length;
+ guint abs_offset;
gint limit, len;
gboolean decreased_max = FALSE;
- check_offset_length(tvb, offset, 0, &abs_offset, &junk_length);
+ /* Only read to end of tvbuff, w/o throwing exception. */
+ check_offset_length(tvb, offset, -1, &abs_offset, &len);
/* There must at least be room for the terminating NUL. */
DISSECTOR_ASSERT(bufsize != 0);
@@ -2412,9 +2411,6 @@ _tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8*
return 0;
}
- /* Only read to end of tvbuff, w/o throwing exception. */
- len = tvb_length_remaining(tvb, abs_offset);
-
/* check_offset_length() won't throw an exception if we're
* looking at the byte immediately after the end of the tvbuff. */
if (len == 0) {