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

Wireshark-bugs: [Wireshark-bugs] [Bug 6131] Tshark custom columns: Why don't I get an error mess

Date: Sat, 16 Jul 2011 07:48:42 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6131

Joke Snelders <j.snelders@xxxxxxxxxx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |j.snelders@xxxxxxxxxx

--- Comment #1 from Joke Snelders <j.snelders@xxxxxxxxxx> 2011-07-16 07:48:41 PDT ---
Here is the answer from helloworld:

http://ask.wireshark.org/questions/5069/tshark-custom-columns-why-dont-i-get-an-error-message

The bug is that prefs.c:2044 and prefs.c:2069 compare only the first few
characters of "%Custttttttttttttt", which match the expected string (%Cus):

const gchar *cust_format = col_format_to_string(COL_CUSTOM);
size_t cust_format_len = strlen(cust_format);
//...
if (strncmp(col_l_elt->data, cust_format, cust_format_len) == 0) {
        cfmt->fmt      = g_strdup(cust_format);
        prefs_fmt      = g_strdup(col_l_elt->data);
        cust_format_info = g_strsplit(&prefs_fmt[cust_format_len+1],":",3); /*
add 1 for ':' */
        cfmt->custom_field = g_strdup(cust_format_info[0]);
//....

If we add 1 to cust_format_len, the string comparison would include the null
terminator in cust_format, which would cause the desired syntax error:

if (strncmp(col_l_elt->data, cust_format, cust_format_len+1) == 0) {
//...

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.