Wireshark mailing list archives
Re: Reading a zero-terminated string in Lua dissector
From: Jeff Morriss <jeff.morriss.ws () gmail com>
Date: Mon, 04 Jun 2012 14:26:22 -0400
Carsten Fuchs wrote:
Hi Jeff, thanks for your reply. Am 2012-06-01 23:47, schrieb Jeff Morriss:To use 'string' fields you'll need to determine the string length first.'stringz' fields are strings that you're sure are NULL-terminated and so you should be able to use a length of -1 (which means "continue to the NULL terminator") but I'm not sure how that can be done in the Lua API (maybe you can just past -1 to the length inbuffer()?).Well, as I need the string length in order to progress my read offset into the buffer, I now just loop until I find the terminating NULL character, counting loop iterations.It's not particularly elegant (at least it feels so, remember that I'm still new to writing Wireshark dissectors), but I've now used it for a while and it works very well.
Hmm, yeah, that does seem a bit silly; there should be a better way. Maybe the Lua API needs an equivalent of tvb_strsize(). I don't know a lot about Lua so I wouldn't hazard such an enhancement so you might want to open a bug report (https://bugs.wireshark.org) so someone who does know it might code it up.
___________________________________________________________________________ Sent via: Wireshark-users mailing list <wireshark-users () wireshark org> Archives: http://www.wireshark.org/lists/wireshark-users Unsubscribe: https://wireshark.org/mailman/options/wireshark-users mailto:wireshark-users-request () wireshark org?subject=unsubscribe
Current thread:
- Re: Reading a zero-terminated string in Lua dissector Jeff Morriss (Jun 01)
- Re: Reading a zero-terminated string in Lua dissector Carsten Fuchs (Jun 04)
- Re: Reading a zero-terminated string in Lua dissector Jeff Morriss (Jun 04)
- <Possible follow-ups>
- Re: Reading a zero-terminated string in Lua dissector Tony Trinh (Jun 04)
- Re: Reading a zero-terminated string in Lua dissector Carsten Fuchs (Jun 05)
- Re: Reading a zero-terminated string in Lua dissector Carsten Fuchs (Jun 04)