Ask Your Question
0

tvbrange:raw() returns more bytes then expected

asked 2020-11-20 10:45:41 +0000

BobH gravatar image

updated 2020-11-20 10:46:29 +0000

I have this lua dissector using:

s = buffer(1, len):raw()

But the result is that s contains all data in buffer, i.e. looks like to ignore the len parameter.

When I modify this to:

s = buffer(1, len):tvb():raw() it works.

Can this be explained or am I doing something wrong?

edit retag flag offensive close merge delete

Comments

What is buffer, how is it created?

grahamb gravatar imagegrahamb ( 2020-11-20 11:13:34 +0000 )edit

buffer is the first parameter for the dissector (company coding standard):

-- Create a function to dissect it function myprotocol.dissector(buffer, pinfo, tree )

BobH gravatar imageBobH ( 2020-11-20 14:10:15 +0000 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-11-20 15:44:58 +0000

Jaap gravatar image

A quick look at epan/wslua/wslua_tvb.c seems to show that TvbRange_raw() works with the underlying TVB based on the parameters passed into this functions, not based on the boundaries set by the creation of the TvbRange.

When looking at TvbRange_tvb() a actual new TVB is created, based on the given boundaries set by the creation of the TvbRange. So taking raw() from that new Tvb does yield the desired result.

So yes, this can be explained, and no, you're not doing something wrong. You just happened to find the workaround.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-11-20 10:45:41 +0000

Seen: 216 times

Last updated: Nov 20 '20