summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-02-24 17:42:50 +0100
committerMichael Adam <obnox@samba.org>2009-02-26 13:22:51 +0100
commit62b53507d29b0679647f429c8d969167fe25122f (patch)
treed8b410a11f814ec6916ca842bba0656e01f388a5 /source3/registry
parente05b7a8627a085ebd2418bc52152130a97725535 (diff)
downloadsamba-62b53507d29b0679647f429c8d969167fe25122f.tar.gz
samba-62b53507d29b0679647f429c8d969167fe25122f.tar.bz2
samba-62b53507d29b0679647f429c8d969167fe25122f.zip
s3:registry: don't directly access key->subkeys->num_subkeys in reg_backend_db.
Use the reg_objects api instead. Michael
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_backend_db.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 5722240f24..fd17b44aab 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -619,7 +619,7 @@ done:
bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr)
{
- int num_subkeys, i;
+ int num_subkeys, old_num_subkeys, i;
char *path = NULL;
struct regsubkey_ctr *subkeys = NULL, *old_subkeys = NULL;
char *oldkeyname = NULL;
@@ -642,16 +642,18 @@ bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr)
regdb_fetch_keys(key, old_subkeys);
- if ((ctr->num_subkeys && old_subkeys->num_subkeys) &&
- (ctr->num_subkeys == old_subkeys->num_subkeys)) {
+ num_subkeys = regsubkey_ctr_numkeys(ctr);
+ old_num_subkeys = regsubkey_ctr_numkeys(old_subkeys);
+ if ((num_subkeys && old_num_subkeys) &&
+ (num_subkeys == old_num_subkeys)) {
- for (i = 0; i<ctr->num_subkeys; i++) {
+ for (i = 0; i < num_subkeys; i++) {
if (strcmp(ctr->subkeys[i],
old_subkeys->subkeys[i]) != 0) {
break;
}
}
- if (i == ctr->num_subkeys) {
+ if (i == num_subkeys) {
/*
* Nothing changed, no point to even start a tdb
* transaction
@@ -937,6 +939,7 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
char *p;
int i, res;
size_t len;
+ int num_subkeys;
if (regdb->transaction_start(regdb) != 0) {
DEBUG(0, ("create_sorted_subkeys: transaction_start "
@@ -954,14 +957,15 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
goto fail;
}
- sorted_subkeys = talloc_array(ctr, char *, ctr->num_subkeys);
+ num_subkeys = regsubkey_ctr_numkeys(ctr);
+ sorted_subkeys = talloc_array(ctr, char *, num_subkeys);
if (sorted_subkeys == NULL) {
goto fail;
}
- len = 4 + 4*ctr->num_subkeys;
+ len = 4 + 4*num_subkeys;
- for (i = 0; i<ctr->num_subkeys; i++) {
+ for (i = 0; i < num_subkeys; i++) {
sorted_subkeys[i] = talloc_strdup_upper(sorted_subkeys,
ctr->subkeys[i]);
if (sorted_subkeys[i] == NULL) {
@@ -970,17 +974,17 @@ static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
len += strlen(sorted_subkeys[i])+1;
}
- qsort(sorted_subkeys, ctr->num_subkeys, sizeof(char *), cmp_keynames);
+ qsort(sorted_subkeys, num_subkeys, sizeof(char *), cmp_keynames);
buf = talloc_array(ctr, char, len);
if (buf == NULL) {
goto fail;
}
- p = buf + 4 + 4*ctr->num_subkeys;
+ p = buf + 4 + 4*num_subkeys;
- SIVAL(buf, 0, ctr->num_subkeys);
+ SIVAL(buf, 0, num_subkeys);
- for (i=0; i<ctr->num_subkeys; i++) {
+ for (i=0; i < num_subkeys; i++) {
ptrdiff_t offset = p - buf;
SIVAL(buf, 4 + 4*i, offset);
strlcpy(p, sorted_subkeys[i], len-offset);