summaryrefslogtreecommitdiff
path: root/src/pool
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2016-10-20 16:18:38 +0200
committerYves-Alexis Perez <corsac@debian.org>2016-10-20 16:18:38 +0200
commit25663e04c3ab01ef8dc9f906608282319cfea2db (patch)
treea0ca5e70f66d74dbe552c996a4f3a285cdfc35e4 /src/pool
parentbf372706c469764d59e9f29c39e3ecbebd72b8d2 (diff)
downloadvyos-strongswan-25663e04c3ab01ef8dc9f906608282319cfea2db.tar.gz
vyos-strongswan-25663e04c3ab01ef8dc9f906608282319cfea2db.zip
New upstream version 5.5.1
Diffstat (limited to 'src/pool')
-rw-r--r--src/pool/Makefile.in5
-rw-r--r--src/pool/pool.c59
2 files changed, 40 insertions, 24 deletions
diff --git a/src/pool/Makefile.in b/src/pool/Makefile.in
index 8b73403e7..9ad2445cb 100644
--- a/src/pool/Makefile.in
+++ b/src/pool/Makefile.in
@@ -353,7 +353,6 @@ clearsilver_LIBS = @clearsilver_LIBS@
cmd_plugins = @cmd_plugins@
datadir = @datadir@
datarootdir = @datarootdir@
-dbusservicedir = @dbusservicedir@
dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
@@ -387,8 +386,6 @@ libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
localedir = @localedir@
localstatedir = @localstatedir@
-maemo_CFLAGS = @maemo_CFLAGS@
-maemo_LIBS = @maemo_LIBS@
manager_plugins = @manager_plugins@
mandir = @mandir@
medsrv_plugins = @medsrv_plugins@
@@ -442,6 +439,8 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+tss2_CFLAGS = @tss2_CFLAGS@
+tss2_LIBS = @tss2_LIBS@
urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
diff --git a/src/pool/pool.c b/src/pool/pool.c
index 265974860..cd9fb6293 100644
--- a/src/pool/pool.c
+++ b/src/pool/pool.c
@@ -1,6 +1,7 @@
/*
+ * Copyright (C) 2011-2016 Tobias Brunner
* Copyright (C) 2008 Martin Willi
- * Hochschule fuer Technik Rapperswil
+ * 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
@@ -23,6 +24,7 @@
#include <utils/debug.h>
#include <library.h>
+#include <collections/array.h>
#include <networking/host.h>
#include <utils/identification.h>
#include <attributes/attributes.h>
@@ -586,11 +588,11 @@ static void resize(char *name, host_t *end)
/**
* create the lease query using the filter string
*/
-static enumerator_t *create_lease_query(char *filter)
+static enumerator_t *create_lease_query(char *filter, array_t **to_free)
{
enumerator_t *query;
- identification_t *id = NULL;
- host_t *addr = NULL;
+ chunk_t id_chunk = chunk_empty, addr_chunk = chunk_empty;
+ id_type_t id_type = 0;
u_int tstamp = 0;
bool online = FALSE, valid = FALSE, expired = FALSE;
char *value, *pos, *pool = NULL;
@@ -635,18 +637,29 @@ static enumerator_t *create_lease_query(char *filter)
case FIL_ID:
if (value)
{
+ identification_t *id;
+
id = identification_create_from_string(value);
+ id_type = id->get_type(id);
+ id_chunk = chunk_clone(id->get_encoding(id));
+ array_insert_create(to_free, ARRAY_TAIL, id_chunk.ptr);
+ id->destroy(id);
}
break;
case FIL_ADDR:
if (value)
{
+ host_t *addr;
+
addr = host_create_from_string(value, 0);
- }
- if (!addr)
- {
- fprintf(stderr, "invalid 'addr' in filter string.\n");
- exit(EXIT_FAILURE);
+ if (!addr)
+ {
+ fprintf(stderr, "invalid 'addr' in filter string.\n");
+ exit(EXIT_FAILURE);
+ }
+ addr_chunk = chunk_clone(addr->get_address(addr));
+ array_insert_create(to_free, ARRAY_TAIL, addr_chunk.ptr);
+ addr->destroy(addr);
}
break;
case FIL_TSTAMP:
@@ -710,11 +723,11 @@ static enumerator_t *create_lease_query(char *filter)
"AND (? OR (identities.type = ? AND identities.data = ?)) "
"AND (? OR address = ?)",
DB_INT, pool == NULL, DB_TEXT, pool,
- DB_INT, id == NULL,
- DB_INT, id ? id->get_type(id) : 0,
- DB_BLOB, id ? id->get_encoding(id) : chunk_empty,
- DB_INT, addr == NULL,
- DB_BLOB, addr ? addr->get_address(addr) : chunk_empty,
+ DB_INT, !id_chunk.ptr,
+ DB_INT, id_type,
+ DB_BLOB, id_chunk,
+ DB_INT, !addr_chunk.ptr,
+ DB_BLOB, addr_chunk,
DB_INT, tstamp == 0, DB_UINT, tstamp, DB_UINT, tstamp,
DB_INT, !valid, DB_INT, time(NULL),
DB_INT, !expired, DB_INT, time(NULL),
@@ -722,14 +735,13 @@ static enumerator_t *create_lease_query(char *filter)
/* union */
DB_INT, !(valid || expired),
DB_INT, pool == NULL, DB_TEXT, pool,
- DB_INT, id == NULL,
- DB_INT, id ? id->get_type(id) : 0,
- DB_BLOB, id ? id->get_encoding(id) : chunk_empty,
- DB_INT, addr == NULL,
- DB_BLOB, addr ? addr->get_address(addr) : chunk_empty,
+ DB_INT, !id_chunk.ptr,
+ DB_INT, id_type,
+ DB_BLOB, id_chunk,
+ DB_INT, !addr_chunk.ptr,
+ DB_BLOB, addr_chunk,
/* res */
DB_TEXT, DB_BLOB, DB_INT, DB_BLOB, DB_UINT, DB_UINT, DB_UINT);
- /* id and addr leak but we can't destroy them until query is destroyed. */
return query;
}
@@ -739,6 +751,7 @@ static enumerator_t *create_lease_query(char *filter)
static void leases(char *filter, bool utc)
{
enumerator_t *query;
+ array_t *to_free = NULL;
chunk_t address_chunk, identity_chunk;
int identity_type;
char *name;
@@ -748,7 +761,7 @@ static void leases(char *filter, bool utc)
identification_t *identity;
bool found = FALSE;
- query = create_lease_query(filter);
+ query = create_lease_query(filter, &to_free);
if (!query)
{
fprintf(stderr, "querying leases failed.\n");
@@ -809,6 +822,10 @@ static void leases(char *filter, bool utc)
identity->destroy(identity);
}
query->destroy(query);
+ if (to_free)
+ {
+ array_destroy_function(to_free, (void*)free, NULL);
+ }
if (!found)
{
fprintf(stderr, "no matching leases found.\n");