summaryrefslogtreecommitdiff
path: root/src/libstrongswan/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils')
-rw-r--r--src/libstrongswan/utils/backtrace.c21
-rw-r--r--src/libstrongswan/utils/backtrace.h10
-rw-r--r--src/libstrongswan/utils/hashtable.c8
-rw-r--r--src/libstrongswan/utils/host.c45
-rw-r--r--src/libstrongswan/utils/host.h12
-rw-r--r--src/libstrongswan/utils/identification.c17
-rw-r--r--src/libstrongswan/utils/leak_detective.c25
-rw-r--r--src/libstrongswan/utils/optionsfrom.c23
8 files changed, 161 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/backtrace.c b/src/libstrongswan/utils/backtrace.c
index a67245194..5f1318b9a 100644
--- a/src/libstrongswan/utils/backtrace.c
+++ b/src/libstrongswan/utils/backtrace.c
@@ -132,10 +132,18 @@ static void log_(private_backtrace_t *this, FILE *file, bool detailed)
/**
* Implementation of backtrace_t.contains_function
*/
+<<<<<<< HEAD
static bool contains_function(private_backtrace_t *this, char *function)
{
#ifdef HAVE_DLADDR
int i;
+=======
+static bool contains_function(private_backtrace_t *this,
+ char *function[], int count)
+{
+#ifdef HAVE_DLADDR
+ int i, j;
+>>>>>>> upstream/4.5.1
for (i = 0; i< this->frame_count; i++)
{
@@ -143,9 +151,18 @@ static bool contains_function(private_backtrace_t *this, char *function)
if (dladdr(this->frames[i], &info) && info.dli_sname)
{
+<<<<<<< HEAD
if (streq(info.dli_sname, function))
{
return TRUE;
+=======
+ for (j = 0; j < count; j++)
+ {
+ if (streq(info.dli_sname, function[j]))
+ {
+ return TRUE;
+ }
+>>>>>>> upstream/4.5.1
}
}
}
@@ -179,7 +196,11 @@ backtrace_t *backtrace_create(int skip)
this->frame_count = frame_count;
this->public.log = (void(*)(backtrace_t*,FILE*,bool))log_;
+<<<<<<< HEAD
this->public.contains_function = (bool(*)(backtrace_t*, char *function))contains_function;
+=======
+ this->public.contains_function = (bool(*)(backtrace_t*, char *function[], int count))contains_function;
+>>>>>>> upstream/4.5.1
this->public.destroy = (void(*)(backtrace_t*))destroy;
return &this->public;
diff --git a/src/libstrongswan/utils/backtrace.h b/src/libstrongswan/utils/backtrace.h
index c6b0ec78f..712122afb 100644
--- a/src/libstrongswan/utils/backtrace.h
+++ b/src/libstrongswan/utils/backtrace.h
@@ -41,12 +41,22 @@ struct backtrace_t {
void (*log)(backtrace_t *this, FILE *file, bool detailed);
/**
+<<<<<<< HEAD
* Check if the backtrace contains a frame in a specific function.
*
* @param function name
* @return TRUE if function is in the stack
*/
bool (*contains_function)(backtrace_t *this, char *function);
+=======
+ * Check if the backtrace contains a frame having a function in a list.
+ *
+ * @param function name array
+ * @param number of elements in function array
+ * @return TRUE if one of the functions is in the stack
+ */
+ bool (*contains_function)(backtrace_t *this, char *function[], int count);
+>>>>>>> upstream/4.5.1
/**
* Destroy a backtrace instance.
diff --git a/src/libstrongswan/utils/hashtable.c b/src/libstrongswan/utils/hashtable.c
index dde57dc65..9a0f92b3c 100644
--- a/src/libstrongswan/utils/hashtable.c
+++ b/src/libstrongswan/utils/hashtable.c
@@ -186,7 +186,11 @@ static void rehash(private_hashtable_t *this)
linked_list_t **old_table;
u_int row, old_capacity;
+<<<<<<< HEAD
if (this->capacity < MAX_CAPACITY)
+=======
+ if (this->capacity >= MAX_CAPACITY)
+>>>>>>> upstream/4.5.1
{
return;
}
@@ -249,6 +253,10 @@ METHOD(hashtable_t, put, void*,
{
old_value = pair->value;
pair->value = value;
+<<<<<<< HEAD
+=======
+ pair->key = key;
+>>>>>>> upstream/4.5.1
break;
}
}
diff --git a/src/libstrongswan/utils/host.c b/src/libstrongswan/utils/host.c
index 112d07e5c..1fba6a587 100644
--- a/src/libstrongswan/utils/host.c
+++ b/src/libstrongswan/utils/host.c
@@ -476,6 +476,13 @@ host_t *host_create_from_dns(char *string, int af, u_int16_t port)
{
return host_create_any_port(af ? af : AF_INET6, port);
}
+<<<<<<< HEAD
+=======
+ if (af == AF_INET && strchr(string, ':'))
+ { /* do not try to convert v6 addresses for v4 family */
+ return NULL;
+ }
+>>>>>>> upstream/4.5.1
memset(&hints, 0, sizeof(hints));
hints.ai_family = af;
@@ -564,6 +571,44 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
/*
* Described in header.
*/
+<<<<<<< HEAD
+=======
+host_t *host_create_from_subnet(char *string, int *bits)
+{
+ char *pos, buf[64];
+ host_t *net;
+
+ pos = strchr(string, '/');
+ if (pos)
+ {
+ if (pos - string >= sizeof(buf))
+ {
+ return NULL;
+ }
+ strncpy(buf, string, pos - string);
+ buf[pos - string] = '\0';
+ *bits = atoi(pos + 1);
+ return host_create_from_string(buf, 0);
+ }
+ net = host_create_from_string(buf, 0);
+ if (net)
+ {
+ if (net->get_family(net) == AF_INET)
+ {
+ *bits = 32;
+ }
+ else
+ {
+ *bits = 128;
+ }
+ }
+ return net;
+}
+
+/*
+ * Described in header.
+ */
+>>>>>>> upstream/4.5.1
host_t *host_create_any(int family)
{
private_host_t *this = host_create_empty();
diff --git a/src/libstrongswan/utils/host.h b/src/libstrongswan/utils/host.h
index f5796154c..b9cd81148 100644
--- a/src/libstrongswan/utils/host.h
+++ b/src/libstrongswan/utils/host.h
@@ -190,6 +190,18 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port);
host_t *host_create_from_sockaddr(sockaddr_t *sockaddr);
/**
+<<<<<<< HEAD
+=======
+ * Create a host from a CIDR subnet definition (1.2.3.0/24), return bits.
+ *
+ * @param string string to parse
+ * @param bits gets the number of network bits in CIDR notation
+ * @return network start address, NULL on error
+ */
+host_t *host_create_from_subnet(char *string, int *bits);
+
+/**
+>>>>>>> upstream/4.5.1
* Create a host without an address, a "any" host.
*
* @param family family of the any host
diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c
index 0696c1030..facf9f6de 100644
--- a/src/libstrongswan/utils/identification.c
+++ b/src/libstrongswan/utils/identification.c
@@ -281,11 +281,20 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
chunk_t oid_data, data, printable;
u_char type;
int oid, written;
+<<<<<<< HEAD
bool finished = FALSE;
+=======
+ bool finished = FALSE, empty = TRUE;
+>>>>>>> upstream/4.5.1
e = create_rdn_enumerator(dn);
while (e->enumerate(e, &oid_data, &type, &data))
{
+<<<<<<< HEAD
+=======
+ empty = FALSE;
+
+>>>>>>> upstream/4.5.1
oid = asn1_known_oid(oid_data);
if (oid == OID_UNKNOWN)
@@ -329,7 +338,15 @@ static void dntoa(chunk_t dn, char *buf, size_t len)
break;
}
}
+<<<<<<< HEAD
if (!finished)
+=======
+ if (empty)
+ {
+ snprintf(buf, len, "");
+ }
+ else if (!finished)
+>>>>>>> upstream/4.5.1
{
snprintf(buf, len, "(invalid ID_DER_ASN1_DN)");
}
diff --git a/src/libstrongswan/utils/leak_detective.c b/src/libstrongswan/utils/leak_detective.c
index 5673fc32d..ef2ea8e14 100644
--- a/src/libstrongswan/utils/leak_detective.c
+++ b/src/libstrongswan/utils/leak_detective.c
@@ -218,6 +218,7 @@ char *whitelist[] = {
"gcry_create_nonce",
/* NSPR */
"PR_CallOnce",
+<<<<<<< HEAD
};
/**
@@ -237,6 +238,25 @@ static bool is_whitelisted(backtrace_t *backtrace)
}
/**
+=======
+ /* libapr */
+ "apr_pool_create_ex",
+ /* glib */
+ "g_type_init_with_debug_flags",
+ "g_type_register_static",
+ "g_type_class_ref",
+ "g_type_create_instance",
+ "g_type_add_interface_static",
+ "g_type_interface_add_prerequisite",
+ "g_socket_connection_factory_lookup_type",
+ /* libgpg */
+ "gpg_err_init",
+ /* gnutls */
+ "gnutls_global_init",
+};
+
+/**
+>>>>>>> upstream/4.5.1
* Report leaks at library destruction
*/
static void report(private_leak_detective_t *this, bool detailed)
@@ -248,7 +268,12 @@ static void report(private_leak_detective_t *this, bool detailed)
for (hdr = first_header.next; hdr != NULL; hdr = hdr->next)
{
+<<<<<<< HEAD
if (is_whitelisted(hdr->backtrace))
+=======
+ if (hdr->backtrace->contains_function(hdr->backtrace,
+ whitelist, countof(whitelist)))
+>>>>>>> upstream/4.5.1
{
whitelisted++;
}
diff --git a/src/libstrongswan/utils/optionsfrom.c b/src/libstrongswan/utils/optionsfrom.c
index d8f635c62..fe3d37966 100644
--- a/src/libstrongswan/utils/optionsfrom.c
+++ b/src/libstrongswan/utils/optionsfrom.c
@@ -61,11 +61,16 @@ struct private_options_t {
char *buffers[MAX_USES];
};
+<<<<<<< HEAD
/**
* Defined in header
*/
bool from(private_options_t *this, char *filename, int *argcp, char **argvp[],
int optind)
+=======
+METHOD(options_t, from, bool,
+ private_options_t *this, char *filename, int *argcp, char **argvp[], int optind)
+>>>>>>> upstream/4.5.1
{
int newargc;
int next; /* place for next argument */
@@ -182,10 +187,15 @@ bool from(private_options_t *this, char *filename, int *argcp, char **argvp[],
return good;
}
+<<<<<<< HEAD
/**
* Defined in header
*/
void destroy(private_options_t *this)
+=======
+METHOD(options_t, destroy, void,
+ private_options_t *this)
+>>>>>>> upstream/4.5.1
{
while (this->nuses >= 0)
{
@@ -200,6 +210,7 @@ void destroy(private_options_t *this)
*/
options_t *options_create(void)
{
+<<<<<<< HEAD
private_options_t *this = malloc_thing(private_options_t);
/* initialize */
@@ -211,6 +222,18 @@ options_t *options_create(void)
/* public functions */
this->public.from = (bool (*) (options_t*,char*,int*,char***,int))from;
this->public.destroy = (void (*) (options_t*))destroy;
+=======
+ private_options_t *this;
+
+ INIT(this,
+ .public = {
+ .from = _from,
+ .destroy = _destroy,
+
+ },
+ .nuses = -1,
+ );
+>>>>>>> upstream/4.5.1
return &this->public;
}