diff options
-rw-r--r-- | epan/dissectors/packet-dcerpc.c | 28 | ||||
-rw-r--r-- | epan/dissectors/packet-dns.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-icmpv6.c | 12 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee80211.c | 80 | ||||
-rw-r--r-- | epan/dissectors/packet-isakmp.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-pim.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-smb.c | 3 | ||||
-rw-r--r-- | epan/proto.c | 60 | ||||
-rw-r--r-- | epan/tvbuff.c | 4 | ||||
-rw-r--r-- | epan/tvbuff.h | 2 | ||||
-rw-r--r-- | plugins/lwres/packet-lwres.c | 18 |
11 files changed, 108 insertions, 129 deletions
diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index cb89d45798..c0be1a12b7 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -2614,7 +2614,7 @@ dissect_dcerpc_cn_bind (tvbuff_t *tvb, gint offset, packet_info *pinfo, if (ctx_tree) { proto_item *iface_item; - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", if_id.Data1, if_id.Data2, if_id.Data3, if_id.Data4[0], if_id.Data4[1], @@ -2622,7 +2622,7 @@ dissect_dcerpc_cn_bind (tvbuff_t *tvb, gint offset, packet_info *pinfo, if_id.Data4[4], if_id.Data4[5], if_id.Data4[6], if_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); #ifdef _WIN32 if(ResolveWin32UUID(if_id, UUID_NAME, MAX_PATH)) @@ -2723,14 +2723,14 @@ dissect_dcerpc_cn_bind (tvbuff_t *tvb, gint offset, packet_info *pinfo, /* XXX - use "dissect_ndr_uuid_t()"? */ dcerpc_tvb_get_uuid (tvb, offset, hdr->drep, &trans_id); if (iface_tree) { - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", trans_id.Data1, trans_id.Data2, trans_id.Data3, trans_id.Data4[0], trans_id.Data4[1], trans_id.Data4[2], trans_id.Data4[3], trans_id.Data4[4], trans_id.Data4[5], trans_id.Data4[6], trans_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); proto_tree_add_string_format (iface_tree, hf_dcerpc_cn_bind_trans_id, tvb, offset, 16, uuid_str, "Transfer Syntax: %s", uuid_str); @@ -2813,14 +2813,14 @@ dissect_dcerpc_cn_bind_ack (tvbuff_t *tvb, gint offset, packet_info *pinfo, /* XXX - use "dissect_ndr_uuid_t()"? */ dcerpc_tvb_get_uuid (tvb, offset, hdr->drep, &trans_id); if (dcerpc_tree) { - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", trans_id.Data1, trans_id.Data2, trans_id.Data3, trans_id.Data4[0], trans_id.Data4[1], trans_id.Data4[2], trans_id.Data4[3], trans_id.Data4[4], trans_id.Data4[5], trans_id.Data4[6], trans_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); proto_tree_add_string_format (dcerpc_tree, hf_dcerpc_cn_ack_trans_id, tvb, offset, 16, uuid_str, "Transfer Syntax: %s", uuid_str); @@ -3283,7 +3283,7 @@ dissect_dcerpc_cn_rqst (tvbuff_t *tvb, gint offset, packet_info *pinfo, /* XXX - use "dissect_ndr_uuid_t()"? */ dcerpc_tvb_get_uuid (tvb, offset, hdr->drep, &obj_id); if (dcerpc_tree) { - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", obj_id.Data1, obj_id.Data2, obj_id.Data3, obj_id.Data4[0], @@ -3294,7 +3294,7 @@ dissect_dcerpc_cn_rqst (tvbuff_t *tvb, gint offset, packet_info *pinfo, obj_id.Data4[5], obj_id.Data4[6], obj_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); proto_tree_add_string_format (dcerpc_tree, hf_dcerpc_obj_id, tvb, offset, 16, uuid_str, "Object UUID: %s", uuid_str); @@ -4806,7 +4806,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { /* XXX - use "dissect_ndr_uuid_t()"? */ - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", hdr.obj_id.Data1, hdr.obj_id.Data2, hdr.obj_id.Data3, hdr.obj_id.Data4[0], @@ -4817,7 +4817,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) hdr.obj_id.Data4[5], hdr.obj_id.Data4[6], hdr.obj_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); proto_tree_add_string_format (dcerpc_tree, hf_dcerpc_obj_id, tvb, offset, 16, uuid_str, "Object UUID: %s", uuid_str); @@ -4826,7 +4826,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { /* XXX - use "dissect_ndr_uuid_t()"? */ - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", hdr.if_id.Data1, hdr.if_id.Data2, hdr.if_id.Data3, hdr.if_id.Data4[0], @@ -4837,7 +4837,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) hdr.if_id.Data4[5], hdr.if_id.Data4[6], hdr.if_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); proto_tree_add_string_format (dcerpc_tree, hf_dcerpc_dg_if_id, tvb, offset, 16, uuid_str, "Interface: %s", uuid_str); @@ -4846,7 +4846,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (tree) { /* XXX - use "dissect_ndr_uuid_t()"? */ - uuid_str_len = snprintf(uuid_str, DCERPC_UUID_STR_LEN, + uuid_str_len = g_snprintf(uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", hdr.act_id.Data1, hdr.act_id.Data2, hdr.act_id.Data3, hdr.act_id.Data4[0], @@ -4857,7 +4857,7 @@ dissect_dcerpc_dg (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) hdr.act_id.Data4[5], hdr.act_id.Data4[6], hdr.act_id.Data4[7]); - if (uuid_str_len >= DCERPC_UUID_STR_LEN) + if (uuid_str_len == -1 || uuid_str_len >= DCERPC_UUID_STR_LEN) memset(uuid_str, 0, DCERPC_UUID_STR_LEN); proto_tree_add_string_format (dcerpc_tree, hf_dcerpc_dg_act_id, tvb, offset, 16, uuid_str, "Activity: %s", uuid_str); diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index f0788d3d68..8975520ec0 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -34,10 +34,6 @@ #include <string.h> #include <memory.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <glib.h> #include <epan/ipv6-utils.h> #include <epan/packet.h> @@ -567,9 +563,9 @@ get_dns_name(tvbuff_t *tvb, int offset, int dns_data_offset, label_len = (bit_count - 1) / 8 + 1; if (maxname > 0) { - print_len = snprintf(np, maxname + 1, "\\[x"); + print_len = g_snprintf(np, maxname + 1, "\\[x"); if (print_len != -1 && print_len <= maxname) { - /* Some versions of snprintf return -1 if they'd truncate + /* Some versions of g_snprintf return -1 if they'd truncate the output. Others return <buf_size> or greater. */ np += print_len; maxname -= print_len; @@ -581,10 +577,10 @@ get_dns_name(tvbuff_t *tvb, int offset, int dns_data_offset, } while(label_len--) { if (maxname > 0) { - print_len = snprintf(np, maxname + 1, "%02x", + print_len = g_snprintf(np, maxname + 1, "%02x", tvb_get_guint8(tvb, offset)); if (print_len != -1 && print_len <= maxname) { - /* Some versions of snprintf return -1 if they'd truncate + /* Some versions of g_snprintf return -1 if they'd truncate the output. Others return <buf_size> or greater. */ np += print_len; maxname -= print_len; @@ -597,9 +593,9 @@ get_dns_name(tvbuff_t *tvb, int offset, int dns_data_offset, offset++; } if (maxname > 0) { - print_len = snprintf(np, maxname + 1, "/%d]", bit_count); + print_len = g_snprintf(np, maxname + 1, "/%d]", bit_count); if (print_len != -1 && print_len <= maxname) { - /* Some versions of snprintf return -1 if they'd truncate + /* Some versions of g_snprintf return -1 if they'd truncate the output. Others return <buf_size> or greater. */ np += print_len; maxname -= print_len; diff --git a/epan/dissectors/packet-icmpv6.c b/epan/dissectors/packet-icmpv6.c index e9a23588a1..7f3af7c74a 100644 --- a/epan/dissectors/packet-icmpv6.c +++ b/epan/dissectors/packet-icmpv6.c @@ -41,10 +41,6 @@ #include <glib.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <epan/packet.h> #include "packet-ipv6.h" #include "packet-dns.h" @@ -478,9 +474,9 @@ bitrange0(guint32 v, int s, char *buf, int buflen) break; } if (i == 1) - l = snprintf(p, ep - p, ",%d", s + off); + l = g_snprintf(p, ep - p, ",%d", s + off); else { - l = snprintf(p, ep - p, ",%d-%d", s + off, + l = g_snprintf(p, ep - p, ",%d-%d", s + off, s + off + i - 1); } if (l == -1 || l > ep - p) { @@ -1214,12 +1210,12 @@ dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) char typebuf[256], codebuf[256]; if (coltypename && strcmp(coltypename, "Unknown") == 0) { - snprintf(typebuf, sizeof(typebuf), "Unknown (0x%02x)", + g_snprintf(typebuf, sizeof(typebuf), "Unknown (0x%02x)", dp->icmp6_type); coltypename = typebuf; } if (colcodename && strcmp(colcodename, "Unknown") == 0) { - snprintf(codebuf, sizeof(codebuf), "Unknown (0x%02x)", + g_snprintf(codebuf, sizeof(codebuf), "Unknown (0x%02x)", dp->icmp6_code); colcodename = codebuf; } diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index f5d8d03a9e..5d1e257e2b 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -945,7 +945,7 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, /* Wi-Fi Protected Access (WPA) Information Element */ if (tag_val_off + 6 <= tag_len && !memcmp(tag_val, WPA_OUI"\x01", 4)) { - snprintf(out_buff, SHORT_STR, "WPA IE, type %u, version %u", + g_snprintf(out_buff, SHORT_STR, "WPA IE, type %u, version %u", tag_val[tag_val_off + 3], pletohs(&tag_val[tag_val_off + 4])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 6, out_buff); offset += 6; @@ -953,14 +953,14 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, if (tag_val_off + 4 <= tag_len) { /* multicast cipher suite */ if (!memcmp(&tag_val[tag_val_off], WPA_OUI, 3)) { - snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s", + g_snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s", wpa_cipher_idx2str(tag_val[tag_val_off + 3])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; tag_val_off += 4; /* unicast cipher suites */ if (tag_val_off + 2 <= tag_len) { - snprintf(out_buff, SHORT_STR, "# of unicast cipher suites: %u", + g_snprintf(out_buff, SHORT_STR, "# of unicast cipher suites: %u", pletohs(tag_val + tag_val_off)); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; @@ -968,7 +968,7 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, i = 1; while (tag_val_off + 4 <= tag_len) { if (!memcmp(&tag_val[tag_val_off], WPA_OUI, 3)) { - snprintf(out_buff, SHORT_STR, "Unicast cipher suite %u: %s", + g_snprintf(out_buff, SHORT_STR, "Unicast cipher suite %u: %s", i, wpa_cipher_idx2str(tag_val[tag_val_off + 3])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; @@ -980,7 +980,7 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, } /* authenticated key management suites */ if (tag_val_off + 2 <= tag_len) { - snprintf(out_buff, SHORT_STR, "# of auth key management suites: %u", + g_snprintf(out_buff, SHORT_STR, "# of auth key management suites: %u", pletohs(tag_val + tag_val_off)); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; @@ -988,7 +988,7 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, i = 1; while (tag_val_off + 4 <= tag_len) { if (!memcmp(&tag_val[tag_val_off], WPA_OUI, 3)) { - snprintf(out_buff, SHORT_STR, "auth key management suite %u: %s", + g_snprintf(out_buff, SHORT_STR, "auth key management suite %u: %s", i, wpa_keymgmt_idx2str(tag_val[tag_val_off + 3])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; @@ -1007,20 +1007,20 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, offset, tag_len - tag_val_off, "Not interpreted"); } else if (tag_val_off + 7 <= tag_len && !memcmp(tag_val, WME_OUI"\x02\x00", 5)) { /* Wireless Multimedia Enhancements (WME) Information Element */ - snprintf(out_buff, SHORT_STR, "WME IE: type %u, subtype %u, version %u, parameter set %u", + g_snprintf(out_buff, SHORT_STR, "WME IE: type %u, subtype %u, version %u, parameter set %u", tag_val[tag_val_off + 3], tag_val[tag_val_off + 4], tag_val[tag_val_off + 5], tag_val[tag_val_off + 6]); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 7, out_buff); } else if (tag_val_off + 24 <= tag_len && !memcmp(tag_val, WME_OUI"\x02\x01", 5)) { /* Wireless Multimedia Enhancements (WME) Parameter Element */ - snprintf(out_buff, SHORT_STR, "WME PE: type %u, subtype %u, version %u, parameter set %u", + g_snprintf(out_buff, SHORT_STR, "WME PE: type %u, subtype %u, version %u, parameter set %u", tag_val[tag_val_off + 3], tag_val[tag_val_off + 4], tag_val[tag_val_off + 5], tag_val[tag_val_off + 6]); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 7, out_buff); offset += 8; tag_val_off += 8; for (i = 0; i < 4; i++) { - snprintf(out_buff, SHORT_STR, "WME AC Parameters: ACI %u (%s), Admission Control %sMandatory, AIFSN %u, ECWmin %u, ECWmax %u, TXOP %u", + g_snprintf(out_buff, SHORT_STR, "WME AC Parameters: ACI %u (%s), Admission Control %sMandatory, AIFSN %u, ECWmin %u, ECWmax %u, TXOP %u", (tag_val[tag_val_off] & 0x60) >> 5, wme_acs[(tag_val[tag_val_off] & 0x60) >> 5], (tag_val[tag_val_off] & 0x10) ? "" : "not ", @@ -1051,14 +1051,14 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, }; const char *field; - snprintf(out_buff, SHORT_STR, "WME TSPEC: type %u, subtype %u, version %u", + g_snprintf(out_buff, SHORT_STR, "WME TSPEC: type %u, subtype %u, version %u", tag_val[tag_val_off + 3], tag_val[tag_val_off + 4], tag_val[tag_val_off + 5]); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 6, out_buff); offset += 6; tag_val_off += 6; ts_info = tvb_get_letohs(tvb, offset); - snprintf(out_buff, SHORT_STR, "WME TS Info: Priority %u (%s) (%s), Contention-based access %sset, %s", + g_snprintf(out_buff, SHORT_STR, "WME TS Info: Priority %u (%s) (%s), Contention-based access %sset, %s", (ts_info >> 11) & 0x7, qos_tags[(ts_info >> 11) & 0x7], qos_acs[(ts_info >> 11) & 0x7], (ts_info & 0x0080) ? "" : "not ", direction[(ts_info >> 5) & 0x3]); @@ -1067,19 +1067,19 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, tag_val_off += 2; msdu_size = tvb_get_letohs(tvb, offset); - snprintf(out_buff, SHORT_STR, "WME TSPEC: %s MSDU Size %u", + g_snprintf(out_buff, SHORT_STR, "WME TSPEC: %s MSDU Size %u", (msdu_size & 0x8000) ? "Fixed" : "Nominal", msdu_size & 0x7fff); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; tag_val_off += 2; - snprintf(out_buff, SHORT_STR, "WME TSPEC: Maximum MSDU Size %u", tvb_get_letohs(tvb, offset)); + g_snprintf(out_buff, SHORT_STR, "WME TSPEC: Maximum MSDU Size %u", tvb_get_letohs(tvb, offset)); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; tag_val_off += 2; while ((field = val_to_str(tag_val_off, fields, "Unknown"))) { - snprintf(out_buff, SHORT_STR, "WME TSPEC: %s %u", field, tvb_get_letohl(tvb, offset)); + g_snprintf(out_buff, SHORT_STR, "WME TSPEC: %s %u", field, tvb_get_letohl(tvb, offset)); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; tag_val_off += 4; @@ -1088,12 +1088,12 @@ dissect_vendor_specific_ie(proto_tree * tree, tvbuff_t * tvb, int offset, } surplus_bandwidth = tvb_get_letohs(tvb, offset); - snprintf(out_buff, SHORT_STR, "WME TSPEC: Surplus Bandwidth Allowance Factor %u.%u", + g_snprintf(out_buff, SHORT_STR, "WME TSPEC: Surplus Bandwidth Allowance Factor %u.%u", (surplus_bandwidth >> 13) & 0x7, (surplus_bandwidth & 0x1fff)); offset += 2; tag_val_off += 2; - snprintf(out_buff, SHORT_STR, "WME TSPEC: Medium Time %u", tvb_get_letohs(tvb, offset)); + g_snprintf(out_buff, SHORT_STR, "WME TSPEC: Medium Time %u", tvb_get_letohs(tvb, offset)); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; tag_val_off += 2; @@ -1136,7 +1136,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, return; } - snprintf(out_buff, SHORT_STR, "RSN IE, version %u", + g_snprintf(out_buff, SHORT_STR, "RSN IE, version %u", pletohs(&tag_val[tag_val_off])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); @@ -1148,7 +1148,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, /* multicast cipher suite */ if (!memcmp(&tag_val[tag_val_off], RSN_OUI, 3)) { - snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s", + g_snprintf(out_buff, SHORT_STR, "Multicast cipher suite: %s", wpa_cipher_idx2str(tag_val[tag_val_off + 3])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; @@ -1160,7 +1160,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, /* unicast cipher suites */ count = pletohs(tag_val + tag_val_off); - snprintf(out_buff, SHORT_STR, "# of unicast cipher suites: %u", count); + g_snprintf(out_buff, SHORT_STR, "# of unicast cipher suites: %u", count); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; tag_val_off += 2; @@ -1168,7 +1168,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, while (tag_val_off + 4 <= tag_len && i <= count) { if (memcmp(&tag_val[tag_val_off], RSN_OUI, 3) != 0) goto done; - snprintf(out_buff, SHORT_STR, "Unicast cipher suite %u: %s", + g_snprintf(out_buff, SHORT_STR, "Unicast cipher suite %u: %s", i, wpa_cipher_idx2str(tag_val[tag_val_off + 3])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; @@ -1181,7 +1181,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, /* authenticated key management suites */ count = pletohs(tag_val + tag_val_off); - snprintf(out_buff, SHORT_STR, "# of auth key management suites: %u", count); + g_snprintf(out_buff, SHORT_STR, "# of auth key management suites: %u", count); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; tag_val_off += 2; @@ -1189,7 +1189,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, while (tag_val_off + 4 <= tag_len && i <= count) { if (memcmp(&tag_val[tag_val_off], RSN_OUI, 3) != 0) goto done; - snprintf(out_buff, SHORT_STR, "auth key management suite %u: %s", + g_snprintf(out_buff, SHORT_STR, "auth key management suite %u: %s", i, wpa_keymgmt_idx2str(tag_val[tag_val_off + 3])); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 4, out_buff); offset += 4; @@ -1201,7 +1201,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, goto done; rsn_capab = pletohs(&tag_val[tag_val_off]); - snprintf(out_buff, SHORT_STR, "RSN Capabilities 0x%04x", rsn_capab); + g_snprintf(out_buff, SHORT_STR, "RSN Capabilities 0x%04x", rsn_capab); cap_item = proto_tree_add_uint_format(tree, rsn_cap, tvb, offset, 2, rsn_capab, "RSN Capabilities: 0x%04X", rsn_capab); @@ -1221,7 +1221,7 @@ dissect_rsn_ie(proto_tree * tree, tvbuff_t * tvb, int offset, goto done; count = pletohs(tag_val + tag_val_off); - snprintf(out_buff, SHORT_STR, "# of PMKIDs: %u", count); + g_snprintf(out_buff, SHORT_STR, "# of PMKIDs: %u", count); proto_tree_add_string(tree, tag_interpretation, tvb, offset, 2, out_buff); offset += 2; tag_val_off += 2; @@ -1376,7 +1376,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of } n += ret; } - snprintf (out_buff, SHORT_STR, "Supported rates: %s [Mbit/sec]", print_buff); + g_snprintf (out_buff, SHORT_STR, "Supported rates: %s [Mbit/sec]", print_buff); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, tag_len, out_buff); @@ -1390,7 +1390,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of tag_len); break; } - snprintf (out_buff, SHORT_STR, + g_snprintf (out_buff, SHORT_STR, "Dwell time 0x%04X, Hop Set %2d, Hop Pattern %2d, Hop Index %2d", tvb_get_letohs(tvb, offset + 2), tvb_get_guint8(tvb, offset + 4), @@ -1408,7 +1408,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of tag_len); break; } - snprintf (out_buff, SHORT_STR, "Current Channel: %u", + g_snprintf (out_buff, SHORT_STR, "Current Channel: %u", tvb_get_guint8(tvb, offset + 2)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, @@ -1423,22 +1423,22 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of tag_len); break; } - snprintf (out_buff, SHORT_STR, "CFP count: %u", + g_snprintf (out_buff, SHORT_STR, "CFP count: %u", tvb_get_guint8(tvb, offset + 2)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 2, 1, out_buff, "%s", out_buff); - snprintf (out_buff, SHORT_STR, "CFP period: %u", + g_snprintf (out_buff, SHORT_STR, "CFP period: %u", tvb_get_guint8(tvb, offset + 3)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 3, 1, out_buff, "%s", out_buff); - snprintf (out_buff, SHORT_STR, "CFP max duration: %u", + g_snprintf (out_buff, SHORT_STR, "CFP max duration: %u", tvb_get_letohs(tvb, offset + 4)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 4, 2, out_buff, "%s", out_buff); - snprintf (out_buff, SHORT_STR, "CFP Remaining: %u", + g_snprintf (out_buff, SHORT_STR, "CFP Remaining: %u", tvb_get_letohs(tvb, offset + 6)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string_format(tree, tag_interpretation, tvb, offset + 6, @@ -1516,7 +1516,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of tag_len); break; } - snprintf (out_buff, SHORT_STR, "ATIM window 0x%X", + g_snprintf (out_buff, SHORT_STR, "ATIM window 0x%X", tvb_get_letohs(tvb, offset + 2)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, @@ -1536,7 +1536,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of } tvb_memcpy(tvb, ccode, offset + 2, 2); ccode[2] = '\0'; - snprintf (out_buff, SHORT_STR, "Country Code: %s, %s Environment", + g_snprintf (out_buff, SHORT_STR, "Country Code: %s, %s Environment", format_text(ccode, 2), val_to_str(tvb_get_guint8(tvb, offset + 4), environment_vals,"Unknown (0x%02x)")); out_buff[SHORT_STR-1] = '\0'; @@ -1570,7 +1570,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of tag_len); break; } - snprintf (out_buff, SHORT_STR, "Prime Radix: %u, Number of Channels: %u", + g_snprintf (out_buff, SHORT_STR, "Prime Radix: %u, Number of Channels: %u", tvb_get_guint8(tvb, offset + 2), tvb_get_guint8(tvb, offset + 3)); out_buff[SHORT_STR-1] = '\0'; @@ -1579,7 +1579,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of break; case TAG_CHALLENGE_TEXT: - snprintf (out_buff, SHORT_STR, "Challenge text: %s", + g_snprintf (out_buff, SHORT_STR, "Challenge text: %s", tvb_bytes_to_str(tvb, offset + 2, tag_len)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, @@ -1598,12 +1598,12 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of break; } erp_info = tvb_get_guint8 (tvb, offset + 2); - snprintf (print_buff, SHORT_STR, "%sNon-ERP STAs, %suse protection, %s preambles", + g_snprintf (print_buff, SHORT_STR, "%sNon-ERP STAs, %suse protection, %s preambles", erp_info & 0x01 ? "" : "no ", erp_info & 0x02 ? "" : "do not ", erp_info & 0x04 ? "short or long": "long"); print_buff[SHORT_STR-1] = '\0'; - snprintf (out_buff, SHORT_STR, + g_snprintf (out_buff, SHORT_STR, "ERP info: 0x%x (%s)",erp_info,print_buff); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2, @@ -1621,7 +1621,7 @@ add_tagged_field (packet_info * pinfo, proto_tree * tree, tvbuff_t * tvb, int of tag_len); break; } - snprintf (out_buff, SHORT_STR, "%.16s", + g_snprintf (out_buff, SHORT_STR, "%.16s", tvb_format_stringzpad(tvb, offset + 12, 16)); out_buff[SHORT_STR-1] = '\0'; proto_tree_add_string_format (tree, tag_interpretation, tvb, offset + 2, @@ -2644,7 +2644,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo, * determined to be possible only with one of the encryption protocols. */ if (tvb_get_guint8(tvb, hdr_len + 1) & 0x20) { - snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X", + g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X", tvb_get_letohl(tvb, hdr_len + 4), tvb_get_guint8(tvb, hdr_len), tvb_get_guint8(tvb, hdr_len + 2)); @@ -2652,7 +2652,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo, EXTIV_LEN, out_buff); } if (tvb_get_guint8(tvb, hdr_len + 2) == 0) { - snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X", + g_snprintf(out_buff, SHORT_STR, "0x%08X%02X%02X", tvb_get_letohl(tvb, hdr_len + 4), tvb_get_guint8(tvb, hdr_len + 1), tvb_get_guint8(tvb, hdr_len)); diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index cfaecc7fcc..eb5ce61fed 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -38,10 +38,6 @@ #include <glib.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <epan/packet.h> #include <epan/ipv6-utils.h> #include <epan/ipproto.h> @@ -1989,7 +1985,7 @@ situation2str(guint32 type) int ret; if (type & SIT_IDENTITY) { - ret = snprintf(msg, SIT_MSG_NUM-n, "%sIDENTITY", sep); + ret = g_snprintf(msg, SIT_MSG_NUM-n, "%sIDENTITY", sep); if (ret == -1 || ret >= SIT_MSG_NUM-n) { /* Truncated. */ msg[SIT_MSG_NUM-1] = '\0'; @@ -2003,7 +1999,7 @@ situation2str(guint32 type) /* No more room. */ return msg; } - ret = snprintf(msg, SIT_MSG_NUM-n, "%sSECRECY", sep); + ret = g_snprintf(msg, SIT_MSG_NUM-n, "%sSECRECY", sep); if (ret == -1 || ret >= SIT_MSG_NUM-n) { /* Truncated. */ msg[SIT_MSG_NUM-1] = '\0'; @@ -2017,7 +2013,7 @@ situation2str(guint32 type) /* No more room. */ return msg; } - ret = snprintf(msg, SIT_MSG_NUM-n, "%sINTEGRITY", sep); + ret = g_snprintf(msg, SIT_MSG_NUM-n, "%sINTEGRITY", sep); if (ret == -1 || ret >= SIT_MSG_NUM-n) { /* Truncated. */ msg[SIT_MSG_NUM-1] = '\0'; diff --git a/epan/dissectors/packet-pim.c b/epan/dissectors/packet-pim.c index 768c37d51d..7e93e8e6e8 100644 --- a/epan/dissectors/packet-pim.c +++ b/epan/dissectors/packet-pim.c @@ -31,10 +31,6 @@ #include <string.h> #include <glib.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include <epan/packet.h> #include <epan/ipproto.h> #include <epan/afn.h> diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 1b33ba6ddf..678a3cabdc 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -12986,14 +12986,13 @@ dissect_qfsi_vals(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, case 1008: /* Query Object ID is GUID plus unknown data */ { e_uuid_t fs_id; char uuid_str[DCERPC_UUID_STR_LEN]; - int uuid_str_len; guint8 drep = 0x10; CHECK_BYTE_COUNT_TRANS_SUBR(16); dcerpc_tvb_get_uuid (tvb, offset, &drep, &fs_id); - uuid_str_len = snprintf( + g_snprintf( uuid_str, DCERPC_UUID_STR_LEN, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", fs_id.Data1, fs_id.Data2, fs_id.Data3, diff --git a/epan/proto.c b/epan/proto.c index 667950d993..0f00aa014e 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -32,10 +32,6 @@ #include <glib.h> #include <float.h> -#ifdef NEED_SNPRINTF_H -# include "snprintf.h" -#endif - #include "packet.h" #include "strutil.h" #include "addr_resolv.h" @@ -3073,7 +3069,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) switch(hfinfo->type) { case FT_NONE: case FT_PROTOCOL: - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s", hfinfo->name); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -3087,14 +3083,14 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_UINT_BYTES: bytes = fvalue_get(&fi->value); if (bytes) { - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, bytes_to_str(bytes, fvalue_length(&fi->value))); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; } else { - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: <MISSING>", hfinfo->name); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -3152,7 +3148,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) break; case FT_FLOAT: - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %." STRINGIFY(FLT_DIG) "f", hfinfo->name, fvalue_get_floating(&fi->value)); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3160,7 +3156,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) break; case FT_DOUBLE: - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %." STRINGIFY(DBL_DIG) "g", hfinfo->name, fvalue_get_floating(&fi->value)); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3168,7 +3164,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) break; case FT_ABSOLUTE_TIME: - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, abs_time_to_str(fvalue_get(&fi->value))); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3176,7 +3172,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) break; case FT_RELATIVE_TIME: - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s seconds", hfinfo->name, rel_time_to_secs_str(fvalue_get(&fi->value))); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3185,7 +3181,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_IPXNET: integer = fvalue_get_integer(&fi->value); - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s (0x%08X)", hfinfo->name, get_ipxnet_name(integer), integer); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3194,7 +3190,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_ETHER: bytes = fvalue_get(&fi->value); - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s (%s)", hfinfo->name, get_ether_name(bytes), ether_to_str(bytes)); @@ -3205,7 +3201,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_IPv4: ipv4 = fvalue_get(&fi->value); n_addr = ipv4_get_net_order_addr(ipv4); - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s (%s)", hfinfo->name, get_hostname(n_addr), ip_to_str((guint8*)&n_addr)); @@ -3215,7 +3211,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_IPv6: bytes = fvalue_get(&fi->value); - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s (%s)", hfinfo->name, get_hostname6((struct e_in6_addr *)bytes), ip6_to_str((struct e_in6_addr*)bytes)); @@ -3225,7 +3221,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_GUID: bytes = fvalue_get(&fi->value); - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, guid_to_str(bytes)); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3237,11 +3233,11 @@ proto_item_fill_label(field_info *fi, gchar *label_str) case FT_UINT_STRING: bytes = fvalue_get(&fi->value); if(strlen(bytes) > ITEM_LABEL_LENGTH) { - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s [truncated]: %s", hfinfo->name, format_text(bytes, strlen(bytes))); } else { - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %s", hfinfo->name, format_text(bytes, strlen(bytes))); } @@ -3292,7 +3288,7 @@ fill_label_boolean(field_info *fi, gchar *label_str) } /* Fill in the textual info */ - ret = snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length, + ret = g_snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length, "%s: %s", hfinfo->name, value ? tfstring->true_string : tfstring->false_string); if ((ret == -1) || (ret >= (ITEM_LABEL_LENGTH - bitfield_byte_length))) @@ -3331,7 +3327,7 @@ fill_label_enumerated_bitfield(field_info *fi, gchar *label_str) bitfield_byte_length = p - label_str; /* Fill in the textual info using stored (shifted) value */ - ret = snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length, + ret = g_snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length, format, hfinfo->name, val_to_str(value, cVALS(hfinfo->strings), "Unknown"), value); if ((ret == -1) || (ret >= (ITEM_LABEL_LENGTH - bitfield_byte_length))) @@ -3368,7 +3364,7 @@ fill_label_numeric_bitfield(field_info *fi, gchar *label_str) bitfield_byte_length = p - label_str; /* Fill in the textual info using stored (shifted) value */ - ret = snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length, + ret = g_snprintf(p, ITEM_LABEL_LENGTH - bitfield_byte_length, format, hfinfo->name, value); if ((ret == -1) || (ret >= (ITEM_LABEL_LENGTH - bitfield_byte_length))) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -3389,7 +3385,7 @@ fill_label_enumerated_uint(field_info *fi, gchar *label_str) value = fvalue_get_integer(&fi->value); /* Fill in the textual info */ - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, format, hfinfo->name, val_to_str(value, cVALS(hfinfo->strings), "Unknown"), value); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3409,7 +3405,7 @@ fill_label_uint(field_info *fi, gchar *label_str) value = fvalue_get_integer(&fi->value); /* Fill in the textual info */ - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, format, hfinfo->name, value); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -3428,7 +3424,7 @@ fill_label_uint64(field_info *fi, gchar *label_str) value = fvalue_get_integer64(&fi->value); /* Fill in the textual info */ - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, format, hfinfo->name, value); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -3447,7 +3443,7 @@ fill_label_enumerated_int(field_info *fi, gchar *label_str) value = fvalue_get_integer(&fi->value); /* Fill in the textual info */ - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, format, hfinfo->name, val_to_str(value, cVALS(hfinfo->strings), "Unknown"), value); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) @@ -3467,7 +3463,7 @@ fill_label_int(field_info *fi, gchar *label_str) value = fvalue_get_integer(&fi->value); /* Fill in the textual info */ - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, format, hfinfo->name, value); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -3486,7 +3482,7 @@ fill_label_int64(field_info *fi, gchar *label_str) value = fvalue_get_integer64(&fi->value); /* Fill in the textual info */ - ret = snprintf(label_str, ITEM_LABEL_LENGTH, + ret = g_snprintf(label_str, ITEM_LABEL_LENGTH, format, hfinfo->name, value); if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH)) label_str[ITEM_LABEL_LENGTH - 1] = '\0'; @@ -4442,7 +4438,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) dfilter_len = abbrev_len + 4 + 11 + 1; buf = g_malloc0(dfilter_len); format = hfinfo_numeric_format(hfinfo); - snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer(&finfo->value)); + g_snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer(&finfo->value)); break; case FT_INT64: @@ -4466,7 +4462,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) dfilter_len = abbrev_len + 4 + 22 + 1; buf = g_malloc0(dfilter_len); format = hfinfo_numeric_format(hfinfo); - snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer64(&finfo->value)); + g_snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer64(&finfo->value)); break; case FT_IPXNET: @@ -4478,7 +4474,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) */ dfilter_len = abbrev_len + 4 + 2 + 8 + 1; buf = g_malloc0(dfilter_len); - snprintf(buf, dfilter_len, "%s == 0x%08x", hfinfo->abbrev, + g_snprintf(buf, dfilter_len, "%s == 0x%08x", hfinfo->abbrev, fvalue_get_integer(&finfo->value)); break; @@ -4491,7 +4487,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) stringified = ip6_to_str((struct e_in6_addr*) fvalue_get(&finfo->value)); dfilter_len = abbrev_len + 4 + strlen(stringified) + 1; buf = g_malloc0(dfilter_len); - snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev, + g_snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev, stringified); break; @@ -4518,7 +4514,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt) buf = g_malloc0(dfilter_len); /* Create the string */ - snprintf(buf, dfilter_len, "%s == ", hfinfo->abbrev); + g_snprintf(buf, dfilter_len, "%s == ", hfinfo->abbrev); fvalue_to_string_repr(&finfo->value, FTREPR_DFILTER, &buf[abbrev_len + 4]); diff --git a/epan/tvbuff.c b/epan/tvbuff.c index f799e25c19..f1e6bc6045 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -1870,7 +1870,7 @@ tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengthp) * no more than bufsize number of bytes, including terminating NUL, to buffer. * Returns length of string (not including terminating NUL), or -1 if the string was * truncated in the buffer due to not having reached the terminating NUL. - * In this way, it acts like snprintf(). + * In this way, it acts like g_snprintf(). * * bufsize MUST be greater than 0. * @@ -1959,7 +1959,7 @@ _tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint bufsize, guint8* buffer, * no more than bufsize number of bytes, including terminating NUL, to buffer. * Returns length of string (not including terminating NUL), or -1 if the string was * truncated in the buffer due to not having reached the terminating NUL. - * In this way, it acts like snprintf(). + * In this way, it acts like g_snprintf(). * * When processing a packet where the remaining number of bytes is less * than bufsize, an exception is not thrown if the end of the packet diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 29504ebd5f..d7a64db654 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -460,7 +460,7 @@ extern guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengt * no more than bufsize number of bytes, including terminating NUL, to buffer. * Returns length of string (not including terminating NUL), or -1 if the string was * truncated in the buffer due to not having reached the terminating NUL. - * In this way, it acts like snprintf(). + * In this way, it acts like g_snprintf(). * * When processing a packet where the remaining number of bytes is less * than bufsize, an exception is not thrown if the end of the packet diff --git a/plugins/lwres/packet-lwres.c b/plugins/lwres/packet-lwres.c index 290f196ebc..b75b18ebc0 100644 --- a/plugins/lwres/packet-lwres.c +++ b/plugins/lwres/packet-lwres.c @@ -276,9 +276,9 @@ lwres_get_dns_name(tvbuff_t *tvb, int offset, int dns_data_offset, if (maxname > 0) { - print_len = snprintf(np, maxname + 1, "\\[x"); - if (print_len != -1) { - /* Some versions of snprintf return -1 if they'd truncate + print_len = g_snprintf(np, maxname + 1, "\\[x"); + if (print_len != -1 && print_len < maxname + 1) { + /* Some versions of g_snprintf return -1 if they'd truncate the output. */ np += print_len; maxname -= print_len; @@ -290,10 +290,10 @@ lwres_get_dns_name(tvbuff_t *tvb, int offset, int dns_data_offset, } while(label_len--) { if (maxname > 0) { - print_len = snprintf(np, maxname + 1, "%02x", + print_len = g_snprintf(np, maxname + 1, "%02x", tvb_get_guint8(tvb, offset)); - if (print_len != -1) { - /* Some versions of snprintf return -1 if they'd truncate + if (print_len != -1 && print_len < maxname + 1) { + /* Some versions of g_snprintf return -1 if they'd truncate the output. */ np += print_len; maxname -= print_len; @@ -306,9 +306,9 @@ lwres_get_dns_name(tvbuff_t *tvb, int offset, int dns_data_offset, offset++; } if (maxname > 0) { - print_len = snprintf(np, maxname + 1, "/%d]", bit_count); - if (print_len != -1) { - /* Some versions of snprintf return -1 if they'd truncate + print_len = g_snprintf(np, maxname + 1, "/%d]", bit_count); + if (print_len != -1 && print_len < maxname + 1) { + /* Some versions of g_snprintf return -1 if they'd truncate the output. */ np += print_len; maxname -= print_len; |