From 1f026c23ef092a14ddb7c647ca306314cc107467 Mon Sep 17 00:00:00 2001 From: JonathanMeans Date: Thu, 12 Mar 2020 08:36:31 -0400 Subject: [PATCH 1/6] Compiled-in NITF_PLUGIN_PATH will not help users of binary release. Remind them to set NITF_PLUGIN_PATH if they need to --- modules/c/nitf/source/PluginRegistry.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/c/nitf/source/PluginRegistry.c b/modules/c/nitf/source/PluginRegistry.c index b905c315e..039c98ffa 100644 --- a/modules/c/nitf/source/PluginRegistry.c +++ b/modules/c/nitf/source/PluginRegistry.c @@ -262,8 +262,20 @@ NITFPRIV(nitf_PluginRegistry*) implicitConstruct(nitf_Error* error) if (!pluginEnvVar) { /* Take the default path */ - strcpy(reg->path, NITF_DEFAULT_PLUGIN_PATH); - return reg; + if (nrt_Directory_exists(NITF_DEFAULT_PLUGIN_PATH)) + { + strcpy(reg->path, NITF_DEFAULT_PLUGIN_PATH); + return reg; + } + else + { + fprintf(stderr, + "Warning: Unable to find plugin path. Specify plugin " + "location by setting environment variable %s," + " or by building the library from source\n", + NITF_PLUGIN_PATH); + return reg; + } } else { From 88769f7cff711fbc91a882f852248893b49ce881 Mon Sep 17 00:00:00 2001 From: JonathanMeans Date: Thu, 12 Mar 2020 08:40:40 -0400 Subject: [PATCH 2/6] Update README --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 84b8c5832..e54714a2e 100644 --- a/README.md +++ b/README.md @@ -212,9 +212,14 @@ of fixing it later, which will make me eternally grateful. NITF Library Users: General Issues ---------------------------------- -If you want to use the default TRE plugins that come with the library, -NITRO already knows where they are installed, and you don't have to -do anything. - -If you want to override this behavior, you can set the -`NITF_PLUGIN_PATH` environment variable to your preferred location. +NITRO handles TREs by loading dynamic libraries at runtime. Therefore, you need +to make sure NITRO can find them. + + - If you are building from source, the location will be compiled in, and + you don't have to do anything extra. + - If you are working from a binary release, you will have to tell + NITRO where the plugins are by setting the `NITF_PLUGIN_PATH` + enviornment variable. + This should look something like `/share/nitf/plugins`. + - If you wish to use a custom TRE location, you can also specify that + with `NITF_PLUGIN_PATH`. From 7aad17fec96a0a74c137c4fb44ef7904dd0d1c5a Mon Sep 17 00:00:00 2001 From: JonathanMeans Date: Thu, 12 Mar 2020 08:42:44 -0400 Subject: [PATCH 3/6] Formatting --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e54714a2e..f86ec00f9 100644 --- a/README.md +++ b/README.md @@ -215,11 +215,12 @@ NITF Library Users: General Issues NITRO handles TREs by loading dynamic libraries at runtime. Therefore, you need to make sure NITRO can find them. - - If you are building from source, the location will be compiled in, and - you don't have to do anything extra. - - If you are working from a binary release, you will have to tell +* If you are building from source, the location will be compiled in, and + you don't have to do anything extra. + +* If you are working from a binary release, you will have to tell NITRO where the plugins are by setting the `NITF_PLUGIN_PATH` enviornment variable. This should look something like `/share/nitf/plugins`. - - If you wish to use a custom TRE location, you can also specify that +* If you wish to use a custom TRE location, you can also specify that with `NITF_PLUGIN_PATH`. From 202fb656270e40e0f2bcd5652428584ce9ce479e Mon Sep 17 00:00:00 2001 From: JonathanMeans Date: Thu, 12 Mar 2020 08:43:32 -0400 Subject: [PATCH 4/6] Formatting --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f86ec00f9..b66ce646f 100644 --- a/README.md +++ b/README.md @@ -219,8 +219,9 @@ to make sure NITRO can find them. you don't have to do anything extra. * If you are working from a binary release, you will have to tell - NITRO where the plugins are by setting the `NITF_PLUGIN_PATH` - enviornment variable. - This should look something like `/share/nitf/plugins`. + NITRO where the plugins are by setting the `NITF_PLUGIN_PATH` + enviornment variable. + This should look something like `/share/nitf/plugins`. + * If you wish to use a custom TRE location, you can also specify that - with `NITF_PLUGIN_PATH`. + with `NITF_PLUGIN_PATH`. From 32376376e26489351c3fbddef0a0b6682f682385 Mon Sep 17 00:00:00 2001 From: JonathanMeans Date: Thu, 12 Mar 2020 08:45:57 -0400 Subject: [PATCH 5/6] Formatting --- modules/c/nitf/source/PluginRegistry.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/c/nitf/source/PluginRegistry.c b/modules/c/nitf/source/PluginRegistry.c index 039c98ffa..740bf7c8d 100644 --- a/modules/c/nitf/source/PluginRegistry.c +++ b/modules/c/nitf/source/PluginRegistry.c @@ -270,9 +270,9 @@ NITFPRIV(nitf_PluginRegistry*) implicitConstruct(nitf_Error* error) else { fprintf(stderr, - "Warning: Unable to find plugin path. Specify plugin " - "location by setting environment variable %s," - " or by building the library from source\n", + "Warning: Unable to find plugin path.\n" + "Specify plugin location by setting environment variable " + "%s, or by building the library from source\n", NITF_PLUGIN_PATH); return reg; } From e28ad0e288127504bb02d813037f6d2d5e4e32a9 Mon Sep 17 00:00:00 2001 From: JonathanMeans Date: Thu, 12 Mar 2020 09:14:46 -0400 Subject: [PATCH 6/6] strcpy -> strncpy --- modules/c/nitf/source/PluginRegistry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/c/nitf/source/PluginRegistry.c b/modules/c/nitf/source/PluginRegistry.c index 740bf7c8d..7c60179cc 100644 --- a/modules/c/nitf/source/PluginRegistry.c +++ b/modules/c/nitf/source/PluginRegistry.c @@ -264,7 +264,7 @@ NITFPRIV(nitf_PluginRegistry*) implicitConstruct(nitf_Error* error) /* Take the default path */ if (nrt_Directory_exists(NITF_DEFAULT_PLUGIN_PATH)) { - strcpy(reg->path, NITF_DEFAULT_PLUGIN_PATH); + strncpy(reg->path, NITF_DEFAULT_PLUGIN_PATH, NITF_MAX_PATH); return reg; } else @@ -279,7 +279,7 @@ NITFPRIV(nitf_PluginRegistry*) implicitConstruct(nitf_Error* error) } else { - strcpy(reg->path, pluginEnvVar); + strncpy(reg->path, pluginEnvVar, NITF_MAX_PATH); } /* * If the we have a user-defined path, they might not