tvbuff.[ch]: Accept more size_t's.
packet-wcp.c: Add size_t casts. packet-x11.c: Use string buffers. svn path=/trunk/; revision=27959
This commit is contained in:
parent
526cf5d50d
commit
098eb5606f
|
@ -272,7 +272,7 @@ dissect_wcp_reset( tvbuff_t *tvb, int offset, proto_tree *tree){
|
|||
static void wcp_save_data( tvbuff_t *tvb, packet_info *pinfo){
|
||||
|
||||
wcp_window_t *buf_ptr = 0;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
/* discard first 2 bytes, header and last byte (check byte) */
|
||||
len = tvb_reported_length( tvb)-3;
|
||||
|
@ -285,7 +285,7 @@ static void wcp_save_data( tvbuff_t *tvb, packet_info *pinfo){
|
|||
} else {
|
||||
guint8 *buf_end = buf_ptr->buffer + MAX_WIN_BUF_LEN;
|
||||
tvb_memcpy( tvb, buf_ptr->buf_cur, 2, buf_end - buf_ptr->buf_cur);
|
||||
tvb_memcpy( tvb, buf_ptr->buffer, buf_end - buf_ptr->buf_cur-2,
|
||||
tvb_memcpy( tvb, buf_ptr->buffer, (gint) (buf_end - buf_ptr->buf_cur-2),
|
||||
len - (buf_end - buf_ptr->buf_cur));
|
||||
buf_ptr->buf_cur = buf_ptr->buf_cur + len - MAX_WIN_BUF_LEN;
|
||||
}
|
||||
|
|
|
@ -1339,43 +1339,31 @@ static void colorFlags(tvbuff_t *tvb, int *offsetp, proto_tree *t)
|
|||
|
||||
if (do_red_green_blue) {
|
||||
int sep = FALSE;
|
||||
char *buffer, *bp;
|
||||
|
||||
buffer=ep_alloc(512);
|
||||
|
||||
bp = buffer + MIN(512, g_snprintf(buffer, 512, "flags: "));
|
||||
emem_strbuf_t *buffer = ep_strbuf_new_label("flags: ");
|
||||
|
||||
if (do_red_green_blue & 0x1) {
|
||||
bp += MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), "DoRed"));
|
||||
ep_strbuf_append(buffer, "DoRed");
|
||||
sep = TRUE;
|
||||
}
|
||||
|
||||
if (do_red_green_blue & 0x2) {
|
||||
if (sep) bp += MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), " | "));
|
||||
bp += MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), "DoGreen"));
|
||||
if (sep) ep_strbuf_append(buffer, " | ");
|
||||
ep_strbuf_append(buffer, "DoGreen");
|
||||
sep = TRUE;
|
||||
}
|
||||
|
||||
if (do_red_green_blue & 0x4) {
|
||||
if (sep) bp += MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), " | "));
|
||||
bp += MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), "DoBlue"));
|
||||
if (sep) ep_strbuf_append(buffer, " | ");
|
||||
ep_strbuf_append(buffer, "DoBlue");
|
||||
sep = TRUE;
|
||||
}
|
||||
|
||||
if (do_red_green_blue & 0xf8) {
|
||||
if (sep) bp += MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), " + "));
|
||||
MIN(512-(bp-buffer),
|
||||
g_snprintf(bp, 512-(bp-buffer), "trash"));
|
||||
if (sep) ep_strbuf_append(buffer, " + trash");
|
||||
}
|
||||
|
||||
ti = proto_tree_add_uint_format(t, hf_x11_coloritem_flags, tvb, *offsetp, 1, do_red_green_blue,
|
||||
"%s", buffer);
|
||||
"%s", buffer->str);
|
||||
tt = proto_item_add_subtree(ti, ett_x11_color_flags);
|
||||
if (do_red_green_blue & 0x1)
|
||||
proto_tree_add_boolean(tt, hf_x11_coloritem_flags_do_red, tvb, *offsetp, 1,
|
||||
|
@ -1480,33 +1468,28 @@ static void listOfColorItem(tvbuff_t *tvb, int *offsetp, proto_tree *t, int hf,
|
|||
proto_tree *ttt;
|
||||
unsigned do_red_green_blue;
|
||||
guint16 red, green, blue;
|
||||
char *buffer;
|
||||
char *bp;
|
||||
emem_strbuf_t *buffer;
|
||||
const char *sep;
|
||||
|
||||
buffer=ep_alloc(1024);
|
||||
buffer=ep_strbuf_new_label("colorItem ");
|
||||
red = VALUE16(tvb, *offsetp + 4);
|
||||
green = VALUE16(tvb, *offsetp + 6);
|
||||
blue = VALUE16(tvb, *offsetp + 8);
|
||||
do_red_green_blue = VALUE8(tvb, *offsetp + 10);
|
||||
|
||||
bp = buffer + MIN(1024, g_snprintf(buffer, 1024, "colorItem: "));
|
||||
sep = "";
|
||||
if (do_red_green_blue & 0x1) {
|
||||
bp += MIN(1024-(bp-buffer),
|
||||
g_snprintf(bp, 1024-(bp-buffer), "red = %d", red));
|
||||
ep_strbuf_append_printf(buffer, "red = %d", red);
|
||||
sep = ", ";
|
||||
}
|
||||
if (do_red_green_blue & 0x2) {
|
||||
bp += MIN(1024-(bp-buffer),
|
||||
g_snprintf(bp, 1024-(bp-buffer), "%sgreen = %d", sep, green));
|
||||
ep_strbuf_append_printf(buffer, "%sgreen = %d", sep, green);
|
||||
sep = ", ";
|
||||
}
|
||||
if (do_red_green_blue & 0x4)
|
||||
bp += MIN(1024-(bp-buffer),
|
||||
g_snprintf(bp, 1024-(bp-buffer), "%sblue = %d", sep, blue));
|
||||
ep_strbuf_append_printf(buffer, "%sblue = %d", sep, blue);
|
||||
|
||||
tti = proto_tree_add_none_format(tt, hf_x11_coloritem, tvb, *offsetp, 12, "%s", buffer);
|
||||
tti = proto_tree_add_none_format(tt, hf_x11_coloritem, tvb, *offsetp, 12, "%s", buffer->str);
|
||||
ttt = proto_item_add_subtree(tti, ett_x11_color_item);
|
||||
proto_tree_add_item(ttt, hf_x11_coloritem_pixel, tvb, *offsetp, 4, little_endian);
|
||||
*offsetp += 4;
|
||||
|
|
|
@ -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, guint length, gint reported_length)
|
||||
tvb_set_real_data(tvbuff_t* tvb, const guint8* data, size_t length, size_t 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, guint length, gint reported
|
|||
}
|
||||
|
||||
tvb->real_data = data;
|
||||
tvb->length = length;
|
||||
tvb->reported_length = reported_length;
|
||||
tvb->length = (guint) length;
|
||||
tvb->reported_length = (guint) reported_length;
|
||||
tvb->initialized = TRUE;
|
||||
}
|
||||
|
||||
tvbuff_t*
|
||||
tvb_new_real_data(const guint8* data, guint length, gint reported_length)
|
||||
tvb_new_real_data(const guint8* data, size_t length, size_t reported_length)
|
||||
{
|
||||
static tvbuff_t *last_tvb=NULL;
|
||||
tvbuff_t *tvb;
|
||||
|
@ -300,7 +300,7 @@ tvb_new_real_data(const guint8* data, guint length, gint reported_length)
|
|||
}
|
||||
|
||||
tvbuff_t*
|
||||
tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, guint length, gint reported_length)
|
||||
tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, size_t length, size_t 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, guint length, gint
|
|||
* 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, gint length,
|
||||
compute_offset_length(tvbuff_t *tvb, gint offset, size_t 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, gint length,
|
|||
*length_ptr = tvb->length - *offset_ptr;
|
||||
}
|
||||
else {
|
||||
*length_ptr = length;
|
||||
*length_ptr = (guint) length;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -388,7 +388,7 @@ compute_offset_length(tvbuff_t *tvb, gint offset, gint length,
|
|||
|
||||
|
||||
static gboolean
|
||||
check_offset_length_no_exception(tvbuff_t *tvb, gint offset, gint length,
|
||||
check_offset_length_no_exception(tvbuff_t *tvb, gint offset, size_t 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, gint 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, gint length,
|
||||
check_offset_length(tvbuff_t *tvb, gint offset, size_t length,
|
||||
guint *offset_ptr, guint *length_ptr)
|
||||
{
|
||||
int exception = 0;
|
||||
|
@ -457,7 +457,7 @@ check_offset_length(tvbuff_t *tvb, gint offset, gint length,
|
|||
|
||||
void
|
||||
tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing,
|
||||
gint backing_offset, gint backing_length, gint reported_length)
|
||||
gint backing_offset, size_t backing_length, size_t 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 = reported_length;
|
||||
tvb->reported_length = (guint) 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, gint backing_length, gint reported_length)
|
||||
tvb_new_subset(tvbuff_t *backing, gint backing_offset, size_t backing_length, size_t 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, gint length)
|
||||
tvb_bytes_exist(tvbuff_t *tvb, gint offset, size_t length)
|
||||
{
|
||||
guint abs_offset, abs_length;
|
||||
|
||||
|
@ -658,7 +658,7 @@ tvb_bytes_exist(tvbuff_t *tvb, gint offset, gint 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, gint length)
|
||||
tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, size_t length)
|
||||
{
|
||||
guint abs_offset, abs_length;
|
||||
|
||||
|
@ -2120,14 +2120,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, gint length)
|
||||
tvb_get_string(tvbuff_t *tvb, gint offset, size_t length)
|
||||
{
|
||||
const guint8 *ptr;
|
||||
guint8 *strbuf = NULL;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
ptr = ensure_contiguous(tvb, offset, (gint) length);
|
||||
strbuf = g_malloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
|
@ -2150,14 +2150,14 @@ tvb_get_string(tvbuff_t *tvb, gint offset, gint length)
|
|||
* after the current packet has been dissected.
|
||||
*/
|
||||
guint8 *
|
||||
tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, gint length)
|
||||
tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, size_t length)
|
||||
{
|
||||
const guint8 *ptr;
|
||||
guint8 *strbuf = NULL;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
ptr = ensure_contiguous(tvb, offset, (gint) length);
|
||||
strbuf = ep_alloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
|
@ -2179,14 +2179,14 @@ tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, gint length)
|
|||
* when wireshark starts or opens a new capture.
|
||||
*/
|
||||
guint8 *
|
||||
tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, gint length)
|
||||
tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, size_t length)
|
||||
{
|
||||
const guint8 *ptr;
|
||||
guint8 *strbuf = NULL;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
ptr = ensure_contiguous(tvb, offset, (gint) 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, guint length,
|
||||
gint reported_length);
|
||||
extern tvbuff_t* tvb_new_child_real_data(tvbuff_t* parent, const guint8* data, size_t length,
|
||||
size_t reported_length);
|
||||
|
||||
/**Sets parameters for TVBUFF_REAL_DATA. Can throw ReportedBoundsError. */
|
||||
extern void tvb_set_real_data(tvbuff_t*, const guint8* data, guint length,
|
||||
gint reported_length);
|
||||
extern void tvb_set_real_data(tvbuff_t*, const guint8* data, size_t length,
|
||||
size_t reported_length);
|
||||
|
||||
/** Combination of tvb_new() and tvb_set_real_data(). Can throw ReportedBoundsError. */
|
||||
extern tvbuff_t* tvb_new_real_data(const guint8* data, guint length,
|
||||
gint reported_length);
|
||||
extern tvbuff_t* tvb_new_real_data(const guint8* data, size_t length,
|
||||
size_t 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, guint 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, gint backing_length, gint reported_length);
|
||||
gint backing_offset, size_t backing_length, size_t 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, gint backing_length, gint reported_length);
|
||||
gint backing_offset, size_t backing_length, size_t 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, gint length);
|
||||
extern gboolean tvb_bytes_exist(tvbuff_t*, gint offset, size_t 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, gint length);
|
||||
extern void tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, size_t 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, 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);
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue