diff options
author | ulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-08-18 19:31:15 +0000 |
---|---|---|
committer | ulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-08-18 19:31:15 +0000 |
commit | 749a290f5f47473c550e7c23ab60673656209fa3 (patch) | |
tree | 7bbe9c727c44cc6a41cf4511e4e3963289f644ab | |
parent | ebb5e461959b0372d8912963cb673644b0f1fe0e (diff) |
several times replacing:
sprintf -> g_snprintf
snprintf -> g_snprintf
vsnprintf -> g_vsnprintf
strdup -> g_strdup
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15412 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | asn1/h245/packet-h245-template.c | 2 | ||||
-rw-r--r-- | config.h.win32 | 1 | ||||
-rw-r--r-- | epan/column-utils.c | 6 | ||||
-rw-r--r-- | epan/dfilter/dfilter.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-clnp.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-cops.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-diameter.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-dns.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-fcdns.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-fcswils.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-fddi.c | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-fw1.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-h245.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-iax2.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-icep.c | 4 | ||||
-rw-r--r-- | epan/plugins.c | 2 | ||||
-rw-r--r-- | epan/proto.c | 6 | ||||
-rw-r--r-- | mkstemp.c | 4 |
18 files changed, 37 insertions, 37 deletions
diff --git a/asn1/h245/packet-h245-template.c b/asn1/h245/packet-h245-template.c index 5ee2de2907..8b87000ed3 100644 --- a/asn1/h245/packet-h245-template.c +++ b/asn1/h245/packet-h245-template.c @@ -377,6 +377,6 @@ static void reset_h245_packet_info(h245_packet_info *pi) pi->msg_type = H245_OTHER; pi->frame_label[0] = '\0'; - sprintf(pi->comment, "H245 "); + g_snprintf(pi->comment, sizeof(pi->comment), "H245 "); } diff --git a/config.h.win32 b/config.h.win32 index 8c5a007176..c345bf4e71 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -198,7 +198,6 @@ #define NEED_GETOPT_H 1 #define NEED_STRPTIME_H 1 #define snprintf _snprintf -#define vsnprintf _vsnprintf #define strcasecmp stricmp #define strncasecmp strnicmp #define open _open diff --git a/epan/column-utils.c b/epan/column-utils.c index 14d7097707..da1db1a5c0 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -252,7 +252,7 @@ col_add_fstr(column_info *cinfo, gint el, const gchar *format, ...) { */ cinfo->col_data[i] = cinfo->col_buf[i]; } - vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap); + g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap); cinfo->col_buf[i][max_len - 1] = '\0'; } } @@ -294,7 +294,7 @@ col_do_append_sep_va_fstr(column_info *cinfo, gint el, const gchar *separator, len += sep_len; } } - vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap); + g_vsnprintf(&cinfo->col_buf[i][len], max_len - len, format, ap); cinfo->col_buf[i][max_len-1] = 0; } } @@ -357,7 +357,7 @@ col_prepend_fstr(column_info *cinfo, gint el, const gchar *format, ...) orig_buf[max_len - 1] = '\0'; orig = orig_buf; } - vsnprintf(cinfo->col_buf[i], max_len, format, ap); + g_vsnprintf(cinfo->col_buf[i], max_len, format, ap); cinfo->col_buf[i][max_len - 1] = '\0'; /* diff --git a/epan/dfilter/dfilter.c b/epan/dfilter/dfilter.c index aca1562a44..20b90fc9c6 100644 --- a/epan/dfilter/dfilter.c +++ b/epan/dfilter/dfilter.c @@ -59,7 +59,7 @@ dfilter_fail(const char *format, ...) va_start(args, format); - vsnprintf(dfilter_error_msg_buf, sizeof(dfilter_error_msg_buf), + g_vsnprintf(dfilter_error_msg_buf, sizeof(dfilter_error_msg_buf), format, args); dfilter_error_msg = dfilter_error_msg_buf; va_end(args); diff --git a/epan/dissectors/packet-clnp.c b/epan/dissectors/packet-clnp.c index 117e9d0fa5..083c06ae50 100644 --- a/epan/dissectors/packet-clnp.c +++ b/epan/dissectors/packet-clnp.c @@ -416,16 +416,16 @@ static gchar *print_tsap(const guchar *tsap, int length) cur=ep_alloc(MAX_TSAP_LEN * 2 + 3); cur[0] = '\0'; if (length <= 0 || length > MAX_TSAP_LEN) - sprintf(cur, "<unsupported TSAP length>"); + g_snprintf(cur, MAX_TSAP_LEN * 2 + 3, "<unsupported TSAP length>"); else { allprintable = is_all_printable(tsap,length); if (!allprintable) strcat(cur,"0x"); while (length != 0) { if (allprintable) - sprintf(tmp, "%c", *tsap ++); + g_snprintf(tmp, sizeof(tmp), "%c", *tsap ++); else - sprintf(tmp, "%02x", *tsap ++); + g_snprintf(tmp, sizeof(tmp), "%02x", *tsap ++); strcat(cur, tmp); length --; } diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index bfb9d4f70f..b4b320a739 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -1309,7 +1309,7 @@ static guchar*format_asn_value (struct variable_list *variable, subid_t *variabl variable->type=mib_to_asn_type(subtree->type); if (!sprint_realloc_by_type(&buf, &buf_len, &out_len, TRUE, variable, subtree->enums, subtree->hint, NULL)) - sprintf(buf,"%s","sprint_realloc_by_type failed"); + g_snprintf(buf,SPRINT_MAX_LEN,"%s","sprint_realloc_by_type failed"); return buf; } @@ -1486,8 +1486,8 @@ static int decode_cops_pr_asn1_data(tvbuff_t *tvb, guint32 offset, * to the end of the string. */ vb_display_string = g_malloc(4*vb_length); - buf = &vb_display_string[0]; - len = sprintf(buf, "%03u", vb_octet_string[0]); + buf = vb_display_string; + len = g_snprintf(buf, 4*vb_length, "%03u", vb_octet_string[0]); buf += len; for (i = 1; i < vb_length; i++) { len = sprintf(buf, ".%03u", vb_octet_string[i]); @@ -2657,7 +2657,7 @@ cops_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8 op val_to_str(code16,table_cops_dqos_transaction_id, "Unknown (0x%04x)"),code16); /* Write the right data into the 'info field' on the Gui */ - sprintf(info,"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown")); + g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown")); strcat(info,val_to_str(code16,table_cops_dqos_transaction_id, "Unknown")); if (check_col(pinfo->cinfo, COL_INFO)) { @@ -3053,7 +3053,7 @@ cops_mm_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8 val_to_str(code16,table_cops_mm_transaction_id, "Unknown (0x%04x)"),code16); /* Write the right data into the 'info field' on the Gui */ - sprintf(info,"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown")); + g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown")); strcat(info,val_to_str(code16,table_cops_mm_transaction_id, "Unknown")); if (check_col(pinfo->cinfo, COL_INFO)) { diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index 0853412b8e..5e83b1fbde 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -1069,7 +1069,7 @@ diameter_avp_get_name(guint32 avpCode, guint32 vendorId) avpCode, vendorId); /* If we don't find it, build a name string */ - sprintf(buffer, "Unknown AVP:0x%08x", avpCode); + g_snprintf(buffer, sizeof(buffer), "Unknown AVP:0x%08x", avpCode); return buffer; } /* diameter_avp_get_name */ static const gchar * diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index 8975520ec0..52c12253a9 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -734,7 +734,7 @@ rfc1867_angle(tvbuff_t *tvb, int offset, const char *nsew) angle = angle / 60; minutes = angle % 60; degrees = angle / 60; - sprintf(buf, "%u deg %u min %u.%03u sec %c", degrees, minutes, secs, + g_snprintf(buf, sizeof(buf), "%u deg %u min %u.%03u sec %c", degrees, minutes, secs, tsecs, direction); return buf; } diff --git a/epan/dissectors/packet-fcdns.c b/epan/dissectors/packet-fcdns.c index 79b244ec47..89ea6901fa 100644 --- a/epan/dissectors/packet-fcdns.c +++ b/epan/dissectors/packet-fcdns.c @@ -1151,7 +1151,7 @@ dissect_fcdns_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset) 8))); break; case FC_SWILS_ZONEMBR_DP: - sprintf(dpbuf, "0x%08x", tvb_get_ntohl (tvb, offset+4)); + g_snprintf(dpbuf, sizeof(dpbuf), "0x%08x", tvb_get_ntohl (tvb, offset+4)); proto_tree_add_string (zmbr_tree, hf_fcdns_zone_mbrid, tvb, offset+4, 4, dpbuf); break; diff --git a/epan/dissectors/packet-fcswils.c b/epan/dissectors/packet-fcswils.c index 064921595a..8b0f5e7929 100644 --- a/epan/dissectors/packet-fcswils.c +++ b/epan/dissectors/packet-fcswils.c @@ -1009,7 +1009,7 @@ dissect_swils_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset) 8))); break; case FC_SWILS_ZONEMBR_DP: - sprintf(dpbuf, "0x%08x", tvb_get_ntohl (tvb, offset+4)); + g_snprintf(dpbuf, sizeof(dpbuf), "0x%08x", tvb_get_ntohl (tvb, offset+4)); proto_tree_add_string (zmbr_tree, hf_swils_zone_mbrid, tvb, offset+4, 4, dpbuf); break; @@ -1035,7 +1035,7 @@ dissect_swils_zone_mbr (tvbuff_t *tvb, proto_tree *zmbr_tree, int offset) offset+12, 8, 0); break; case FC_SWILS_ZONEMBR_DP_LUN: - sprintf(dpbuf, "0x%08x", tvb_get_ntohl (tvb, offset+4)); + g_snprintf(dpbuf, sizeof(dpbuf), "0x%08x", tvb_get_ntohl (tvb, offset+4)); proto_tree_add_string (zmbr_tree, hf_swils_zone_mbrid, tvb, offset+4, 4, dpbuf); proto_tree_add_item (zmbr_tree, hf_swils_zone_mbrid_lun, tvb, diff --git a/epan/dissectors/packet-fddi.c b/epan/dissectors/packet-fddi.c index 31ae210826..299ccbf899 100644 --- a/epan/dissectors/packet-fddi.c +++ b/epan/dissectors/packet-fddi.c @@ -219,35 +219,35 @@ fddifc_to_str(int fc) switch (fc & FDDI_FC_CLFF) { case FDDI_FC_MAC: - sprintf(strbuf, "MAC frame, control %x", fc & FDDI_FC_ZZZZ); + g_snprintf(strbuf, sizeof(strbuf), "MAC frame, control %x", fc & FDDI_FC_ZZZZ); return strbuf; case FDDI_FC_SMT: - sprintf(strbuf, "SMT frame, control %x", fc & FDDI_FC_ZZZZ); + g_snprintf(strbuf, sizeof(strbuf), "SMT frame, control %x", fc & FDDI_FC_ZZZZ); return strbuf; case FDDI_FC_LLC_ASYNC: if (fc & FDDI_FC_ASYNC_R) - sprintf(strbuf, "Async LLC frame, control %x", fc & FDDI_FC_ZZZZ); + g_snprintf(strbuf, sizeof(strbuf), "Async LLC frame, control %x", fc & FDDI_FC_ZZZZ); else - sprintf(strbuf, "Async LLC frame, priority %d", + g_snprintf(strbuf, sizeof(strbuf), "Async LLC frame, priority %d", fc & FDDI_FC_ASYNC_PRI); return strbuf; case FDDI_FC_LLC_SYNC: if (fc & FDDI_FC_ZZZZ) { - sprintf(strbuf, "Sync LLC frame, control %x", fc & FDDI_FC_ZZZZ); + g_snprintf(strbuf, sizeof(strbuf), "Sync LLC frame, control %x", fc & FDDI_FC_ZZZZ); return strbuf; } else return "Sync LLC frame"; case FDDI_FC_IMP_ASYNC: - sprintf(strbuf, "Implementor async frame, control %x", + g_snprintf(strbuf, sizeof(strbuf), "Implementor async frame, control %x", fc & FDDI_FC_ZZZZ); return strbuf; case FDDI_FC_IMP_SYNC: - sprintf(strbuf, "Implementor sync frame, control %x", + g_snprintf(strbuf, sizeof(strbuf), "Implementor sync frame, control %x", fc & FDDI_FC_ZZZZ); return strbuf; break; diff --git a/epan/dissectors/packet-fw1.c b/epan/dissectors/packet-fw1.c index e1c9ca15cb..08e8189ee0 100644 --- a/epan/dissectors/packet-fw1.c +++ b/epan/dissectors/packet-fw1.c @@ -151,7 +151,7 @@ dissect_fw1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_clear(pinfo->cinfo, COL_INFO); - /* sprintf(header, fw1_header); */ + /* g_snprintf(header, sizeof(header), fw1_header); */ /* fetch info to local variable */ direction = tvb_get_guint8(tvb, 0); diff --git a/epan/dissectors/packet-h245.c b/epan/dissectors/packet-h245.c index 411da62976..9a5772a0a5 100644 --- a/epan/dissectors/packet-h245.c +++ b/epan/dissectors/packet-h245.c @@ -22837,6 +22837,6 @@ static void reset_h245_packet_info(h245_packet_info *pi) pi->msg_type = H245_OTHER; pi->frame_label[0] = '\0'; - sprintf(pi->comment, "H245 "); + g_snprintf(pi->comment, sizeof(pi->comment), "H245 "); } diff --git a/epan/dissectors/packet-iax2.c b/epan/dissectors/packet-iax2.c index b8e83aa002..3efba06205 100644 --- a/epan/dissectors/packet-iax2.c +++ b/epan/dissectors/packet-iax2.c @@ -414,7 +414,8 @@ static gchar *key_to_str( const iax_circuit_key *key ) /* why doesn't address_to_str take a const pointer? cast the warnings into oblivion. */ - sprintf(strp,"{%s:%i,%i}", + /* XXX - is this a case for ep_alloc? */ + g_snprintf(strp, 80, "{%s:%i,%i}", address_to_str((address *)&key->addr), key->port, key->callno); diff --git a/epan/dissectors/packet-icep.c b/epan/dissectors/packet-icep.c index 87838fdd28..9e1f13709e 100644 --- a/epan/dissectors/packet-icep.c +++ b/epan/dissectors/packet-icep.c @@ -327,9 +327,7 @@ static void dissect_ice_facet(proto_tree *tree, int hf_icep, if ( Size == 0 ) { if (tree) { - s = ep_alloc( strlen("(empty)") + 1 ); - sprintf(s, "(empty)"); - s[strlen("(empty)")] = '\0'; + s = ep_strdup( "(empty)" ); /* display the 0x00 Size byte when click on a empty ice_string */ proto_tree_add_string(tree, hf_icep, tvb, offset - 1, 1, s); } diff --git a/epan/plugins.c b/epan/plugins.c index b4f665b369..9d606376b8 100644 --- a/epan/plugins.c +++ b/epan/plugins.c @@ -403,7 +403,7 @@ char *get_plugins_global_dir(const char *plugin_dir) /* * Scan the plugin directory. */ - return strdup(plugin_dir); + return g_strdup(plugin_dir); #endif } diff --git a/epan/proto.c b/epan/proto.c index 0f00aa014e..cba96405ad 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -525,7 +525,7 @@ proto_tree_free_node(proto_node *node, gpointer data _U_) /* Is the parsing being done for a visible proto_tree or an invisible one? * By setting this correctly, the proto_tree creation is sped up by not - * having to call vsnprintf and copy strings around. + * having to call g_vsnprintf and copy strings around. */ void proto_tree_set_visible(proto_tree *tree, gboolean visible) @@ -2359,7 +2359,7 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap) if (!PROTO_ITEM_IS_HIDDEN(pi)) { ITEM_LABEL_NEW(fi->rep); - ret = vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH, format, ap); + ret = g_vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH, format, ap); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) fi->rep->representation[ITEM_LABEL_LENGTH - 1] = '\0'; } @@ -2416,7 +2416,7 @@ proto_item_append_text(proto_item *pi, const char *format, ...) curlen = strlen(fi->rep->representation); if (ITEM_LABEL_LENGTH > curlen) { - ret = vsnprintf(fi->rep->representation + curlen, + ret = g_vsnprintf(fi->rep->representation + curlen, ITEM_LABEL_LENGTH - curlen, format, ap); if ((ret == -1) || (ret >= (int)(ITEM_LABEL_LENGTH - curlen))) fi->rep->representation[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -41,6 +41,8 @@ #include <process.h> /* For spawning child process */ #endif +#include <glib.h> + #ifndef __set_errno #define __set_errno(x) errno=(x) #endif @@ -65,7 +67,7 @@ mkstemp (template) return -1; } - if (sprintf (&template[len - 5], "%.5u", + if (g_snprintf (&template[len - 5], 6, "%.5u", (unsigned int) getpid () % 100000) != 5) /* Inconceivable lossage. */ return -1; |