aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dns.c
diff options
context:
space:
mode:
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2005-10-16 00:27:50 +0000
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2005-10-16 00:27:50 +0000
commit9e235eff147265a1bfdd31aa8d0490a882b60525 (patch)
tree0f6f505dd10a9129bffc602a09f41f667bfcb9f0 /epan/dissectors/packet-dns.c
parent7db5c78e43f5bbbc41c17f1c69bd1e753aa87b92 (diff)
remove one array from the stack
get rid of strcpy and strcat git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16235 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-dns.c')
-rw-r--r--epan/dissectors/packet-dns.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c
index 8b850e1f41..a152caefa3 100644
--- a/epan/dissectors/packet-dns.c
+++ b/epan/dissectors/packet-dns.c
@@ -2295,7 +2295,8 @@ dissect_dns_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree *dns_tree = NULL, *field_tree;
proto_item *ti, *tf;
guint16 id, flags, opcode, rcode, quest, ans, auth, add;
- char buf[128+1];
+ char *buf;
+ int bufpos;
int cur_off;
gboolean isupdate;
@@ -2304,6 +2305,11 @@ dissect_dns_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->cinfo, COL_INFO))
col_clear(pinfo->cinfo, COL_INFO);
+#define MAX_BUF_SIZE (128+1)
+ buf=ep_alloc(MAX_BUF_SIZE);
+ buf[0]=0;
+ bufpos=0;
+
/* To do: check for errs, etc. */
id = tvb_get_ntohs(tvb, offset + DNS_ID);
flags = tvb_get_ntohs(tvb, offset + DNS_FLAGS);
@@ -2311,13 +2317,15 @@ dissect_dns_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
rcode = (guint16) (flags & F_RCODE);
if (check_col(pinfo->cinfo, COL_INFO)) {
- strcpy(buf, val_to_str(opcode, opcode_vals, "Unknown operation (%u)"));
+ bufpos=0;
+ bufpos+=g_snprintf(buf+bufpos, MAX_BUF_SIZE-bufpos, "%s%s",
+ val_to_str(opcode, opcode_vals, "Unknown operation (%u)"),
+ (flags&F_RESPONSE)?" response":"");
+
if (flags & F_RESPONSE) {
- strcat(buf, " response");
if ((flags & F_RCODE) != RCODE_NOERROR) {
- strcat(buf, ", ");
- strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
- "Unknown error (%u)"));
+ bufpos+=g_snprintf(buf+bufpos, MAX_BUF_SIZE-bufpos, ", %s",
+ val_to_str(flags & F_RCODE, rcode_vals, "Unknown error (%u)"));
}
}
col_add_str(pinfo->cinfo, COL_INFO, buf);
@@ -2348,12 +2356,12 @@ dissect_dns_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree_add_uint(dns_tree, hf_dns_transaction_id, tvb,
offset + DNS_ID, 2, id);
- strcpy(buf, val_to_str(opcode, opcode_vals, "Unknown operation"));
+ bufpos=0;
+ bufpos+=g_snprintf(buf+bufpos, MAX_BUF_SIZE-bufpos, "%s",
+ val_to_str(opcode, opcode_vals, "Unknown operation"));
if (flags & F_RESPONSE) {
- strcat(buf, " response");
- strcat(buf, ", ");
- strcat(buf, val_to_str(flags & F_RCODE, rcode_vals,
- "Unknown error"));
+ bufpos+=g_snprintf(buf+bufpos, MAX_BUF_SIZE-bufpos, " response, %s",
+ val_to_str(flags & F_RCODE, rcode_vals, "Unknown error"));
}
tf = proto_tree_add_uint_format(dns_tree, hf_dns_flags, tvb,
offset + DNS_FLAGS, 2,