summaryrefslogtreecommitdiff
path: root/source4/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/util')
-rw-r--r--source4/lib/util/genrand.c2
-rw-r--r--source4/lib/util/idtree.c16
-rw-r--r--source4/lib/util/util_ldb.c3
3 files changed, 17 insertions, 4 deletions
diff --git a/source4/lib/util/genrand.c b/source4/lib/util/genrand.c
index 7df4ec4e20..cd1823a9a0 100644
--- a/source4/lib/util/genrand.c
+++ b/source4/lib/util/genrand.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "system/filesys.h"
-#include "lib/crypto/crypto.h"
+#include "../lib/crypto/crypto.h"
#include "system/locale.h"
/**
diff --git a/source4/lib/util/idtree.c b/source4/lib/util/idtree.c
index 1e2cc2976a..193922973f 100644
--- a/source4/lib/util/idtree.c
+++ b/source4/lib/util/idtree.c
@@ -12,7 +12,7 @@
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 3 of the License, or
+ the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -105,12 +105,13 @@ static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id)
int n, m, sh;
struct idr_layer *p, *new;
struct idr_layer *pa[MAX_LEVEL];
- int l, id;
+ int l, id, oid;
uint32_t bm;
memset(pa, 0, sizeof(pa));
id = *starting_id;
+restart:
p = idp->top;
l = idp->layers;
pa[l--] = NULL;
@@ -124,12 +125,23 @@ static int sub_alloc(struct idr_context *idp, void *ptr, int *starting_id)
if (m == IDR_SIZE) {
/* no space available go back to previous layer. */
l++;
+ oid = id;
id = (id | ((1 << (IDR_BITS*l))-1)) + 1;
+
+ /* if already at the top layer, we need to grow */
if (!(p = pa[l])) {
*starting_id = id;
return -2;
}
+
+ /* If we need to go up one layer, continue the
+ * loop; otherwise, restart from the top.
+ */
+ sh = IDR_BITS * (l + 1);
+ if (oid >> sh == id >> sh)
continue;
+ else
+ goto restart;
}
if (m != n) {
sh = IDR_BITS*l;
diff --git a/source4/lib/util/util_ldb.c b/source4/lib/util/util_ldb.c
index fab729c036..0465022edd 100644
--- a/source4/lib/util/util_ldb.c
+++ b/source4/lib/util/util_ldb.c
@@ -52,7 +52,8 @@ int gendb_search_v(struct ldb_context *ldb,
res = NULL;
- ret = ldb_search(ldb, basedn, scope, expr, attrs, &res);
+ ret = ldb_search(ldb, mem_ctx, &res, basedn, scope, attrs,
+ expr?"%s":NULL, expr);
if (ret == LDB_SUCCESS) {
talloc_steal(mem_ctx, res->msgs);