void
tvb_set_free_cb(tvbuff_t* tvb, tvbuff_free_cb_t func)
{
+ DISSECTOR_ASSERT(tvb);
DISSECTOR_ASSERT(tvb->type == TVBUFF_REAL_DATA);
tvb->free_cb = func;
}
void
tvb_set_child_real_data_tvbuff(tvbuff_t* parent, tvbuff_t* child)
{
+ DISSECTOR_ASSERT(parent && child);
DISSECTOR_ASSERT(parent->initialized);
DISSECTOR_ASSERT(child->initialized);
DISSECTOR_ASSERT(child->type == TVBUFF_REAL_DATA);
void
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);
DISSECTOR_ASSERT(!tvb->initialized);
{
guint end_offset;
- DISSECTOR_ASSERT(tvb);
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (!compute_offset_length(tvb, offset, length, offset_ptr, length_ptr, exception)) {
return FALSE;
tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing,
gint backing_offset, gint backing_length, gint reported_length)
{
+ DISSECTOR_ASSERT(tvb);
DISSECTOR_ASSERT(tvb->type == TVBUFF_SUBSET);
DISSECTOR_ASSERT(!tvb->initialized);
{
tvb_comp_t *composite;
- DISSECTOR_ASSERT(!tvb->initialized);
+ DISSECTOR_ASSERT(tvb && !tvb->initialized);
composite = &tvb->tvbuffs.composite;
composite->tvbs = g_slist_append( composite->tvbs, member );
add_to_used_in_list(member, tvb);
{
tvb_comp_t *composite;
- DISSECTOR_ASSERT(!tvb->initialized);
+ DISSECTOR_ASSERT(tvb && !tvb->initialized);
composite = &tvb->tvbuffs.composite;
composite->tvbs = g_slist_prepend( composite->tvbs, member );
add_to_used_in_list(member, tvb);
tvb_comp_t *composite;
int i = 0;
- DISSECTOR_ASSERT(!tvb->initialized);
+ DISSECTOR_ASSERT(tvb && !tvb->initialized);
DISSECTOR_ASSERT(tvb->length == 0);
composite = &tvb->tvbuffs.composite;
guint
tvb_length(tvbuff_t* tvb)
{
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
return tvb->length;
}
{
guint abs_offset, abs_length;
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, NULL)) {
return abs_length;
guint abs_offset, abs_length;
int exception;
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (!compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, &exception)) {
THROW(exception);
{
guint abs_offset, abs_length;
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (!compute_offset_length(tvb, offset, length, &abs_offset, &abs_length, NULL))
return FALSE;
{
guint abs_offset, abs_length;
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
/*
* -1 doesn't mean "until end of buffer", as that's pointless
{
guint abs_offset, abs_length;
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (!compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, NULL))
return FALSE;
guint
tvb_reported_length(tvbuff_t* tvb)
{
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
return tvb->reported_length;
}
{
guint abs_offset, abs_length;
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, NULL)) {
if (tvb->reported_length >= abs_offset)
void
tvb_set_reported_length(tvbuff_t* tvb, guint reported_length)
{
- DISSECTOR_ASSERT(tvb->initialized);
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
if (reported_length > tvb->reported_length)
THROW(ReportedBoundsError);
{
guint abs_offset, abs_length;
guint8 *duped;
-
+
check_offset_length(tvb, offset, length, &abs_offset, &abs_length);
-
+
duped = g_malloc(abs_length);
return tvb_memcpy(tvb, duped, abs_offset, abs_length);
}
* "composite_ensure_contiguous_no_exception()" depends on -1 not being
* an error; does anything else depend on this routine treating -1 as
* meaning "to the end of the buffer"?
- *
+ *
* This function allocates memory from a buffer with packet lifetime.
* You do not have to free this buffer, it will be automatically freed
* when wireshark starts decoding the next packet.
{
guint abs_offset, abs_length;
guint8 *duped;
-
+
check_offset_length(tvb, offset, length, &abs_offset, &abs_length);
-
+
duped = ep_alloc(abs_length);
return tvb_memcpy(tvb, duped, abs_offset, abs_length);
}
}
/* Convert a string from Unicode to ASCII. At the moment we fake it by
- * replacing all non-ASCII characters with a '.' )-: The len parameter is
+ * replacing all non-ASCII characters with a '.' )-: The len parameter is
* the number of guint16's to convert from Unicode.
*
* This function allocates memory from a buffer with packet lifetime.
tvbuff_t *
tvb_uncompress(tvbuff_t *tvb, int offset, int comprlen)
{
-
+
gint err = Z_OK;
guint bytes_out = 0;
return NULL;
}
- /*
+ /*
* Assume that the uncompressed data is at least twice as big as
* the compressed size.
*/
if (uncompr != NULL) {
g_free(uncompr);
}
-
+
return NULL;
}
-
+
g_memmove(new_data, uncompr, bytes_out);
g_memmove((new_data + bytes_out), strmbuf,
bytes_pass);
g_free(compr);
return NULL;
}
-
+
} else if (err == Z_DATA_ERROR && inits_done == 1
&& uncompr == NULL && (*compr == 0x1f) &&
(*(compr + 1) == 0x8b)) {
if (flags & (1 << 4)) {
/* A null terminated comment */
-
+
while (*c != '\0') {
c++;
}
return NULL;
}
comprlen -= (c - compr);
-
+
inflateEnd(strm);
err = inflateInit2(strm, wbits);
inits_done++;
} else if (err == Z_DATA_ERROR && uncompr == NULL &&
inits_done <= 3) {
-
- /*
+
+ /*
* Re-init the stream with a negative
* MAX_WBITS. This is necessary due to
* some servers (Apache) not sending
strm->avail_out = bufsiz;
err = inflateInit2(strm, wbits);
-
+
inits_done++;
-
+
if (err != Z_OK) {
g_free(strm);
g_free(strmbuf);
printf("inflate() total passes: %u\n", inflate_passes);
printf("bytes in: %u\nbytes out: %u\n\n", bytes_in, bytes_out);
#endif
-
+
if (uncompr != NULL) {
uncompr_tvb = tvb_new_real_data((guint8*) uncompr, bytes_out,
bytes_out);