diff options
author | Hadriel Kaplan <hadriel@128technology.com> | 2014-12-22 19:14:49 -0500 |
---|---|---|
committer | Hadriel Kaplan <hadrielk@yahoo.com> | 2014-12-25 15:14:36 +0000 |
commit | ceeeea089ac68366d520eaf332fed4231ce8831e (patch) | |
tree | f5476eb52acb94bac95c40521e9d7337b28e5211 /epan/wslua | |
parent | 2391a436e60b4a1823be983583d5ef34a7faf6de (diff) |
Lua accessor for Protocol field type gets wrong data
When a Lua dissector/tap accesses the value of a Field of FT_PROTOCOL ftype, the
returned ByteArray contains the wrong data. Also, calling such a field's
tostring() method returns a string of "(unknown)" instead of the hex of the
data.
Bug: 10801
Change-Id: I8a0642dc0e41af444d211bbe4106cd21207084a6
Reviewed-on: https://code.wireshark.org/review/6003
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Hadriel Kaplan <hadrielk@yahoo.com>
Diffstat (limited to 'epan/wslua')
-rw-r--r-- | epan/wslua/wslua_field.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c index 7d9e625a24..b07e98aa1a 100644 --- a/epan/wslua/wslua_field.c +++ b/epan/wslua/wslua_field.c @@ -174,7 +174,6 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) { /* FALLTHROUGH */ case FT_BYTES: case FT_UINT_BYTES: - case FT_PROTOCOL: case FT_REL_OID: case FT_SYSTEM_ID: case FT_OID: @@ -185,6 +184,16 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) { pushByteArray(L,ba); return 1; } + case FT_PROTOCOL: + { + ByteArray ba = g_byte_array_new(); + tvbuff_t* tvb = (tvbuff_t *) fvalue_get(&fi->ws_fi->value); + g_byte_array_append(ba, (const guint8 *)tvb_memdup(wmem_packet_scope(), tvb, 0, + tvb_captured_length(tvb)), tvb_captured_length(tvb)); + pushByteArray(L,ba); + return 1; + } + case FT_GUID: default: luaL_error(L,"FT_ not yet supported"); @@ -198,9 +207,19 @@ WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) { FieldInfo fi = checkFieldInfo(L,1); if (fi->ws_fi->value.ftype->val_to_string_repr) { - gchar* repr = fvalue_to_string_repr(&fi->ws_fi->value,FTREPR_DISPLAY,NULL); + gchar* repr = NULL; + + if (fi->ws_fi->hfinfo->type == FT_PROTOCOL || fi->ws_fi->hfinfo->type == FT_PCRE) { + repr = fvalue_to_string_repr(&fi->ws_fi->value,FTREPR_DFILTER,NULL); + } + else { + repr = fvalue_to_string_repr(&fi->ws_fi->value,FTREPR_DISPLAY,NULL); + } + if (repr) { lua_pushstring(L,repr); + /* fvalue_to_string_repr() g_malloc's the string's buffer */ + g_free(repr); } else { lua_pushstring(L,"(unknown)"); |