Wireshark mailing list archives
Re: Reading a zero-terminated string in Lua dissector
From: Carsten Fuchs <carsten.fuchs () cafu de>
Date: Mon, 04 Jun 2012 09:05:27 +0200
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 in buffer()?).
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.
If anyone is interested, my current dissector code is at: http://trac.cafu.de/browser/cafu/trunk/Ca3DE/wireshark-cafu.lua Best regards, Carsten -- Cafu - the open-source Game and Graphics Engine for multiplayer, cross-platform, real-time 3D Action Learn more at http://www.cafu.de ___________________________________________________________________________ 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)