diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-08-20 01:24:23 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2005-08-20 01:24:23 +0000 |
commit | aff31978c18fad2dd6cf2a3f66d9c6c0cc405366 (patch) | |
tree | ffcf19cf2701b36bba09728ac17118784f5c9170 | |
parent | ce65efd3019eced34bdbedb07132651b21cb1239 (diff) |
remove sprintf from mtp3
svn path=/trunk/; revision=15451
-rw-r--r-- | epan/dissectors/packet-mtp3.c | 37 | ||||
-rw-r--r-- | epan/dissectors/packet-mtp3.h | 4 | ||||
-rw-r--r-- | epan/to_str.c | 2 | ||||
-rw-r--r-- | gtk/mtp3_stat.c | 8 |
4 files changed, 28 insertions, 23 deletions
diff --git a/epan/dissectors/packet-mtp3.c b/epan/dissectors/packet-mtp3.c index 6a5d55f26d..b5bfaa1168 100644 --- a/epan/dissectors/packet-mtp3.c +++ b/epan/dissectors/packet-mtp3.c @@ -42,6 +42,7 @@ #include <epan/packet.h> #include <epan/tap.h> #include <epan/prefs.h> +#include <epan/emem.h> /* Initialize the protocol and registered fields */ static int proto_mtp3 = -1; @@ -190,22 +191,22 @@ static dissector_handle_t data_handle; */ void -mtp3_pc_to_str_buf(const guint32 pc, gchar *buf) +mtp3_pc_to_str_buf(const guint32 pc, gchar *buf, int buf_len) { switch (mtp3_standard) { case ITU_STANDARD: switch (itu_pc_structure) { case ITU_PC_STRUCTURE_NONE: - sprintf(buf, "%u", pc); + g_snprintf(buf, buf_len, "%u", pc); break; case ITU_PC_STRUCTURE_3_8_3: /* this format is used in international ITU networks */ - sprintf(buf, "%u-%u-%u", (pc & 0x3800)>>11, (pc & 0x7f8) >> 3, (pc & 0x07) >> 0); + g_snprintf(buf, buf_len, "%u-%u-%u", (pc & 0x3800)>>11, (pc & 0x7f8) >> 3, (pc & 0x07) >> 0); break; case ITU_PC_STRUCTURE_4_3_4_3: /* this format is used in some national ITU networks, the German one for example. */ - sprintf(buf, "%u-%u-%u-%u", (pc & 0x3c00) >>10, (pc & 0x0380) >> 7, (pc & 0x0078) >> 3, (pc & 0x0007) >> 0); + g_snprintf(buf, buf_len, "%u-%u-%u-%u", (pc & 0x3c00) >>10, (pc & 0x0380) >> 7, (pc & 0x0078) >> 3, (pc & 0x0007) >> 0); break; default: DISSECTOR_ASSERT_NOT_REACHED(); @@ -213,7 +214,7 @@ mtp3_pc_to_str_buf(const guint32 pc, gchar *buf) break; case ANSI_STANDARD: case CHINESE_ITU_STANDARD: - sprintf(buf, "%u-%u-%u", (pc & ANSI_NETWORK_MASK), (pc & ANSI_CLUSTER_MASK) >> 8, (pc & ANSI_MEMBER_MASK) >> 16); + g_snprintf(buf, buf_len, "%u-%u-%u", (pc & ANSI_NETWORK_MASK), (pc & ANSI_CLUSTER_MASK) >> 8, (pc & ANSI_MEMBER_MASK) >> 16); break; default: DISSECTOR_ASSERT_NOT_REACHED(); @@ -225,9 +226,10 @@ mtp3_pc_to_str_buf(const guint32 pc, gchar *buf) gchar * mtp3_pc_to_str(const guint32 pc) { - static gchar str[MAX_STRUCTURED_PC_LENGTH]; + gchar *str; - mtp3_pc_to_str_buf(pc, str); + str=ep_alloc(MAX_STRUCTURED_PC_LENGTH); + mtp3_pc_to_str_buf(pc, str, MAX_STRUCTURED_PC_LENGTH); return str; } @@ -247,7 +249,8 @@ mtp3_pc_structured(void) void mtp3_addr_to_str_buf( const guint8 *data, - gchar *buf) + gchar *buf, + int buf_len) { const mtp3_addr_pc_t *addr_pc_p = (const mtp3_addr_pc_t *)data; @@ -257,11 +260,11 @@ mtp3_addr_to_str_buf( switch (addr_pc_p->type) { case ITU_STANDARD: - sprintf(buf, "%u", addr_pc_p->pc & ITU_PC_MASK); + g_snprintf(buf, buf_len, "%u", addr_pc_p->pc & ITU_PC_MASK); break; default: /* assuming 24-bit */ - sprintf(buf, "%u", addr_pc_p->pc & ANSI_PC_MASK); + g_snprintf(buf, buf_len, "%u", addr_pc_p->pc & ANSI_PC_MASK); break; } break; @@ -270,11 +273,11 @@ mtp3_addr_to_str_buf( switch (addr_pc_p->type) { case ITU_STANDARD: - sprintf(buf, "%x", addr_pc_p->pc & ITU_PC_MASK); + g_snprintf(buf, buf_len, "%x", addr_pc_p->pc & ITU_PC_MASK); break; default: /* assuming 24-bit */ - sprintf(buf, "%x", addr_pc_p->pc & ANSI_PC_MASK); + g_snprintf(buf, buf_len, "%x", addr_pc_p->pc & ANSI_PC_MASK); break; } break; @@ -283,11 +286,11 @@ mtp3_addr_to_str_buf( switch (addr_pc_p->type) { case ITU_STANDARD: - sprintf(buf, "%u:%u", addr_pc_p->ni, addr_pc_p->pc & ITU_PC_MASK); + g_snprintf(buf, buf_len, "%u:%u", addr_pc_p->ni, addr_pc_p->pc & ITU_PC_MASK); break; default: /* assuming 24-bit */ - sprintf(buf, "%u:%u", addr_pc_p->ni, addr_pc_p->pc & ANSI_PC_MASK); + g_snprintf(buf, buf_len, "%u:%u", addr_pc_p->ni, addr_pc_p->pc & ANSI_PC_MASK); break; } break; @@ -296,11 +299,11 @@ mtp3_addr_to_str_buf( switch (addr_pc_p->type) { case ITU_STANDARD: - sprintf(buf, "%u:%x", addr_pc_p->ni, addr_pc_p->pc & ITU_PC_MASK); + g_snprintf(buf, buf_len, "%u:%x", addr_pc_p->ni, addr_pc_p->pc & ITU_PC_MASK); break; default: /* assuming 24-bit */ - sprintf(buf, "%u:%x", addr_pc_p->ni, addr_pc_p->pc & ANSI_PC_MASK); + g_snprintf(buf, buf_len, "%u:%x", addr_pc_p->ni, addr_pc_p->pc & ANSI_PC_MASK); break; } break; @@ -309,7 +312,7 @@ mtp3_addr_to_str_buf( /* FALLTHRU */ case MTP3_NET_ADDR_FMT_DASHED: - mtp3_pc_to_str_buf(addr_pc_p->pc, buf); + mtp3_pc_to_str_buf(addr_pc_p->pc, buf, buf_len); break; } } diff --git a/epan/dissectors/packet-mtp3.h b/epan/dissectors/packet-mtp3.h index 38aa9ba95f..4657b460fa 100644 --- a/epan/dissectors/packet-mtp3.h +++ b/epan/dissectors/packet-mtp3.h @@ -64,8 +64,8 @@ typedef struct _mtp3_tap_rec_t { #define ANSI_MEMBER_MASK 0xFF0000 #define ANSI_PC_STRING_LENGTH 16 -extern void mtp3_addr_to_str_buf(const guint8 *data, gchar *buf); -extern void mtp3_pc_to_str_buf(const guint32 pc, gchar *buf); +extern void mtp3_addr_to_str_buf(const guint8 *data, gchar *buf, int buf_len); +extern void mtp3_pc_to_str_buf(const guint32 pc, gchar *buf, int buf_len); extern gchar* mtp3_pc_to_str(const guint32 pc); extern gboolean mtp3_pc_structured(void); diff --git a/epan/to_str.c b/epan/to_str.c index e678246b01..7c73091d62 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -791,7 +791,7 @@ address_to_str_buf(const address *addr, gchar *buf, int buf_len) g_snprintf(buf, buf_len, "%02x.%02x.%02x", addr->data[0], addr->data[1], addr->data[2]); break; case AT_SS7PC: - mtp3_addr_to_str_buf(addr->data, buf); + mtp3_addr_to_str_buf(addr->data, buf, buf_len); break; case AT_STRINGZ: strcpy(buf, addr->data); diff --git a/gtk/mtp3_stat.c b/gtk/mtp3_stat.c index 6fe4fe8016..4f350c0a04 100644 --- a/gtk/mtp3_stat.c +++ b/gtk/mtp3_stat.c @@ -47,6 +47,7 @@ #include "simple_dialog.h" #include "dlg_utils.h" #include <epan/tap.h> +#include <epan/emem.h> #include "../register.h" #include "../globals.h" #include "filter_dlg.h" @@ -173,23 +174,24 @@ mtp3_stat_draw( { mtp3_stat_t (*stat_p)[MTP3_MAX_NUM_OPC_DPC] = tapdata; int i, j, row_offset; - char str[256]; + char *str; if (!dlg.win || !tapdata) { return; } + str=ep_alloc(256); i = 0; while (i < mtp3_num_used) { row_offset = i * MTP3_NUM_SI_CODE; - mtp3_addr_to_str_buf((guint8 *) &(*stat_p)[i].addr_opc, str); + mtp3_addr_to_str_buf((guint8 *) &(*stat_p)[i].addr_opc, str, 256); dlg.entries[0] = g_strdup(str); - mtp3_addr_to_str_buf((guint8 *) &(*stat_p)[i].addr_dpc, str); + mtp3_addr_to_str_buf((guint8 *) &(*stat_p)[i].addr_dpc, str, 256); dlg.entries[1] = g_strdup(str); for (j=0; j < MTP3_NUM_SI_CODE; j++) |