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>
This commit is contained in:
Hadriel Kaplan 2014-12-22 19:14:49 -05:00 committed by Hadriel Kaplan
parent 2391a436e6
commit ceeeea089a
1 changed files with 21 additions and 2 deletions

View File

@ -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)");