From a2251afaffd032b164031b0e3da422f525838cf0 Mon Sep 17 00:00:00 2001 From: Gilbert Ramirez Date: Fri, 4 Jan 2002 06:45:14 +0000 Subject: [PATCH] Throw a BoundsError if a length parameter in a tvbuff-accessor is < -1. svn path=/trunk/; revision=4474 --- epan/tvbuff.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 549a6c90aa..d24643e243 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.26 2001/11/20 22:46:12 guy Exp $ + * $Id: tvbuff.c,v 1.27 2002/01/04 06:45:14 gram Exp $ * * Copyright (c) 2000 by Gilbert Ramirez * @@ -407,8 +407,10 @@ compute_offset_length(tvbuff_t *tvb, gint offset, gint length, } /* Compute the length */ - g_assert(length >= -1); - if (length == -1) { + if (length < -1) { + return FALSE; + } + else if (length == -1) { *length_ptr = tvb->length - *offset_ptr; } else { @@ -457,6 +459,10 @@ check_offset_length(tvbuff_t *tvb, gint offset, gint length, { int exception = 0; + if (length < -1) { + THROW(BoundsError); + } + if (!check_offset_length_no_exception(tvb, offset, length, offset_ptr, length_ptr, &exception)) { g_assert(exception > 0); THROW(exception);