summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/sqlite
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2017-05-30 20:59:31 +0200
committerYves-Alexis Perez <corsac@corsac.net>2017-05-30 20:59:31 +0200
commitbba25e2ff6c4a193acb54560ea4417537bd2954e (patch)
tree9e074fe343f9ab6f5ce1e9c5142d9a6cf180fcda /src/libstrongswan/plugins/sqlite
parent05ddd767992d68bb38c7f16ece142e8c2e9ae016 (diff)
downloadvyos-strongswan-bba25e2ff6c4a193acb54560ea4417537bd2954e.tar.gz
vyos-strongswan-bba25e2ff6c4a193acb54560ea4417537bd2954e.zip
New upstream version 5.5.3
Diffstat (limited to 'src/libstrongswan/plugins/sqlite')
-rw-r--r--src/libstrongswan/plugins/sqlite/Makefile.in2
-rw-r--r--src/libstrongswan/plugins/sqlite/sqlite_database.c33
2 files changed, 17 insertions, 18 deletions
diff --git a/src/libstrongswan/plugins/sqlite/Makefile.in b/src/libstrongswan/plugins/sqlite/Makefile.in
index 8ffc4aae0..5e23cb91c 100644
--- a/src/libstrongswan/plugins/sqlite/Makefile.in
+++ b/src/libstrongswan/plugins/sqlite/Makefile.in
@@ -358,6 +358,7 @@ docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
fips_mode = @fips_mode@
+fuzz_plugins = @fuzz_plugins@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
host = @host@
@@ -380,6 +381,7 @@ json_CFLAGS = @json_CFLAGS@
json_LIBS = @json_LIBS@
libdir = @libdir@
libexecdir = @libexecdir@
+libfuzzer = @libfuzzer@
libiptc_CFLAGS = @libiptc_CFLAGS@
libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
diff --git a/src/libstrongswan/plugins/sqlite/sqlite_database.c b/src/libstrongswan/plugins/sqlite/sqlite_database.c
index 0a35e3017..9f874212e 100644
--- a/src/libstrongswan/plugins/sqlite/sqlite_database.c
+++ b/src/libstrongswan/plugins/sqlite/sqlite_database.c
@@ -174,10 +174,8 @@ typedef struct {
private_sqlite_database_t *database;
} sqlite_enumerator_t;
-/**
- * destroy a sqlite enumerator
- */
-static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
+METHOD(enumerator_t, sqlite_enumerator_destroy, void,
+ sqlite_enumerator_t *this)
{
sqlite3_finalize(this->stmt);
if (!is_threadsave())
@@ -188,13 +186,10 @@ static void sqlite_enumerator_destroy(sqlite_enumerator_t *this)
free(this);
}
-/**
- * Implementation of database.query().enumerate
- */
-static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
+METHOD(enumerator_t, sqlite_enumerator_enumerate, bool,
+ sqlite_enumerator_t *this, va_list args)
{
int i;
- va_list args;
switch (sqlite3_step(this->stmt))
{
@@ -207,7 +202,7 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
case SQLITE_DONE:
return FALSE;
}
- va_start(args, this);
+
for (i = 0; i < this->count; i++)
{
switch (this->columns[i])
@@ -245,11 +240,9 @@ static bool sqlite_enumerator_enumerate(sqlite_enumerator_t *this, ...)
}
default:
DBG1(DBG_LIB, "invalid result type supplied");
- va_end(args);
return FALSE;
}
}
- va_end(args);
return TRUE;
}
@@ -270,13 +263,17 @@ METHOD(database_t, query, enumerator_t*,
stmt = run(this, sql, &args);
if (stmt)
{
- enumerator = malloc_thing(sqlite_enumerator_t);
- enumerator->public.enumerate = (void*)sqlite_enumerator_enumerate;
- enumerator->public.destroy = (void*)sqlite_enumerator_destroy;
- enumerator->stmt = stmt;
- enumerator->count = sqlite3_column_count(stmt);
+ INIT(enumerator,
+ .public = {
+ .enumerate = enumerator_enumerate_default,
+ .venumerate = _sqlite_enumerator_enumerate,
+ .destroy = _sqlite_enumerator_destroy,
+ },
+ .stmt = stmt,
+ .count = sqlite3_column_count(stmt),
+ .database = this,
+ );
enumerator->columns = malloc(sizeof(db_type_t) * enumerator->count);
- enumerator->database = this;
for (i = 0; i < enumerator->count; i++)
{
enumerator->columns[i] = va_arg(args, db_type_t);