aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ber.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2009-04-03 16:53:40 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2009-04-03 16:53:40 +0000
commit1a6a9554cb4f0cbb8864a7d1c3c10d9e4e3658a2 (patch)
treed2646f517938ff124cef72eab02c26064b0e3a21 /epan/dissectors/packet-ber.c
parent7558bdf7c420cd0418bad257cada9b56b4a9f2b3 (diff)
Don't reply on an argument of -1 as the last argument of tvb_memcpy()
meaning "to the end of the tvbuff"; we'd like to get rid of the "-1 means to the end of the tvbuff" convention, as in many cases the length comes from a 32-bit length field in the packet, and we want 0xFFFFFFFF to be treated, even on ILP32 platforms, as meaning "2^32-1 bytes", probably giving an exception, rather than as "to the end of the packet". git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27945 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-ber.c')
-rw-r--r--epan/dissectors/packet-ber.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index d300e8570c..6153d239be 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -3081,16 +3081,25 @@ int
dissect_ber_GeneralString(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *name_string, guint name_len)
{
tvbuff_t *out_tvb = NULL;
+ gint tvb_len;
offset = dissect_ber_restricted_string(FALSE, BER_UNI_TAG_GeneralString, actx, tree, tvb, offset, hf_id, (name_string)?&out_tvb:NULL);
if(name_string) {
- if(out_tvb && tvb_length(out_tvb) >= name_len) {
- tvb_memcpy(out_tvb, (guint8*)name_string, 0, name_len-1);
- name_string[name_len-1] = '\0';
- } else if(out_tvb) {
- tvb_memcpy(out_tvb, (guint8*)name_string, 0, -1);
- name_string[tvb_length(out_tvb)] = '\0';
+ /*
+ * XXX - do we want to just get what's left in the tvbuff
+ * if the full length isn't available in the tvbuff, or
+ * do we want to throw an exception?
+ */
+ if(out_tvb) {
+ tvb_len = tvb_length(out_tvb);
+ if(tvb_len >= name_len) {
+ tvb_memcpy(out_tvb, (guint8*)name_string, 0, name_len-1);
+ name_string[name_len-1] = '\0';
+ } else {
+ tvb_memcpy(out_tvb, (guint8*)name_string, 0, tvb_len);
+ name_string[tvb_len] = '\0';
+ }
}
}