This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Lua tostring(tvb(offset,8):le_int64()) returns a Big Endian result

2

Hi,

I am trying to use lua tvb_range:le_uint64() but it does not return the correct value when converted from userdata to a lua integer? It seems to always return tvb_range:int64()

The captured buffer contains; "aa c8 74 91 ba d2 4c 00"

local f.my_proto.fields
f.my_int64 = ProtoField.int64("my_proto.my_int64", "My Int 64", base.Dec)
tree:add_le(f.mt_int64, tvb(0,8))

This code correctly dissects the bytes and displays

"My Int 64: 216237969109738"

Then I try and convert the range from userdata to a lua integer

print (tvb(0,8):le_int64(), tvb(0,8):int64())
>-6140529922666247168 -6140529922666247168

print (tostring(tvb(0,8):le_int64()), tostring(tvb(0,8):int64()) >-6140529922666247168 -6140529922666247168

But it should return

print (tvb(0,8):le_int64(), tvb(0,8):int64())
>216237969109738  -6140529922666247168

Is there a bug in the le_uint64() function? I couldn’t find it in Bugzilla.

Thanks

OS: Centos 5.3 Wireshark 1.4.1 Lua 5.1

This question is marked “community wiki”.

asked 13 Nov ‘11, 19:48

mrb's gravatar image

mrb
16337
accept rate: 0%