From abf3eaace8cf937b281e2ed5a2cccafb4ec5bf4e Mon Sep 17 00:00:00 2001 From: John Thacker Date: Wed, 28 Oct 2020 15:30:12 -0400 Subject: [PATCH] Encodings: Add FT_STRINGZ support for GB18030, EUC-KR --- epan/tvbuff.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 5bdeb22090..df44f60955 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -3289,6 +3289,34 @@ tvb_get_t61_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *l return get_t61_string(scope, ptr, size); } +static guint8 * +tvb_get_gb18030_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *lengthp) +{ + guint size; + const guint8 *ptr; + + size = tvb_strsize(tvb, offset); + ptr = ensure_contiguous(tvb, offset, size); + /* XXX, conversion between signed/unsigned integer */ + if (lengthp) + *lengthp = size; + return get_gb18030_string(scope, ptr, size); +} + +static guint8 * +tvb_get_euc_kr_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *lengthp) +{ + guint size; + const guint8 *ptr; + + size = tvb_strsize(tvb, offset); + ptr = ensure_contiguous(tvb, offset, size); + /* XXX, conversion between signed/unsigned integer */ + if (lengthp) + *lengthp = size; + return get_euc_kr_string(scope, ptr, size); +} + guint8 * tvb_get_stringz_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding) { @@ -3463,6 +3491,14 @@ tvb_get_stringz_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, g case ENC_T61: strptr = tvb_get_t61_stringz(scope, tvb, offset, lengthp); break; + + case ENC_GB18030: + strptr = tvb_get_gb18030_stringz(scope, tvb, offset, lengthp); + break; + + case ENC_EUC_KR: + strptr = tvb_get_euc_kr_stringz(scope, tvb, offset, lengthp); + break; } return strptr;