summaryrefslogtreecommitdiff
path: root/src/db.c
diff options
context:
space:
mode:
authorTom Hromatka <tom.hromatka@oracle.com>2018-04-05 14:57:23 -0400
committerPaul Moore <paul@paul-moore.com>2018-04-05 14:57:23 -0400
commitcf98f79d0894221beb9f2753c092304237617c1c (patch)
treed1f64b22466d955e59ec6d795aa0c44693a3e610 /src/db.c
parentc14558ec0c8edcd92974adba43543d2d4f20e7f1 (diff)
downloadlibseccomp-cf98f79d0894221beb9f2753c092304237617c1c.tar.gz
db: applied pcmoore's gist for GH issue #112
Note that as cited in the gist, this commit is not ready to be committed yet. Specifically: * investigate _db_tree_prune(), that likely needs some logic (lt/gt) flipping to compensate for the changes in _db_tree_add() * run the full regression test to ensure we aren't accidentally breaking anything * separate patch to add this test case to the regression tests * separate patch to clear up the macros in src/db.h, see db_chain_lt() as an example Full gist is here: https://gist.github.com/pcmoore/f644341a85c6ad7131a26f68f99e3fc6 Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com> [PM: subject line tweak, testing has proven this commit is OK and necessary to restore proper db ordering, also fix the 'make check-syntax' errors] Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'src/db.c')
-rw-r--r--src/db.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/db.c b/src/db.c
index 1793e1d..a4b2f92 100644
--- a/src/db.c
+++ b/src/db.c
@@ -619,7 +619,7 @@ static int _db_tree_add(struct db_arg_chain_tree **existing,
}
return 0;
- } else if (db_chain_lt(x_iter, n_iter)) {
+ } else if (!db_chain_lt(x_iter, n_iter)) {
/* try to move along the current level */
if (x_iter->lvl_nxt == NULL) {
/* add to the end of this level */
@@ -640,6 +640,8 @@ static int _db_tree_add(struct db_arg_chain_tree **existing,
n_iter->lvl_prv = x_iter->lvl_prv;
n_iter->lvl_nxt = x_iter;
x_iter->lvl_prv = n_iter;
+ if (*existing == x_iter)
+ *existing = n_iter;
return 0;
}
} while (x_iter);