aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-quake3.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-04-12 15:26:34 -0700
committerGuy Harris <guy@alum.mit.edu>2014-04-12 22:27:22 +0000
commitcb16dff992c3844936bf5829f19e5a5247458503 (patch)
tree901b7be3379f5b94f150de71d1c0f3e2fa2d12e4 /epan/dissectors/packet-quake3.c
parentef8a0a2ce172810d48371eb65c73b1bd4a6303ca (diff)
Get rid of more tvb_get_nstringz* calls.
Add an FT_STRINGZPAD type, for null-padded strings (typically fixed-length fields, where the string can be up to the length of the field, and is null-padded if it's shorter than that), and use it. Use IS_FT_STRING() in more cases, so that less code needs to know what types are string types. Add a tvb_get_stringzpad() routine, which gets null-padded strings. Currently, it does the same thing that tvb_get_string_enc() does, but that might change if we don't store string values as null-terminated strings. Change-Id: I46f56e130de8f419a19b56ded914e24cc7518a66 Reviewed-on: https://code.wireshark.org/review/1082 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-quake3.c')
-rw-r--r--epan/dissectors/packet-quake3.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/epan/dissectors/packet-quake3.c b/epan/dissectors/packet-quake3.c
index c9d5fad22d..3b8bfc328f 100644
--- a/epan/dissectors/packet-quake3.c
+++ b/epan/dissectors/packet-quake3.c
@@ -144,7 +144,7 @@ dissect_quake3_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *cl_tree = NULL;
proto_item *text_item = NULL;
proto_tree *text_tree = NULL;
- guint8 text[2048];
+ guint8 *text;
int len;
int offset;
guint32 marker;
@@ -165,11 +165,21 @@ dissect_quake3_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_,
/* all the rest of the packet is just text */
offset = 4;
- len = tvb_get_nstringz0(tvb, offset, sizeof(text), text);
+ /*
+ * XXX - is there ever more than one null-terminated string in
+ * the packet?
+ *
+ * XXX - is the string guaranteed to be null-terminated (so
+ * that if there's no NUL at the end, it's an error)?
+ *
+ * XXX - are non-ASCII characters supported and, if so, what
+ * encoding is used for them?
+ */
+ text = tvb_get_stringz_enc(wmem_packet_scope(), tvb, offset, &len, ENC_ASCII|ENC_NA);
if (cl_tree) {
text_item = proto_tree_add_string(cl_tree,
hf_quake3_connectionless_text,
- tvb, offset, len + 1, text);
+ tvb, offset, len, text);
text_tree = proto_item_add_subtree(text_item, ett_quake3_connectionless_text);
}
@@ -321,7 +331,7 @@ dissect_quake3_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_,
val_to_str_const(command, names_command, "Unknown"));
}
- /*offset += len + 1;*/
+ /*offset += len;*/
}