summaryrefslogtreecommitdiff
path: root/source4/lib/registry/ldb.c
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>2008-09-13 12:10:00 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-21 14:40:41 +0200
commitf58f74949d1c596a9c696dc71b325f7d4475fc5f (patch)
tree2a9eeb0ff04ff3bfd0e13ad3e5c2ae9c8f50e786 /source4/lib/registry/ldb.c
parent036b650ee4b4b32859c8ccfa797b20bbaa9a23e6 (diff)
downloadsamba-f58f74949d1c596a9c696dc71b325f7d4475fc5f.tar.gz
samba-f58f74949d1c596a9c696dc71b325f7d4475fc5f.tar.bz2
samba-f58f74949d1c596a9c696dc71b325f7d4475fc5f.zip
ldb_get_value_by_id: Fix the return of the default value
The return of the values of a certain key has been broken since I've introduced the default value. Now the behaviour is correct: If no default value exists, start with index zero to fetch the other values. Otherwise let zero be the default value and enumerate the others starting with one.
Diffstat (limited to 'source4/lib/registry/ldb.c')
-rw-r--r--source4/lib/registry/ldb.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 18054ac89b..42c99fbb24 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -1,7 +1,8 @@
/*
Unix SMB/CIFS implementation.
Registry interface
- Copyright (C) Jelmer Vernooij 2004-2007.
+ Copyright (C) 2004-2007, Jelmer Vernooij, jelmer@samba.org
+ Copyright (C) 2008 Matthias Dieter Wallnöfer, mwallnoefer@yahoo.de
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
@@ -318,23 +319,23 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, struct hive_key *k,
{
struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
- if (idx == 0) {
- /* default value */
- return ldb_get_default_value(mem_ctx, k, name, data_type, data);
- } else {
- /* normal value */
+ /* if default value exists, give it back */
+ if (W_ERROR_IS_OK(ldb_get_default_value(mem_ctx, k, name, data_type, data)))
+ if (idx == 0)
+ return WERR_OK;
+ else
+ --idx;
- /* Do the search if necessary */
- if (kd->values == NULL) {
- W_ERROR_NOT_OK_RETURN(cache_values(kd));
- }
+ /* Do the search if necessary */
+ if (kd->values == NULL) {
+ W_ERROR_NOT_OK_RETURN(cache_values(kd));
+ }
- if (idx >= kd->value_count)
- return WERR_NO_MORE_ITEMS;
+ if (idx >= kd->value_count)
+ return WERR_NO_MORE_ITEMS;
- reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm),
+ reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm),
kd->values[idx], name, data_type, data);
- }
return WERR_OK;
}