forked from osmocom/wireshark
From Sebastien Tandel:
Create two new files (ws_strsplit.[ch]) that use GTK2 code to override the buggy g_strsplit() function when compiling for GTK1. Include this work-around function (ws_strsplit) in libwireshark.def. Add notes on usage to README.developer. Include epan/ws_strsplit.h in all files that use g_strsplit(). svn path=/trunk/; revision=20804
This commit is contained in:
parent
1ebd7feda9
commit
0ebc01dc03
|
@ -433,6 +433,12 @@ automatically free()d when the dissection of the current packet ends so you
|
|||
don't have to worry about free()ing them explicitly in order to not leak memory.
|
||||
Please read README.malloc.
|
||||
|
||||
When using g_strsplit() from glib, place an #include <epan/ws_strsplit.h> at
|
||||
the top of your file. This file will leave in place g_strsplit() when using
|
||||
GTK/GLib v2 and replace it with GLib v2 code when compiling for GTK/GLib 1.
|
||||
This is necessary because the GLib v1 version of g_strsplit is known to be
|
||||
buggy. In either case, you will still use the g_strsplit() function name
|
||||
as usual in your code.
|
||||
|
||||
1.1.3 Robustness.
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ LIBWIRESHARK_SRC = \
|
|||
uat_load.c \
|
||||
unicode-utils.c \
|
||||
value_string.c \
|
||||
ws_strsplit.c \
|
||||
xdlc.c \
|
||||
xmlstub.c
|
||||
|
||||
|
@ -190,6 +191,7 @@ LIBWIRESHARK_INCLUDES = \
|
|||
uat-int.h \
|
||||
unicode-utils.h \
|
||||
value_string.h \
|
||||
ws_strsplit.h \
|
||||
x264_prt_id.h \
|
||||
xdlc.h \
|
||||
xmlstub.h
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <epan/tvbuff.h>
|
||||
#include <epan/crc32.h>
|
||||
#include <epan/strutil.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#include "airpdcap_system.h"
|
||||
#include "airpdcap_int.h"
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <epan/base64.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/stats_tree.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#include <epan/req_resp_hdrs.h>
|
||||
#include "packet-http.h"
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <epan/prefs.h>
|
||||
#include <epan/tap.h>
|
||||
#include <epan/emem.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#include "packet-jxta.h"
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <epan/strutil.h>
|
||||
#include "packet-sscop.h"
|
||||
#include "packet-umts_fp.h"
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
typedef struct _k12_hdls_t {
|
||||
char* match;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include "ex-opt.h"
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
static GHashTable* ex_opts = NULL;
|
||||
|
||||
|
|
|
@ -802,4 +802,5 @@ vals_status DATA
|
|||
val_to_str
|
||||
value_is_in_range
|
||||
write_prefs
|
||||
ws_strsplit
|
||||
xml_escape
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <epan/stats_tree_priv.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "stats_tree.h"
|
||||
|
@ -541,48 +542,42 @@ extern guint8* stats_tree_get_abbr(const guint8* optarg) {
|
|||
*
|
||||
*/
|
||||
static range_pair_t* get_range(guint8* rngstr) {
|
||||
gchar** split;
|
||||
range_pair_t* rng;
|
||||
|
||||
split = g_strsplit((gchar*)rngstr,"-",2);
|
||||
gchar** split;
|
||||
range_pair_t* rng;
|
||||
|
||||
/* empty string */
|
||||
if (split[0] == NULL) {
|
||||
g_strfreev(split);
|
||||
return NULL;
|
||||
}
|
||||
split = g_strsplit((gchar*)rngstr,"-",2);
|
||||
|
||||
#if GLIB_MAJOR_VERSION >= 2
|
||||
/* means we have a non empty string
|
||||
* which does not contain a delimiter */
|
||||
if (split[1] == NULL) {
|
||||
g_strfreev(split);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
/* empty string */
|
||||
if (split[0] == NULL) {
|
||||
g_strfreev(split);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rng = g_malloc(sizeof(range_pair_t));
|
||||
/* means we have a non empty string
|
||||
* which does not contain a delimiter */
|
||||
if (split[1] == NULL) {
|
||||
g_strfreev(split);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* string == "X-?" */
|
||||
if (*(split[0]) != '\0') {
|
||||
rng->floor = strtol(split[0],NULL,10);
|
||||
} else
|
||||
/* string == "-?" */
|
||||
rng->floor = G_MININT;
|
||||
rng = g_malloc(sizeof(range_pair_t));
|
||||
|
||||
/* string == "X-?" */
|
||||
if (*(split[0]) != '\0') {
|
||||
rng->floor = strtol(split[0],NULL,10);
|
||||
} else
|
||||
/* string == "-?" */
|
||||
rng->floor = G_MININT;
|
||||
|
||||
/* string != "?-" */
|
||||
if (*(split[1]) != '\0') {
|
||||
rng->ceil = strtol(split[1],NULL,10);
|
||||
} else
|
||||
/* string == "?-" */
|
||||
rng->ceil = G_MAXINT;
|
||||
|
||||
g_strfreev(split);
|
||||
|
||||
/* string != "?-" */
|
||||
#if GLIB_MAJOR_VERSION >= 2
|
||||
if (*(split[1]) != '\0') {
|
||||
#else
|
||||
if (split[1] != NULL) {
|
||||
#endif
|
||||
rng->ceil = strtol(split[1],NULL,10);
|
||||
} else
|
||||
/* string == "?-" */
|
||||
rng->ceil = G_MAXINT;
|
||||
|
||||
g_strfreev(split);
|
||||
|
||||
return rng;
|
||||
}
|
||||
|
||||
|
@ -595,7 +590,7 @@ extern int stats_tree_create_range_node(stats_tree* st,
|
|||
guint8* curr_range;
|
||||
stat_node* rng_root = new_stat_node(st, name, parent_id, FALSE, TRUE);
|
||||
stat_node* range_node = NULL;
|
||||
|
||||
|
||||
va_start( list, parent_id );
|
||||
while (( curr_range = va_arg(list, guint8*) )) {
|
||||
range_node = new_stat_node(st, curr_range, rng_root->id, FALSE, FALSE);
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/* ws_strsplit.c
|
||||
* String Split utility function
|
||||
* Code borrowed from GTK2 to override the GTK1 version of g_strsplit, which is
|
||||
* known to be buggy.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#if GLIB_MAJOR_VERSION < 2
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
|
||||
gchar** ws_strsplit ( const gchar *string,
|
||||
const gchar *delimiter,
|
||||
gint max_tokens)
|
||||
{
|
||||
GSList *string_list = NULL, *slist;
|
||||
gchar **str_array, *s;
|
||||
guint n = 0;
|
||||
const gchar *remainder;
|
||||
|
||||
g_return_val_if_fail (string != NULL, NULL);
|
||||
g_return_val_if_fail (delimiter != NULL, NULL);
|
||||
g_return_val_if_fail (delimiter[0] != '\0', NULL);
|
||||
|
||||
if (max_tokens < 1)
|
||||
max_tokens = G_MAXINT;
|
||||
|
||||
remainder = string;
|
||||
s = strstr (remainder, delimiter);
|
||||
if (s) {
|
||||
gsize delimiter_len = strlen (delimiter);
|
||||
|
||||
while (--max_tokens && s) {
|
||||
gsize len;
|
||||
gchar *new_string;
|
||||
|
||||
len = s - remainder;
|
||||
new_string = g_new (gchar, len + 1);
|
||||
strncpy (new_string, remainder, len);
|
||||
new_string[len] = 0;
|
||||
string_list = g_slist_prepend (string_list, new_string);
|
||||
n++;
|
||||
remainder = s + delimiter_len;
|
||||
s = strstr (remainder, delimiter);
|
||||
}
|
||||
}
|
||||
if (*string) {
|
||||
n++;
|
||||
string_list = g_slist_prepend (string_list, g_strdup (remainder));
|
||||
}
|
||||
|
||||
str_array = g_new (gchar*, n + 1);
|
||||
|
||||
str_array[n--] = NULL;
|
||||
for (slist = string_list; slist; slist = slist->next)
|
||||
str_array[n--] = slist->data;
|
||||
|
||||
g_slist_free (string_list);
|
||||
|
||||
return str_array;
|
||||
}
|
||||
|
||||
#endif /* GLIB_MAJOR_VERSION */
|
|
@ -0,0 +1,41 @@
|
|||
/* ws_strsplit.h
|
||||
* String Split utility function
|
||||
* Code borrowed from GTK2 to override the GTK1 version of g_strsplit, which is
|
||||
* known to be buggy.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __WS_STRSPLIT_H__
|
||||
#define __WS_STRSPLIT_H__
|
||||
|
||||
#if GLIB_MAJOR_VERSION < 2
|
||||
|
||||
#define g_strsplit(s, d, t) ws_strsplit(s, d, t)
|
||||
|
||||
gchar ** ws_strsplit (const gchar *string,
|
||||
const gchar *delimiter,
|
||||
gint max_tokens);
|
||||
|
||||
#endif /* GLIB_MAJOR_VERSION */
|
||||
|
||||
#endif /* __WS_STRSPLIT_H__ */
|
||||
|
|
@ -32,6 +32,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include <epan/dissectors/packet-t38.h>
|
||||
#include <epan/conversation.h>
|
||||
#include <epan/rtp_pt.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#include "alert_box.h"
|
||||
#include "simple_dialog.h"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/filesystem.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include "webbrowser.h"
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "mate.h"
|
||||
#include "mate_grammar.h"
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
#define DUMMY void*
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "mate.h"
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
/* the current mate_config */
|
||||
static mate_config* matecfg = NULL;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "mate.h"
|
||||
#include "mate_util.h"
|
||||
#include <wiretap/file_util.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
/***************************************************************************
|
||||
* dbg_print
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <epan/funnel.h>
|
||||
#include <stdio.h>
|
||||
#include <epan/stat_cmd_args.h>
|
||||
#include <epan/ws_strsplit.h>
|
||||
|
||||
|
||||
struct _funnel_text_window_t {
|
||||
|
|
Loading…
Reference in New Issue