replace a whole bunch of silly rotating stating buffers with ep_alloc() calls

this should fix a whole number of display bugs when there are too many such pdus in a single frame for the silly buffers to handle before they wrap.



svn path=/trunk/; revision=15384
This commit is contained in:
Ronnie Sahlberg 2005-08-17 09:25:04 +00:00
parent 1df55c8071
commit 4c1b32d94d
5 changed files with 18 additions and 66 deletions

View File

@ -32,6 +32,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/emem.h>
#include "etypes.h"
static int proto_aarp = -1;
@ -105,17 +106,9 @@ static const value_string hrd_vals[] = {
static gchar *
atalkid_to_str(const guint8 *ad) {
gint node;
static gchar str[3][16];
static gchar *cur;
if (cur == &str[0][0]) {
cur = &str[1][0];
} else if (cur == &str[1][0]) {
cur = &str[2][0];
} else {
cur = &str[0][0];
}
gchar *cur;
cur=ep_alloc(16);
node=ad[1]<<8|ad[2];
sprintf(cur, "%d.%d",node,ad[3]);
return cur;

View File

@ -32,6 +32,7 @@
#include <epan/strutil.h>
#include <epan/arptypes.h>
#include <epan/addr_resolv.h>
#include <epan/emem.h>
#include "packet-arp.h"
#include "etypes.h"
#include "arcnet_pids.h"
@ -165,15 +166,12 @@ arpproaddr_to_str(const guint8 *ad, int ad_len, guint16 type)
return bytes_to_str(ad, ad_len);
}
#define N_ATMARPNUM_TO_STR_STRINGS 2
#define MAX_E164_STR_LEN 20
static const gchar *
atmarpnum_to_str(const guint8 *ad, int ad_tl)
{
int ad_len = ad_tl & ATMARP_LEN_MASK;
static gchar str[N_ATMARPNUM_TO_STR_STRINGS][MAX_E164_STR_LEN+3+1];
static int cur_idx;
gchar *cur;
if (ad_len == 0)
@ -183,10 +181,7 @@ atmarpnum_to_str(const guint8 *ad, int ad_tl)
/*
* I'm assuming this means it's an ASCII (IA5) string.
*/
cur_idx++;
if (cur_idx >= N_ATMARPNUM_TO_STR_STRINGS)
cur_idx = 0;
cur = &str[cur_idx][0];
cur = ep_alloc(MAX_E164_STR_LEN+3+1);
if (ad_len > MAX_E164_STR_LEN) {
/* Can't show it all. */
memcpy(cur, ad, MAX_E164_STR_LEN);

View File

@ -34,6 +34,7 @@
#include <epan/prefs.h>
#include <epan/packet.h>
#include <epan/reassemble.h>
#include <epan/emem.h>
#include "packet-osi.h"
#include "packet-osi-options.h"
#include "packet-isis.h"
@ -408,20 +409,11 @@ static gboolean is_all_printable(const guchar *stringtocheck, int length)
static gchar *print_tsap(const guchar *tsap, int length)
{
static gchar str[3][MAX_TSAP_LEN * 2 + 3]; /* TSAP in hex + '0x' + NULL */
static gchar *cur;
gchar *cur;
gchar tmp[3];
gboolean allprintable;
if (cur == &str[0][0]) {
cur = &str[1][0];
} else if (cur == &str[1][0]) {
cur = &str[2][0];
} else {
cur = &str[0][0];
}
cur=ep_alloc(MAX_TSAP_LEN * 2 + 3);
cur[0] = '\0';
if (length <= 0 || length > MAX_TSAP_LEN)
sprintf(cur, "<unsupported TSAP length>");

View File

@ -34,6 +34,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/emem.h>
#include "packet-smb-common.h"
/*
@ -142,21 +143,14 @@ static gchar *
unicode_to_str(tvbuff_t *tvb, int offset, int *us_lenp, gboolean exactlen,
guint16 bc)
{
static gchar str[3][MAX_UNICODE_STR_LEN+3+1];
static gchar *cur;
gchar *cur;
gchar *p;
guint16 uchar;
int len;
int us_len;
gboolean overflow = FALSE;
if (cur == &str[0][0]) {
cur = &str[1][0];
} else if (cur == &str[1][0]) {
cur = &str[2][0];
} else {
cur = &str[0][0];
}
cur=ep_alloc(MAX_UNICODE_STR_LEN+3+1);
p = cur;
len = MAX_UNICODE_STR_LEN;
us_len = 0;
@ -212,8 +206,7 @@ get_unicode_or_ascii_string(tvbuff_t *tvb, int *offsetp,
gboolean useunicode, int *len, gboolean nopad, gboolean exactlen,
guint16 *bcp)
{
static gchar str[3][MAX_UNICODE_STR_LEN+3+1];
static gchar *cur;
gchar *cur;
const gchar *string;
int string_len;
int copylen;
@ -247,13 +240,7 @@ get_unicode_or_ascii_string(tvbuff_t *tvb, int *offsetp,
/*
* The string we return must be null-terminated.
*/
if (cur == &str[0][0]) {
cur = &str[1][0];
} else if (cur == &str[1][0]) {
cur = &str[2][0];
} else {
cur = &str[0][0];
}
cur=ep_alloc(MAX_UNICODE_STR_LEN+3+1);
copylen = *len;
if (copylen < 0) {
/* This probably means it's a very large unsigned number; just set

View File

@ -31,6 +31,7 @@
#include <glib.h>
#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/emem.h>
#include "packet-wccp.h"
static int proto_wccp = -1;
@ -377,17 +378,9 @@ wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree, guint32 start,
static gchar *
bucket_name(guint8 bucket)
{
static gchar str[4][10+1];
static gchar *cur;
gchar *cur;
if (cur == &str[0][0])
cur = &str[1][0];
else if (cur == &str[1][0])
cur = &str[2][0];
else if (cur == &str[2][0])
cur = &str[3][0];
else
cur = &str[0][0];
cur=ep_alloc(10+1);
if (bucket == 0xff)
strcpy(cur, "Unassigned");
else
@ -968,17 +961,9 @@ dissect_wccp2_router_assignment_element(tvbuff_t *tvb, int offset,
static gchar *
assignment_bucket_name(guint8 bucket)
{
static gchar str[4][10+1];
static gchar *cur;
gchar *cur;
if (cur == &str[0][0])
cur = &str[1][0];
else if (cur == &str[1][0])
cur = &str[2][0];
else if (cur == &str[2][0])
cur = &str[3][0];
else
cur = &str[0][0];
cur=ep_alloc(10+1);
if (bucket == 0xff)
strcpy(cur, "Unassigned");
else {