aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/Makefile.am9
-rw-r--r--src/libcharon/daemon.c7
-rw-r--r--src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap_msg.c9
-rw-r--r--src/libimcv/ietf/ietf_attr_op_status.c4
-rw-r--r--src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.c4
-rw-r--r--src/libstrongswan/Makefile.am10
-rw-r--r--src/libstrongswan/asn1/asn1.c16
-rw-r--r--src/libstrongswan/library.c13
-rw-r--r--src/libstrongswan/plugins/pem/pem_builder.c6
-rw-r--r--src/libstrongswan/plugins/plugin_constructors.py60
-rw-r--r--src/libstrongswan/plugins/plugin_loader.c85
-rw-r--r--src/libstrongswan/plugins/plugin_loader.h10
-rw-r--r--src/libstrongswan/plugins/x509/x509_cert.c32
-rw-r--r--src/libstrongswan/processing/processor.c13
-rw-r--r--src/libstrongswan/utils/chunk.c2
-rw-r--r--src/libtnccs/Makefile.am9
-rw-r--r--src/libtnccs/tnc/tnc.c7
-rw-r--r--src/libtpmtss/Makefile.am9
-rw-r--r--src/libtpmtss/tpm_tss.c7
19 files changed, 280 insertions, 32 deletions
diff --git a/src/libcharon/Makefile.am b/src/libcharon/Makefile.am
index 8461d6230..3fcaedc3b 100644
--- a/src/libcharon/Makefile.am
+++ b/src/libcharon/Makefile.am
@@ -184,6 +184,15 @@ if USE_ME
sa/ikev2/tasks/ike_me.c sa/ikev2/tasks/ike_me.h
endif
+if STATIC_PLUGIN_CONSTRUCTORS
+BUILT_SOURCES = $(srcdir)/plugin_constructors.c
+CLEANFILES = $(srcdir)/plugin_constructors.c
+
+$(srcdir)/plugin_constructors.c: $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py
+ $(AM_V_GEN) \
+ $(PYTHON) $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py ${c_plugins} > $@
+endif
+
# build optional plugins
########################
diff --git a/src/libcharon/daemon.c b/src/libcharon/daemon.c
index eadc10a6a..8daea783f 100644
--- a/src/libcharon/daemon.c
+++ b/src/libcharon/daemon.c
@@ -118,6 +118,13 @@ struct private_daemon_t {
};
/**
+ * Register plugins if built statically
+ */
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+#include "plugin_constructors.c"
+#endif
+
+/**
* One and only instance of the daemon.
*/
daemon_t *charon;
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap_msg.c b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap_msg.c
index b86288683..db19bd575 100644
--- a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap_msg.c
+++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap_msg.c
@@ -55,7 +55,7 @@ struct private_tnc_ifmap_soap_msg_t {
static xmlNodePtr find_child(xmlNodePtr parent, const xmlChar* name)
{
xmlNodePtr child;
-
+
child = parent->xmlChildrenNode;
while (child)
{
@@ -80,7 +80,7 @@ METHOD(tnc_ifmap_soap_msg_t, post, bool,
xmlChar *xml_str, *errorCode, *errorString;
int xml_len, len, written;
chunk_t xml, http;
- char buf[4096];
+ char buf[4096] = { 0 };
status_t status;
DBG2(DBG_TNC, "sending ifmap %s", request->name);
@@ -131,7 +131,8 @@ METHOD(tnc_ifmap_soap_msg_t, post, bool,
xml = chunk_empty;
do
{
- len = this->tls->read(this->tls, buf, sizeof(buf), TRUE);
+ /* reduce size so the buffer is null-terminated */
+ len = this->tls->read(this->tls, buf, sizeof(buf)-1, TRUE);
if (len <= 0)
{
return FALSE;
@@ -150,7 +151,7 @@ METHOD(tnc_ifmap_soap_msg_t, post, bool,
DBG3(DBG_TNC, "parsing XML message %B", &xml);
this->doc = xmlParseMemory(xml.ptr, xml.len);
free(xml.ptr);
-
+
if (!this->doc)
{
DBG1(DBG_TNC, "failed to parse XML message");
diff --git a/src/libimcv/ietf/ietf_attr_op_status.c b/src/libimcv/ietf/ietf_attr_op_status.c
index f04c89b96..1f813b3c6 100644
--- a/src/libimcv/ietf/ietf_attr_op_status.c
+++ b/src/libimcv/ietf/ietf_attr_op_status.c
@@ -170,6 +170,7 @@ METHOD(pa_tnc_attr_t, process, status_t,
chunk_t last_use;
uint16_t reserved;
struct tm t;
+ char buf[BUF_LEN];
*offset = 0;
@@ -208,7 +209,8 @@ METHOD(pa_tnc_attr_t, process, status_t,
*offset = 4;
/* Conversion from RFC 3339 ASCII string to time_t */
- if (sscanf(last_use.ptr, "%4d-%2d-%2dT%2d:%2d:%2dZ", &t.tm_year, &t.tm_mon,
+ snprintf(buf, sizeof(buf), "%.*s", (int)last_use.len, last_use.ptr);
+ if (sscanf(buf, "%4d-%2d-%2dT%2d:%2d:%2dZ", &t.tm_year, &t.tm_mon,
&t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec) != 6)
{
DBG1(DBG_TNC, "invalid last_use time format in IETF operational status");
diff --git a/src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.c b/src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.c
index c249ca151..9438fa062 100644
--- a/src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.c
+++ b/src/libimcv/tcg/pts/tcg_pts_attr_simple_comp_evid.c
@@ -263,13 +263,15 @@ bool measurement_time_from_utc(time_t *measurement_time, chunk_t utc_time)
{
int tm_year, tm_mon, tm_day, tm_days, tm_hour, tm_min, tm_sec, tm_secs;
int tm_leap_4, tm_leap_100, tm_leap_400, tm_leap;
+ char buf[BUF_LEN];
if (memeq(utc_undefined_time_str, utc_time.ptr, utc_time.len))
{
*measurement_time = 0;
return TRUE;
}
- if (sscanf(utc_time.ptr, "%4d-%2d-%2dT%2d:%2d:%2dZ",
+ snprintf(buf, sizeof(buf), "%.*s", (int)utc_time.len, utc_time.ptr);
+ if (sscanf(buf, "%4d-%2d-%2dT%2d:%2d:%2dZ",
&tm_year, &tm_mon, &tm_day, &tm_hour, &tm_min, &tm_sec) != 6)
{
return FALSE;
diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am
index f6d6f5465..b4d8452f1 100644
--- a/src/libstrongswan/Makefile.am
+++ b/src/libstrongswan/Makefile.am
@@ -195,6 +195,7 @@ endif
EXTRA_DIST = \
asn1/oid.txt asn1/oid.pl \
crypto/proposal/proposal_keywords_static.txt \
+plugins/plugin_constructors.py \
Android.mk
BUILT_SOURCES = \
@@ -220,6 +221,15 @@ $(srcdir)/crypto/proposal/proposal_keywords_static.c: $(srcdir)/crypto/proposal/
$(GPERF) -N proposal_get_token_static -m 10 -C -G -c -t -D < \
$(srcdir)/crypto/proposal/proposal_keywords_static.txt > $@
+if STATIC_PLUGIN_CONSTRUCTORS
+BUILT_SOURCES += $(srcdir)/plugin_constructors.c
+CLEANFILES = $(srcdir)/plugin_constructors.c
+
+$(srcdir)/plugin_constructors.c: $(srcdir)/plugins/plugin_constructors.py
+ $(AM_V_GEN) \
+ $(PYTHON) $(srcdir)/plugins/plugin_constructors.py ${s_plugins} > $@
+endif
+
if MONOLITHIC
SUBDIRS =
else
diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c
index 5ce840325..8b9dc1c48 100644
--- a/src/libstrongswan/asn1/asn1.c
+++ b/src/libstrongswan/asn1/asn1.c
@@ -350,13 +350,15 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
int tm_leap_4, tm_leap_100, tm_leap_400, tm_leap;
int tz_hour, tz_min, tz_offset;
time_t tm_days, tm_secs;
- u_char *eot = NULL;
+ char buf[BUF_LEN], *eot = NULL;
- if ((eot = memchr(utctime->ptr, 'Z', utctime->len)) != NULL)
+ snprintf(buf, sizeof(buf), "%.*s", (int)utctime->len, utctime->ptr);
+
+ if ((eot = strchr(buf, 'Z')) != NULL)
{
tz_offset = 0; /* Zulu time with a zero time zone offset */
}
- else if ((eot = memchr(utctime->ptr, '+', utctime->len)) != NULL)
+ else if ((eot = strchr(buf, '+')) != NULL)
{
if (sscanf(eot+1, "%2d%2d", &tz_hour, &tz_min) != 2)
{
@@ -364,7 +366,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
}
tz_offset = 3600*tz_hour + 60*tz_min; /* positive time zone offset */
}
- else if ((eot = memchr(utctime->ptr, '-', utctime->len)) != NULL)
+ else if ((eot = strchr(buf, '-')) != NULL)
{
if (sscanf(eot+1, "%2d%2d", &tz_hour, &tz_min) != 2)
{
@@ -382,15 +384,15 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
const char* format = (type == ASN1_UTCTIME)? "%2d%2d%2d%2d%2d":
"%4d%2d%2d%2d%2d";
- if (sscanf(utctime->ptr, format, &tm_year, &tm_mon, &tm_day,
- &tm_hour, &tm_min) != 5)
+ if (sscanf(buf, format, &tm_year, &tm_mon, &tm_day,
+ &tm_hour, &tm_min) != 5)
{
return 0; /* error in [yy]yymmddhhmm time format */
}
}
/* is there a seconds field? */
- if ((eot - utctime->ptr) == ((type == ASN1_UTCTIME)?12:14))
+ if ((eot - buf) == ((type == ASN1_UTCTIME)?12:14))
{
if (sscanf(eot-2, "%2d", &tm_sec) != 1)
{
diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c
index 4f79dcc5b..7944b9356 100644
--- a/src/libstrongswan/library.c
+++ b/src/libstrongswan/library.c
@@ -94,6 +94,13 @@ void library_add_namespace(char *ns)
}
/**
+ * Register plugins if built statically
+ */
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+#include "plugin_constructors.c"
+#endif
+
+/**
* library instance
*/
library_t *lib = NULL;
@@ -241,6 +248,8 @@ static bool equals(char *a, char *b)
*/
#define MEMWIPE_WIPE_WORDS 16
+#ifndef NO_CHECK_MEMWIPE
+
/**
* Write magic to memory, and try to clear it with memwipe()
*/
@@ -281,6 +290,8 @@ static bool check_memwipe()
return TRUE;
}
+#endif
+
/*
* see header file
*/
@@ -387,10 +398,12 @@ bool library_init(char *settings, const char *namespace)
this->public.streams = stream_manager_create();
this->public.plugins = plugin_loader_create();
+#ifndef NO_CHECK_MEMWIPE
if (!check_memwipe())
{
return FALSE;
}
+#endif
if (lib->settings->get_bool(lib->settings,
"%s.integrity_test", FALSE, lib->ns))
diff --git a/src/libstrongswan/plugins/pem/pem_builder.c b/src/libstrongswan/plugins/pem/pem_builder.c
index 719a2a69e..ec90fb084 100644
--- a/src/libstrongswan/plugins/pem/pem_builder.c
+++ b/src/libstrongswan/plugins/pem/pem_builder.c
@@ -61,7 +61,7 @@ static bool find_boundary(char* tag, chunk_t *line)
if (!present("-----", line) ||
!present(tag, line) ||
- *line->ptr != ' ')
+ !line->len || *line->ptr != ' ')
{
return FALSE;
}
@@ -250,7 +250,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
{
continue;
}
- if (match("Proc-Type", &name) && *value.ptr == '4')
+ if (match("Proc-Type", &name) && value.len && *value.ptr == '4')
{
encrypted = TRUE;
}
@@ -306,7 +306,7 @@ static status_t pem_to_bin(chunk_t *blob, bool *pgp)
}
/* check for PGP armor checksum */
- if (*data.ptr == '=')
+ if (data.len && *data.ptr == '=')
{
*pgp = TRUE;
data.ptr++;
diff --git a/src/libstrongswan/plugins/plugin_constructors.py b/src/libstrongswan/plugins/plugin_constructors.py
new file mode 100644
index 000000000..d9c40e383
--- /dev/null
+++ b/src/libstrongswan/plugins/plugin_constructors.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2017 Tobias Brunner
+# HSR Hochschule fuer Technik Rapperswil
+#
+# 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. See <http://www.fsf.org/copyleft/gpl.txt>.
+#
+# 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.
+
+import sys
+from argparse import ArgumentParser
+
+def generate_output(plugins):
+ """Generate a source file containing plugin constructor registrations"""
+ print("/**")
+ print(" * Register plugin constructors for static libraries")
+ print(" * Created by {0}".format(__file__))
+ print(" */")
+ print("")
+ print("#include <plugins/plugin.h>")
+ print("#include <plugins/plugin_loader.h>")
+ print("")
+
+ for plugin in plugins:
+ print("plugin_t *{0}_plugin_create();".format(plugin.replace('-', '_')))
+
+ print("")
+ print("static void register_plugins() __attribute__ ((constructor));")
+ print("static void register_plugins()")
+ print("{")
+
+ for plugin in plugins:
+ print(' plugin_constructor_register("{0}", {1}_plugin_create);'.format(plugin, plugin.replace('-', '_')))
+
+ print("}")
+
+ print("")
+ print("static void unregister_plugins() __attribute__ ((destructor));")
+ print("static void unregister_plugins()")
+ print("{")
+
+ for plugin in plugins:
+ print(' plugin_constructor_register("{0}", NULL);'.format(plugin))
+
+ print("}")
+ print("")
+
+parser = ArgumentParser(description = "Generate constructor registration for a list of plugins")
+parser.add_argument('plugins', metavar="plugin", nargs="*",
+ help = "name of a plugin for which to generate constructor registration")
+
+
+args = parser.parse_args()
+generate_output(args.plugins);
diff --git a/src/libstrongswan/plugins/plugin_loader.c b/src/libstrongswan/plugins/plugin_loader.c
index e4698fac0..4daf3f13e 100644
--- a/src/libstrongswan/plugins/plugin_loader.c
+++ b/src/libstrongswan/plugins/plugin_loader.c
@@ -40,6 +40,13 @@ typedef struct registered_feature_t registered_feature_t;
typedef struct provided_feature_t provided_feature_t;
typedef struct plugin_entry_t plugin_entry_t;
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+/**
+ * Statically registered constructors
+ */
+static hashtable_t *plugin_constructors = NULL;
+#endif
+
/**
* private data of plugin_loader
*/
@@ -298,6 +305,46 @@ static plugin_t *static_features_create(const char *name,
return &this->public;
}
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+/*
+ * Described in header.
+ */
+void plugin_constructor_register(char *name, void *constructor)
+{
+ bool old = FALSE;
+
+ if (lib && lib->leak_detective)
+ {
+ old = lib->leak_detective->set_state(lib->leak_detective, FALSE);
+ }
+
+ if (!plugin_constructors)
+ {
+ chunk_hash_seed();
+ plugin_constructors = hashtable_create(hashtable_hash_str,
+ hashtable_equals_str, 32);
+ }
+ if (constructor)
+ {
+ plugin_constructors->put(plugin_constructors, name, constructor);
+ }
+ else
+ {
+ plugin_constructors->remove(plugin_constructors, name);
+ if (!plugin_constructors->get_count(plugin_constructors))
+ {
+ plugin_constructors->destroy(plugin_constructors);
+ plugin_constructors = NULL;
+ }
+ }
+
+ if (lib && lib->leak_detective)
+ {
+ lib->leak_detective->set_state(lib->leak_detective, old);
+ }
+}
+#endif
+
/**
* create a plugin
* returns: NOT_FOUND, if the constructor was not found
@@ -309,7 +356,7 @@ static status_t create_plugin(private_plugin_loader_t *this, void *handle,
{
char create[128];
plugin_t *plugin;
- plugin_constructor_t constructor;
+ plugin_constructor_t constructor = NULL;
if (snprintf(create, sizeof(create), "%s_plugin_create",
name) >= sizeof(create))
@@ -317,8 +364,17 @@ static status_t create_plugin(private_plugin_loader_t *this, void *handle,
return FAILED;
}
translate(create, "-", "_");
- constructor = dlsym(handle, create);
- if (constructor == NULL)
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+ if (plugin_constructors)
+ {
+ constructor = plugin_constructors->get(plugin_constructors, name);
+ }
+ if (!constructor)
+#endif
+ {
+ constructor = dlsym(handle, create);
+ }
+ if (!constructor)
{
return NOT_FOUND;
}
@@ -674,9 +730,11 @@ static bool load_dependencies(private_plugin_loader_t *this,
if (!find_compatible_feature(this, &provided->feature[i]))
{
- char *name, *provide, *depend;
bool soft = provided->feature[i].kind == FEATURE_SDEPEND;
+#ifndef USE_FUZZING
+ char *name, *provide, *depend;
+
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(&provided->feature[0]);
depend = plugin_feature_get_string(&provided->feature[i]);
@@ -697,6 +755,8 @@ static bool load_dependencies(private_plugin_loader_t *this,
}
free(provide);
free(depend);
+#endif /* !USE_FUZZING */
+
if (soft)
{ /* it's ok if we can't resolve soft dependencies */
continue;
@@ -716,8 +776,6 @@ static void load_feature(private_plugin_loader_t *this,
{
if (load_dependencies(this, provided, level))
{
- char *name, *provide;
-
if (plugin_feature_load(provided->entry->plugin, provided->feature,
provided->reg))
{
@@ -727,6 +785,9 @@ static void load_feature(private_plugin_loader_t *this,
return;
}
+#ifndef USE_FUZZING
+ char *name, *provide;
+
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(&provided->feature[0]);
if (provided->entry->critical)
@@ -740,6 +801,7 @@ static void load_feature(private_plugin_loader_t *this,
provide, name);
}
free(provide);
+#endif /* !USE_FUZZING */
}
else
{ /* TODO: we could check the current level and set a different flag when
@@ -759,13 +821,16 @@ static void load_provided(private_plugin_loader_t *this,
provided_feature_t *provided,
int level)
{
- char *name, *provide;
int indent = level * 2;
if (provided->loaded || provided->failed)
{
return;
}
+
+#ifndef USE_FUZZING
+ char *name, *provide;
+
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(provided->feature);
if (provided->loading)
@@ -778,6 +843,12 @@ static void load_provided(private_plugin_loader_t *this,
DBG3(DBG_LIB, "%*sloading feature %s in plugin '%s'",
indent, "", provide, name);
free(provide);
+#else
+ if (provided->loading)
+ {
+ return;
+ }
+#endif /* USE_FUZZING */
provided->loading = TRUE;
load_feature(this, provided, level + 1);
diff --git a/src/libstrongswan/plugins/plugin_loader.h b/src/libstrongswan/plugins/plugin_loader.h
index 6be6a909c..92a860615 100644
--- a/src/libstrongswan/plugins/plugin_loader.h
+++ b/src/libstrongswan/plugins/plugin_loader.h
@@ -168,4 +168,14 @@ plugin_loader_t *plugin_loader_create();
*/
void plugin_loader_add_plugindirs(char *basedir, char *plugins);
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+/**
+ * Register a plugin constructor in case of static builds.
+ *
+ * @param name name of the plugin
+ * @param constructor constructor to register (set to NULL to unregister)
+ */
+void plugin_constructor_register(char *name, void *constructor);
+#endif
+
#endif /** PLUGIN_LOADER_H_ @}*/
diff --git a/src/libstrongswan/plugins/x509/x509_cert.c b/src/libstrongswan/plugins/x509/x509_cert.c
index b3d90c5f6..ee630eee0 100644
--- a/src/libstrongswan/plugins/x509/x509_cert.c
+++ b/src/libstrongswan/plugins/x509/x509_cert.c
@@ -218,6 +218,29 @@ struct private_x509_cert_t {
};
/**
+ * Convert a generalName to a string
+ */
+static bool gn_to_string(identification_t *id, char **uri)
+{
+ int len;
+
+#ifdef USE_FUZZING
+ chunk_t proper;
+ chunk_printable(id->get_encoding(id), &proper, '?');
+ len = asprintf(uri, "%.*s", (int)proper.len, proper.ptr);
+ chunk_free(&proper);
+#else
+ len = asprintf(uri, "%Y", id);
+#endif
+ if (!len)
+ {
+ free(*uri);
+ return FALSE;
+ }
+ return len > 0;
+}
+
+/**
* Destroy a CertificateDistributionPoint
*/
static void crl_uri_destroy(x509_cdp_t *this)
@@ -649,7 +672,7 @@ static bool parse_authorityInfoAccess(chunk_t blob, int level0,
}
DBG2(DBG_ASN, " '%Y'", id);
if (accessMethod == OID_OCSP &&
- asprintf(&uri, "%Y", id) > 0)
+ gn_to_string(id, &uri))
{
this->ocsp_uris->insert_last(this->ocsp_uris, uri);
}
@@ -821,7 +844,7 @@ static void add_cdps(linked_list_t *list, linked_list_t *uris,
while (uris->remove_last(uris, (void**)&id) == SUCCESS)
{
- if (asprintf(&uri, "%Y", id) > 0)
+ if (gn_to_string(id, &uri))
{
if (issuers->get_count(issuers))
{
@@ -900,8 +923,8 @@ bool x509_parse_crlDistributionPoints(chunk_t blob, int level0,
end:
parser->destroy(parser);
- uris->destroy(uris);
- issuers->destroy(issuers);
+ uris->destroy_offset(uris, offsetof(identification_t, destroy));
+ issuers->destroy_offset(issuers, offsetof(identification_t, destroy));
return success;
}
@@ -1461,6 +1484,7 @@ static bool parse_certificate(private_x509_cert_t *this)
}
break;
case OID_AUTHORITY_KEY_ID:
+ chunk_free(&this->authKeyIdentifier);
this->authKeyIdentifier = x509_parse_authorityKeyIdentifier(
object, level, &this->authKeySerialNumber);
break;
diff --git a/src/libstrongswan/processing/processor.c b/src/libstrongswan/processing/processor.c
index 27e5ab5f6..bd8d534a5 100644
--- a/src/libstrongswan/processing/processor.c
+++ b/src/libstrongswan/processing/processor.c
@@ -429,7 +429,15 @@ METHOD(processor_t, execute_job, void,
METHOD(processor_t, set_threads, void,
private_processor_t *this, u_int count)
{
+ int i;
+
this->mutex->lock(this->mutex);
+ for (i = 0; i < JOB_PRIO_MAX; i++)
+ {
+ this->prio_threads[i] = lib->settings->get_int(lib->settings,
+ "%s.processor.priority_threads.%N", 0, lib->ns,
+ job_priority_names, i);
+ }
if (count > this->total_threads)
{ /* increase thread count */
worker_thread_t *worker;
@@ -551,13 +559,10 @@ processor_t *processor_create()
.job_added = condvar_create(CONDVAR_TYPE_DEFAULT),
.thread_terminated = condvar_create(CONDVAR_TYPE_DEFAULT),
);
+
for (i = 0; i < JOB_PRIO_MAX; i++)
{
this->jobs[i] = linked_list_create();
- this->prio_threads[i] = lib->settings->get_int(lib->settings,
- "%s.processor.priority_threads.%N", 0, lib->ns,
- job_priority_names, i);
}
-
return &this->public;
}
diff --git a/src/libstrongswan/utils/chunk.c b/src/libstrongswan/utils/chunk.c
index 0c50ab788..8f4b7efff 100644
--- a/src/libstrongswan/utils/chunk.c
+++ b/src/libstrongswan/utils/chunk.c
@@ -643,7 +643,7 @@ chunk_t chunk_from_base64(chunk_t base64, char *buf)
outlen += 3;
for (j = 0; j < 4; j++)
{
- if (*pos == '=')
+ if (*pos == '=' && outlen > 0)
{
outlen--;
}
diff --git a/src/libtnccs/Makefile.am b/src/libtnccs/Makefile.am
index 7a630fe54..ff7b54f6a 100644
--- a/src/libtnccs/Makefile.am
+++ b/src/libtnccs/Makefile.am
@@ -26,6 +26,15 @@ tnc/tnccs/tnccs_manager.h tnc/tnccs/tnccs_manager.c
EXTRA_DIST = Android.mk
+if STATIC_PLUGIN_CONSTRUCTORS
+BUILT_SOURCES = $(srcdir)/plugin_constructors.c
+CLEANFILES = $(srcdir)/plugin_constructors.c
+
+$(srcdir)/plugin_constructors.c: $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py
+ $(AM_V_GEN) \
+ $(PYTHON) $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py ${t_plugins} > $@
+endif
+
# build optional plugins
########################
diff --git a/src/libtnccs/tnc/tnc.c b/src/libtnccs/tnc/tnc.c
index 80ba61c5a..9627be862 100644
--- a/src/libtnccs/tnc/tnc.c
+++ b/src/libtnccs/tnc/tnc.c
@@ -55,6 +55,13 @@ struct private_tnc_t {
};
/**
+ * Register plugins if built statically
+ */
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+#include "plugin_constructors.c"
+#endif
+
+/**
* Single instance of tnc_t.
*/
tnc_t *tnc;
diff --git a/src/libtpmtss/Makefile.am b/src/libtpmtss/Makefile.am
index c7ac39a09..5f3a97a99 100644
--- a/src/libtpmtss/Makefile.am
+++ b/src/libtpmtss/Makefile.am
@@ -33,6 +33,15 @@ else
SUBDIRS = .
endif
+if STATIC_PLUGIN_CONSTRUCTORS
+BUILT_SOURCES = $(srcdir)/plugin_constructors.c
+CLEANFILES = $(srcdir)/plugin_constructors.c
+
+$(srcdir)/plugin_constructors.c: $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py
+ $(AM_V_GEN) \
+ $(PYTHON) $(top_srcdir)/src/libstrongswan/plugins/plugin_constructors.py ${p_plugins} > $@
+endif
+
if USE_TPM
SUBDIRS += plugins/tpm
if MONOLITHIC
diff --git a/src/libtpmtss/tpm_tss.c b/src/libtpmtss/tpm_tss.c
index b7b970c8d..42a341896 100644
--- a/src/libtpmtss/tpm_tss.c
+++ b/src/libtpmtss/tpm_tss.c
@@ -18,6 +18,13 @@
#include "tpm_tss_trousers.h"
/**
+ * Register plugins if built statically
+ */
+#ifdef STATIC_PLUGIN_CONSTRUCTORS
+#include "plugin_constructors.c"
+#endif
+
+/**
* Described in header.
*/
void libtpmtss_init(void)