ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Best way to handle a variable-length NULL-terminated string

From: "Maynard, Chris" <Christopher.Maynard@xxxxxxxxx>
Date: Mon, 3 May 2010 11:32:51 -0400
Maybe this is what you're looking for?

>From epan/tvbuff.h:

/** Find size of stringz (NUL-terminated string) by looking for terminating
 * NUL.  The size of the string includes the terminating NUL.
 *
 * If the NUL isn't found, it throws the appropriate exception.
 */
extern guint tvb_strsize(tvbuff_t *tvb, const gint offset);

- Chris

-----Original Message-----
From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Jeremy O'Brien
Sent: Monday, May 03, 2010 11:14 AM
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] Best way to handle a variable-length NULL-terminated string in a tvb

Actually, is there a function that will just get the length of said
string? I don't need to do anything with the string itself other than
add it to the proto_tree and of course increment my offset. I know I
could just g_free the string immediately after fetching it, but this
seems like it has a little overhead.

[snip]

CONFIDENTIALITY NOTICE: The contents of this email are confidential
and for the exclusive use of the intended recipient. If you receive this
email in error, please delete it from your system immediately and 
notify us either by email, telephone or fax. You should not copy,
forward, or otherwise disclose the content of the email.