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: