aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-08-20 13:02:08 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-08-20 13:02:08 +0000
commite6dd3c8b2231ce9318ef22b44e8330034a832ba2 (patch)
tree781b57c32b03eaae5d81d0ed4ec1bce05deeea12 /epan
parentb55266d3c04910979e6c860284a850b84a89fee7 (diff)
more sprintf updates
svn path=/trunk/; revision=15469
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-diameter.c32
-rw-r--r--epan/dissectors/packet-fcdns.c14
-rw-r--r--epan/dissectors/packet-icep.c4
-rw-r--r--epan/dissectors/packet-ieee80211.c6
4 files changed, 32 insertions, 24 deletions
diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c
index 5e83b1fbde..60ab8a9a0a 100644
--- a/epan/dissectors/packet-diameter.c
+++ b/epan/dissectors/packet-diameter.c
@@ -54,6 +54,7 @@
#include <epan/report_err.h>
#include <epan/prefs.h>
#include <epan/sminmpec.h>
+#include <epan/emem.h>
#include "packet-tcp.h"
#include "packet-sip.h"
@@ -908,7 +909,7 @@ initializeDictionary(void)
static gchar *
diameter_vendor_to_str(guint32 vendorId, gboolean longName) {
VendorId *probe;
- static gchar buffer[64];
+ gchar *buffer;
for (probe=vendorListHead; probe; probe=probe->next) {
if (vendorId == probe->id) {
@@ -919,8 +920,8 @@ diameter_vendor_to_str(guint32 vendorId, gboolean longName) {
}
}
- g_snprintf(buffer, sizeof(buffer),
- "Vendor 0x%08x", vendorId);
+ buffer=ep_alloc(64);
+ g_snprintf(buffer, 64, "Vendor 0x%08x", vendorId);
return buffer;
} /*diameter_vendor_to_str */
@@ -929,7 +930,7 @@ static gchar *
diameter_command_to_str(guint32 commandCode, guint32 vendorId)
{
CommandCode *probe;
- static gchar buffer[64];
+ gchar *buffer=NULL;
gchar *vendorName=NULL;
switch(gbl_version) {
@@ -961,7 +962,8 @@ diameter_command_to_str(guint32 commandCode, guint32 vendorId)
if ( suppress_console_output == FALSE )
g_warning("Diameter: Unable to find name for command code 0x%08x, Vendor \"%u\"!",
commandCode, vendorId);
- g_snprintf(buffer, sizeof(buffer),
+ buffer=ep_alloc(64);
+ g_snprintf(buffer, 64,
"Cmd-0x%08x", commandCode);
break;
case DIAMETER_RFC:
@@ -976,7 +978,8 @@ diameter_command_to_str(guint32 commandCode, guint32 vendorId)
if ( suppress_console_output == FALSE )
g_warning("Diameter: Unable to find name for command code 0x%08x!",
commandCode);
- g_snprintf(buffer, sizeof(buffer),
+ buffer=ep_alloc(64);
+ g_snprintf(buffer, 64,
"Cmd-0x%08x", commandCode);
break;
}
@@ -987,7 +990,7 @@ diameter_command_to_str(guint32 commandCode, guint32 vendorId)
static gchar *
diameter_app_to_str(guint32 appId) {
ApplicationId *probe;
- static gchar buffer[64];
+ gchar *buffer;
for (probe=ApplicationIdHead; probe; probe=probe->next) {
if (appId == probe->id) {
@@ -995,7 +998,8 @@ diameter_app_to_str(guint32 appId) {
}
}
- g_snprintf(buffer, sizeof(buffer), "Unknown");
+ buffer=ep_alloc(64);
+ g_snprintf(buffer, 64, "Unknown");
return buffer;
} /*diameter_app_to_str */
@@ -1039,7 +1043,7 @@ diameter_avp_get_type(guint32 avpCode, guint32 vendorId){
static gchar *
diameter_avp_get_name(guint32 avpCode, guint32 vendorId)
{
- static gchar buffer[64];
+ gchar *buffer;
avpInfo *probe;
gchar *vendorName=NULL;
@@ -1069,7 +1073,8 @@ diameter_avp_get_name(guint32 avpCode, guint32 vendorId)
avpCode, vendorId);
/* If we don't find it, build a name string */
- g_snprintf(buffer, sizeof(buffer), "Unknown AVP:0x%08x", avpCode);
+ buffer=ep_alloc(64);
+ g_snprintf(buffer, 64, "Unknown AVP:0x%08x", avpCode);
return buffer;
} /* diameter_avp_get_name */
static const gchar *
@@ -1521,7 +1526,7 @@ static void dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree
proto_tree *group_tree;
proto_item *grouptf;
proto_item *avptf;
- char buffer[1024];
+ char *buffer;
int BadPacket = FALSE;
guint32 avpLength;
guint8 flags;
@@ -1707,7 +1712,8 @@ static void dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree
switch(avpType) {
case DIAMETER_GROUPED:
- sprintf(buffer, "%s Grouped AVPs", avpNameString);
+ buffer=ep_alloc(256);
+ g_snprintf(buffer, 256, "%s Grouped AVPs", avpNameString);
/* Recursively call ourselves */
grouptf = proto_tree_add_text(avpi_tree,
tvb, offset, tvb_length(tvb),
@@ -1841,7 +1847,6 @@ static void dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree
case DIAMETER_TIME:
if (avpDataLength == 4) {
nstime_t data;
- gchar buffer[64];
struct tm *gmtp;
data.secs = tvb_get_ntohl(tvb, offset);
@@ -1851,6 +1856,7 @@ static void dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree
data.nsecs = 0;
gmtp = gmtime(&data.secs);
+ buffer=ep_alloc(64);
strftime(buffer, 64,
"%a, %d %b %Y %H:%M:%S UTC", gmtp);
diff --git a/epan/dissectors/packet-fcdns.c b/epan/dissectors/packet-fcdns.c
index 89ea6901fa..bcb02dedd6 100644
--- a/epan/dissectors/packet-fcdns.c
+++ b/epan/dissectors/packet-fcdns.c
@@ -211,7 +211,7 @@ fccos_to_str (tvbuff_t *tvb, int offset, gchar *cosstr)
/* The feature routines just decode FCP's FC-4 features field */
static gchar *
-fc4feature_to_str (guint8 fc4feature, guint8 fc4type, gchar *str)
+fc4feature_to_str (guint8 fc4feature, guint8 fc4type, gchar *str, int len)
{
int stroff = 0;
@@ -228,7 +228,7 @@ fc4feature_to_str (guint8 fc4feature, guint8 fc4type, gchar *str)
}
}
else {
- sprintf (str, "0x%x", fc4feature);
+ g_snprintf (str, len, "0x%x", fc4feature);
}
return (str);
}
@@ -875,8 +875,9 @@ dissect_fcdns_gidff (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq)
{
int offset = 16; /* past the fc_ct header */
guint8 islast;
- gchar str[64];
+ gchar *str;
+ str=ep_alloc(64);
if (req_tree) {
if (isreq) {
proto_tree_add_item (req_tree, hf_fcdns_req_domainscope, tvb,
@@ -887,7 +888,7 @@ dissect_fcdns_gidff (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq)
offset+6, 1,
fc4feature_to_str (tvb_get_guint8 (tvb, offset+6),
tvb_get_guint8 (tvb, offset+7),
- str));
+ str, 64));
proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, tvb,
offset+7, 1, 0);
}
@@ -1061,8 +1062,9 @@ static void
dissect_fcdns_rffid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq)
{
int offset = 16; /* past the fc_ct header */
- gchar fc4str[64];
+ gchar *fc4str;
+ fc4str=ep_alloc(64);
if (req_tree && isreq) {
proto_tree_add_string (req_tree, hf_fcdns_req_portid, tvb, offset+1, 3,
fc_to_str (tvb_get_ptr (tvb, offset+1, 3)));
@@ -1072,7 +1074,7 @@ dissect_fcdns_rffid (tvbuff_t *tvb, proto_tree *req_tree, gboolean isreq)
offset+6),
tvb_get_guint8 (tvb,
offset+7),
- fc4str));
+ fc4str, 64));
proto_tree_add_item (req_tree, hf_fcdns_req_fc4type, tvb, offset+7,
1, 0);
}
diff --git a/epan/dissectors/packet-icep.c b/epan/dissectors/packet-icep.c
index 9e1f13709e..92b0f14f9f 100644
--- a/epan/dissectors/packet-icep.c
+++ b/epan/dissectors/packet-icep.c
@@ -451,9 +451,7 @@ static void dissect_ice_context(proto_tree *tree, tvbuff_t *tvb, guint32 offset,
}
if (Size == 0) {
- s = ep_alloc( strlen("(empty)") + 1 );
- sprintf(s, "(empty)");
- s[strlen("(empty)")] = '\0';
+ s = "(empty)";
/* display the 0x00 Size byte when click on a empty context */
if (tree)
proto_tree_add_string(tree, hf_icep_context, tvb, offset - 1, 1, s);
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index 5d1e257e2b..1d7d1cdcb6 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -69,6 +69,7 @@
#include "etypes.h"
#include <epan/crc32.h>
#include <epan/tap.h>
+#include <epan/emem.h>
#include <ctype.h>
#include "isprint.h"
@@ -3978,7 +3979,7 @@ static void init_wepkeys(void) {
gboolean res;
#ifdef USE_ENV
- guint8 buf[128];
+ guint8 *buf;
tmp = getenv("ETHEREAL_WEPKEYNUM");
if (!tmp) {
@@ -4009,7 +4010,8 @@ static void init_wepkeys(void) {
wep_keylens[i] = 0;
#ifdef USE_ENV
- sprintf(buf, "ETHEREAL_WEPKEY%d", i+1);
+ buf=ep_alloc(128);
+ sprintf(buf, 128, "ETHEREAL_WEPKEY%d", i+1);
tmp = getenv(buf);
#else
tmp = wep_keystr[i];