Back out the previous change. As Guy pointed out, we might not want to
be so size_t-happy. svn path=/trunk/; revision=27962
This commit is contained in:
parent
98ee238eea
commit
17ae564af8
|
@ -253,7 +253,7 @@ tvb_set_child_real_data_tvbuff(tvbuff_t* parent, tvbuff_t* child)
|
|||
}
|
||||
|
||||
void
|
||||
tvb_set_real_data(tvbuff_t* tvb, const guint8* data, size_t length, size_t reported_length)
|
||||
tvb_set_real_data(tvbuff_t* tvb, const guint8* data, guint length, gint reported_length)
|
||||
{
|
||||
DISSECTOR_ASSERT(tvb);
|
||||
DISSECTOR_ASSERT(tvb->type == TVBUFF_REAL_DATA);
|
||||
|
@ -264,13 +264,13 @@ tvb_set_real_data(tvbuff_t* tvb, const guint8* data, size_t length, size_t repor
|
|||
}
|
||||
|
||||
tvb->real_data = data;
|
||||
tvb->length = (guint) length;
|
||||
tvb->reported_length = (guint) reported_length;
|
||||
tvb->length = length;
|
||||
tvb->reported_length = reported_length;
|
||||
tvb->initialized = TRUE;
|
||||
}
|
||||
|
||||
tvbuff_t*
|
||||
tvb_new_real_data(const guint8* data, size_t length, size_t reported_length)
|
||||
tvb_new_real_data(const guint8* data, guint length, gint reported_length)
|
||||
{
|
||||
static tvbuff_t *last_tvb=NULL;
|
||||
tvbuff_t *tvb;
|
||||
|
@ -300,7 +300,7 @@ tvb_new_real_data(const guint8* data, size_t length, size_t reported_length)
|
|||
}
|
||||
|
||||
tvbuff_t*
|
||||
tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, size_t length, size_t reported_length)
|
||||
tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, guint length, gint reported_length)
|
||||
{
|
||||
tvbuff_t *tvb = tvb_new_real_data(data, length, reported_length);
|
||||
if (tvb) {
|
||||
|
@ -324,7 +324,7 @@ tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, size_t length, siz
|
|||
* that gets an exception, so the error is reported as an error in that
|
||||
* protocol rather than the containing protocol. */
|
||||
static gboolean
|
||||
compute_offset_length(tvbuff_t *tvb, gint offset, size_t length,
|
||||
compute_offset_length(tvbuff_t *tvb, gint offset, gint length,
|
||||
guint *offset_ptr, guint *length_ptr, int *exception)
|
||||
{
|
||||
DISSECTOR_ASSERT(offset_ptr);
|
||||
|
@ -380,7 +380,7 @@ compute_offset_length(tvbuff_t *tvb, gint offset, size_t length,
|
|||
*length_ptr = tvb->length - *offset_ptr;
|
||||
}
|
||||
else {
|
||||
*length_ptr = (guint) length;
|
||||
*length_ptr = length;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -388,7 +388,7 @@ compute_offset_length(tvbuff_t *tvb, gint offset, size_t length,
|
|||
|
||||
|
||||
static gboolean
|
||||
check_offset_length_no_exception(tvbuff_t *tvb, gint offset, size_t length,
|
||||
check_offset_length_no_exception(tvbuff_t *tvb, gint offset, gint length,
|
||||
guint *offset_ptr, guint *length_ptr, int *exception)
|
||||
{
|
||||
guint end_offset;
|
||||
|
@ -442,7 +442,7 @@ check_offset_length_no_exception(tvbuff_t *tvb, gint offset, size_t length,
|
|||
* either is out of bounds. Sets integer ptrs to the new offset
|
||||
* and length. */
|
||||
static void
|
||||
check_offset_length(tvbuff_t *tvb, gint offset, size_t length,
|
||||
check_offset_length(tvbuff_t *tvb, gint offset, gint length,
|
||||
guint *offset_ptr, guint *length_ptr)
|
||||
{
|
||||
int exception = 0;
|
||||
|
@ -457,7 +457,7 @@ check_offset_length(tvbuff_t *tvb, gint offset, size_t length,
|
|||
|
||||
void
|
||||
tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing,
|
||||
gint backing_offset, size_t backing_length, size_t reported_length)
|
||||
gint backing_offset, gint backing_length, gint reported_length)
|
||||
{
|
||||
DISSECTOR_ASSERT(tvb);
|
||||
DISSECTOR_ASSERT(tvb->type == TVBUFF_SUBSET);
|
||||
|
@ -478,7 +478,7 @@ tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing,
|
|||
tvb->reported_length = backing->reported_length - tvb->tvbuffs.subset.offset;
|
||||
}
|
||||
else {
|
||||
tvb->reported_length = (guint) reported_length;
|
||||
tvb->reported_length = reported_length;
|
||||
}
|
||||
tvb->initialized = TRUE;
|
||||
add_to_used_in_list(backing, tvb);
|
||||
|
@ -492,7 +492,7 @@ tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing,
|
|||
|
||||
|
||||
tvbuff_t*
|
||||
tvb_new_subset(tvbuff_t *backing, gint backing_offset, size_t backing_length, size_t reported_length)
|
||||
tvb_new_subset(tvbuff_t *backing, gint backing_offset, gint backing_length, gint reported_length)
|
||||
{
|
||||
static tvbuff_t *last_tvb=NULL;
|
||||
tvbuff_t *tvb;
|
||||
|
@ -638,7 +638,7 @@ tvb_ensure_length_remaining(tvbuff_t *tvb, gint offset)
|
|||
/* Validates that 'length' bytes are available starting from
|
||||
* offset (pos/neg). Does not throw an exception. */
|
||||
gboolean
|
||||
tvb_bytes_exist(tvbuff_t *tvb, gint offset, size_t length)
|
||||
tvb_bytes_exist(tvbuff_t *tvb, gint offset, gint length)
|
||||
{
|
||||
guint abs_offset, abs_length;
|
||||
|
||||
|
@ -658,7 +658,7 @@ tvb_bytes_exist(tvbuff_t *tvb, gint offset, size_t length)
|
|||
/* Validates that 'length' bytes are available starting from
|
||||
* offset (pos/neg). Throws an exception if they aren't. */
|
||||
void
|
||||
tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, size_t length)
|
||||
tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, gint length)
|
||||
{
|
||||
guint abs_offset, abs_length;
|
||||
|
||||
|
@ -1011,18 +1011,7 @@ tvb_memcpy(tvbuff_t *tvb, void* target, gint offset, size_t length)
|
|||
{
|
||||
guint abs_offset, abs_length;
|
||||
|
||||
/*
|
||||
* XXX - we should eliminate the "length = -1 means 'to the end
|
||||
* of the tvbuff'" convention, and use other means to achieve
|
||||
* that; this would let us eliminate a bunch of checks for
|
||||
* negative lengths in cases where the protocol has a 32-bit
|
||||
* length field.
|
||||
*
|
||||
* Allowing -1 but throwing an assertion on other negative
|
||||
* lengths is a bit more work with the length being a size_t;
|
||||
* instead, we check for a length <= 2^31-1.
|
||||
*/
|
||||
DISSECTOR_ASSERT(length <= 0x7FFFFFFF);
|
||||
DISSECTOR_ASSERT(length >= -1);
|
||||
check_offset_length(tvb, offset, (gint) length, &abs_offset, &abs_length);
|
||||
|
||||
if (tvb->real_data) {
|
||||
|
@ -2120,14 +2109,14 @@ tvb_format_stringzpad(tvbuff_t *tvb, gint offset, gint size)
|
|||
* Throws an exception if the tvbuff ends before the string does.
|
||||
*/
|
||||
guint8 *
|
||||
tvb_get_string(tvbuff_t *tvb, gint offset, size_t length)
|
||||
tvb_get_string(tvbuff_t *tvb, gint offset, gint length)
|
||||
{
|
||||
const guint8 *ptr;
|
||||
guint8 *strbuf = NULL;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, (gint) length);
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
strbuf = g_malloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
|
@ -2150,14 +2139,14 @@ tvb_get_string(tvbuff_t *tvb, gint offset, size_t length)
|
|||
* after the current packet has been dissected.
|
||||
*/
|
||||
guint8 *
|
||||
tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, size_t length)
|
||||
tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, gint length)
|
||||
{
|
||||
const guint8 *ptr;
|
||||
guint8 *strbuf = NULL;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, (gint) length);
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
strbuf = ep_alloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
|
@ -2179,14 +2168,14 @@ tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, size_t length)
|
|||
* when wireshark starts or opens a new capture.
|
||||
*/
|
||||
guint8 *
|
||||
tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, size_t length)
|
||||
tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, gint length)
|
||||
{
|
||||
const guint8 *ptr;
|
||||
guint8 *strbuf = NULL;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, (gint) length);
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
strbuf = se_alloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
|
|
|
@ -208,16 +208,16 @@ extern void tvb_set_free_cb(tvbuff_t*, tvbuff_free_cb_t);
|
|||
* the tvbuff routines knowledgable of this fact. */
|
||||
extern void tvb_set_child_real_data_tvbuff(tvbuff_t* parent, tvbuff_t* child);
|
||||
|
||||
extern tvbuff_t* tvb_new_child_real_data(tvbuff_t* parent, const guint8* data, size_t length,
|
||||
size_t reported_length);
|
||||
extern tvbuff_t* tvb_new_child_real_data(tvbuff_t* parent, const guint8* data, guint length,
|
||||
gint reported_length);
|
||||
|
||||
/**Sets parameters for TVBUFF_REAL_DATA. Can throw ReportedBoundsError. */
|
||||
extern void tvb_set_real_data(tvbuff_t*, const guint8* data, size_t length,
|
||||
size_t reported_length);
|
||||
extern void tvb_set_real_data(tvbuff_t*, const guint8* data, guint length,
|
||||
gint reported_length);
|
||||
|
||||
/** Combination of tvb_new() and tvb_set_real_data(). Can throw ReportedBoundsError. */
|
||||
extern tvbuff_t* tvb_new_real_data(const guint8* data, size_t length,
|
||||
size_t reported_length);
|
||||
extern tvbuff_t* tvb_new_real_data(const guint8* data, guint length,
|
||||
gint reported_length);
|
||||
|
||||
|
||||
/** Define the subset of the backing buffer to use.
|
||||
|
@ -234,12 +234,12 @@ extern tvbuff_t* tvb_new_real_data(const guint8* data, size_t length,
|
|||
* is beyond the bounds of the backing tvbuff.
|
||||
* Can throw ReportedBoundsError. */
|
||||
extern void tvb_set_subset(tvbuff_t* tvb, tvbuff_t* backing,
|
||||
gint backing_offset, size_t backing_length, size_t reported_length);
|
||||
gint backing_offset, gint backing_length, gint reported_length);
|
||||
|
||||
/** Combination of tvb_new() and tvb_set_subset()
|
||||
* Can throw ReportedBoundsError. */
|
||||
extern tvbuff_t* tvb_new_subset(tvbuff_t* backing,
|
||||
gint backing_offset, size_t backing_length, size_t reported_length);
|
||||
gint backing_offset, gint backing_length, gint reported_length);
|
||||
|
||||
|
||||
/** Both tvb_composite_append and tvb_composite_prepend can throw
|
||||
|
@ -274,11 +274,11 @@ extern guint tvb_ensure_length_remaining(tvbuff_t*, gint offset);
|
|||
|
||||
/* Checks (w/o throwing exception) that the bytes referred to by
|
||||
* 'offset'/'length' actually exist in the buffer */
|
||||
extern gboolean tvb_bytes_exist(tvbuff_t*, gint offset, size_t length);
|
||||
extern gboolean tvb_bytes_exist(tvbuff_t*, gint offset, gint length);
|
||||
|
||||
/** Checks that the bytes referred to by 'offset'/'length' actually exist
|
||||
* in the buffer, and throws an exception if they aren't. */
|
||||
extern void tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, size_t length);
|
||||
extern void tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, gint length);
|
||||
|
||||
/* Checks (w/o throwing exception) that offset exists in buffer */
|
||||
extern gboolean tvb_offset_exists(tvbuff_t*, gint offset);
|
||||
|
@ -468,9 +468,9 @@ extern gchar *tvb_format_stringzpad(tvbuff_t *tvb, gint offset, gint size);
|
|||
* instead it will automatically be freed when a new capture
|
||||
* or file is opened.
|
||||
*/
|
||||
extern guint8 *tvb_get_string(tvbuff_t *tvb, gint offset, size_t length);
|
||||
extern guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, size_t length);
|
||||
extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, size_t length);
|
||||
extern guint8 *tvb_get_string(tvbuff_t *tvb, gint offset, gint length);
|
||||
extern guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, gint length);
|
||||
extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, gint length);
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue