aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-12-13 22:35:50 +0000
committerGuy Harris <guy@alum.mit.edu>2013-12-13 22:35:50 +0000
commit30ab019f2b8ef698cdcae17e3659d49b9d1ada5d (patch)
treed4a7b8d68697e9e75098d5c6b4edb34ab4acb076
parentbbc3e14642e63c3d393d4b632ef81f3b16fbcafc (diff)
In tvb_get_unicode_string(), if the byte count is odd, ignore the last
byte. (We should perhaps add an expert info indication in those cases.) svn path=/trunk/; revision=54074
-rw-r--r--epan/tvbuff.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 70a0c2150e..421b55662c 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -1884,7 +1884,7 @@ tvb_get_unicode_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset
strbuf = wmem_strbuf_new(scope, NULL);
- for(i = 0; i < length; i += 2) {
+ for(i = 0; i + 1 < length; i += 2) {
if (encoding == ENC_BIG_ENDIAN)
uchar = tvb_get_ntohs(tvb, offset + i);
else
@@ -1893,6 +1893,10 @@ tvb_get_unicode_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset
wmem_strbuf_append_unichar(strbuf, uchar);
}
+ /*
+ * XXX - if i < length, this means we were handed an odd
+ * number of bytes, so we're not a valid UCS-2 string.
+ */
return (gchar*)wmem_strbuf_get_str(strbuf);
}