Almost forgot to post solution. The matter is that my dissector don't cover cases of null application protocol payload, and thats why i got these errors. The solution is to add one "if" statement, that checks out length of the payload.
bad argument #1 to 'get_index' (index out of range) in Wireshark Lua dissector
-
10-10-2022 - |
Frage
In my dissector I have this code
local defaultdata = data_tvb():bytes()
local newdata = ByteArray.new()
newdata:set_size(defaultdata:len())
for i=0,defaultdata:len()-2 do
local var = bit.band((bit.lshift(defaultdata:get_index(i), 1) + bit.rshift(defaultdata:get_index(i+1), 7)), 0xff)
newdata:set_index(i, var) end
local var = bit.band((bit.lshift(defaultdata:get_index(defaultdata:len()-1), 1) + bit.rshift(defaultdata:get_index(0), 7)), 0xff)
newdata:set_index(defaultdata:len()-1,var)
data_tvb = ByteArray.tvb(newdata, "Decoded") end
My problem is in second bitwise operation in get_index
function.
I know, that problem might be in get_index(0)
or get_index(defaultdata:len()-1)
because in Lua there is no element of the zero index(not that of C) but nothing actually works with another values.
With any values I got this message: bad argument #1 to 'get_index' (index out of range)
So, as I mentioned above, part, that not depend on this code work correctly.
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow