aboutsummaryrefslogtreecommitdiffstats
path: root/epan/oids.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2018-03-19 22:46:49 +0100
committerAnders Broman <a.broman58@gmail.com>2018-03-24 07:07:14 +0000
commit2f34f262038de32c4a39cf11a164551cd0633773 (patch)
treead0a37e7431bc07651b77782940add123081b51e /epan/oids.c
parent98b46985dd5903db2b89219b1eb480620f342d17 (diff)
OID name resolv: Fix MIB/PIB path presentations
oids.c: Sort out libsmi init, add user paths once. Qt, About WS: Stop memory leak of MIB/PIB paths. GTK, About WS: Allow for 20 individual paths. tshark, folders: init before getting paths, allow 20 individual. Bug: 14539 Change-Id: I113ee2dd4394d553a16b256e66fd840eeeec78ef Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/26555 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/oids.c')
-rw-r--r--epan/oids.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/epan/oids.c b/epan/oids.c
index 28ea769d83..b30ed2d084 100644
--- a/epan/oids.c
+++ b/epan/oids.c
@@ -30,6 +30,7 @@
#ifdef HAVE_LIBSMI
#include <smi.h>
+static gboolean smi_init_done = FALSE;
static gboolean oids_init_done = FALSE;
static gboolean load_smi_modules = FALSE;
static gboolean suppress_smi_errors = FALSE;
@@ -533,14 +534,13 @@ static void register_mibs(void) {
if (oids_init_done) {
D(1,("Exiting register_mibs() to avoid double registration of MIBs proto."));
return;
- } else {
- oids_init_done = TRUE;
}
hfa = wmem_array_new(wmem_epan_scope(), sizeof(hf_register_info));
etta = g_array_new(FALSE,TRUE,sizeof(gint*));
smiInit(NULL);
+ smi_init_done = TRUE;
smi_errors = g_string_new("");
smiSetErrorHandler(smi_error_handler);
@@ -734,6 +734,8 @@ static void register_mibs(void) {
proto_register_subtree_array((gint**)(void*)etta->data, etta->len);
g_array_free(etta,TRUE);
+
+ oids_init_done = TRUE;
}
#endif
@@ -1263,10 +1265,9 @@ oid_get_default_mib_path(void) {
if (!load_smi_modules) {
D(1,("OID resolution not enabled"));
- return path_str->str;
+ return g_string_free(path_str, FALSE);
}
#ifdef _WIN32
-#define PATH_SEPARATOR ";"
path = get_datafile_path("snmp\\mibs");
g_string_append_printf(path_str, "%s;", path);
g_free (path);
@@ -1275,23 +1276,28 @@ oid_get_default_mib_path(void) {
g_string_append_printf(path_str, "%s", path);
g_free (path);
#else
-#define PATH_SEPARATOR ":"
- path = smiGetPath();
g_string_append(path_str, "/usr/share/snmp/mibs");
+ if (!smi_init_done)
+ smiInit(NULL);
+ path = smiGetPath();
if (strlen(path) > 0 ) {
- g_string_append(path_str, PATH_SEPARATOR);
+ g_string_append(path_str, G_SEARCHPATH_SEPARATOR_S);
+ g_string_append_printf(path_str, "%s", path);
}
- g_string_append_printf(path_str, "%s", path);
smi_free(path);
-#endif
- for(i=0;i<num_smi_paths;i++) {
- if (!( smi_paths[i].name && *smi_paths[i].name))
- continue;
+ if (oids_init_done == FALSE)
+ {
+#endif
+ for (i = 0; i < num_smi_paths; i++) {
+ if (!(smi_paths[i].name && *smi_paths[i].name))
+ continue;
- g_string_append_printf(path_str,PATH_SEPARATOR "%s",smi_paths[i].name);
+ g_string_append_printf(path_str, G_SEARCHPATH_SEPARATOR_S "%s", smi_paths[i].name);
+ }
+#ifndef _WIN32
}
-
+#endif
return g_string_free(path_str, FALSE);
#else /* HAVE_LIBSMI */
return g_strdup("");