Wireshark mailing list archives
Re: epan_base64_decode(): failure when string contains a NUL character
From: Uli Heilmeier <zeugs () heilmeier eu>
Date: Wed, 24 Apr 2013 21:09:03 +0200
Am 21.04.13 22:29, schrieb Evan Huus:
There is only one issue left: How can I split up this string. The g_strsplit() function seems to don't accept NULL as a delimiter.It depends what you need the results for. If you just need them separated by a NULL then they're already in that state, you can just use strlen and pointer arithmetic.
Yeah, your right. This way it was easy to split up the data. Thanks a lot for this tip. I added the patch to bug 8600.
If you need discrete copies of each substring in their own memory space you can just do the above and then strdup them. A word of warning though: be sure to sanity check everything, as you can't assume that the string coming out of the packet will be sane, or will contain the correct number of NULLs (it may not contain any NULLs at all, in which case just calling strlen will run past the end of the buffer). Also be sure to use managed memory (see doc/README.wmem) unless you have a specific reason not to.
Thanks for the warning. I hope I added the right checks to my code. Cheers Uli ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- epan_base64_decode(): failure when string contains a NUL character Uli Heilmeier (Apr 17)
- Re: epan_base64_decode(): failure when string contains a NUL character Evan Huus (Apr 17)
- Re: epan_base64_decode(): failure when string contains a NUL character Jakub Zawadzki (Apr 20)
- Re: epan_base64_decode(): failure when string contains a NUL character Uli Heilmeier (Apr 21)
- Re: epan_base64_decode(): failure when string contains a NUL character Evan Huus (Apr 21)
- Re: epan_base64_decode(): failure when string contains a NUL character Uli Heilmeier (Apr 24)
- Re: epan_base64_decode(): failure when string contains a NUL character Uli Heilmeier (Apr 21)