diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/registry/ldb.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index f3c6613383..02bfa46c8c 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -508,8 +508,10 @@ static WERROR ldb_get_default_value(TALLOC_CTX *mem_ctx, if (res->count == 0 || res->msgs[0]->num_elements == 0) return WERR_BADFILE; - reg_ldb_unpack_value(mem_ctx, - res->msgs[0], name, data_type, data); + if ((data_type != NULL) && (data != NULL)) { + reg_ldb_unpack_value(mem_ctx, res->msgs[0], name, data_type, + data); + } talloc_free(res); @@ -955,6 +957,9 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, uint32_t *max_valbufsize) { struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data); + uint32_t default_value_type = REG_NONE; + DATA_BLOB default_value = { NULL, 0 }; + WERROR werr; /* Initialization */ if (classname != NULL) @@ -972,6 +977,16 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, if (max_valbufsize != NULL) *max_valbufsize = 0; + /* We need this to get the default value (if it exists) for counting + * the values under the key and for finding out the longest value buffer + * size. If no default value exists the DATA_BLOB "default_value" will + * remain { NULL, 0 }. */ + werr = ldb_get_default_value(mem_ctx, key, NULL, &default_value_type, + &default_value); + if ((!W_ERROR_IS_OK(werr)) && (!W_ERROR_EQUAL(werr, WERR_BADFILE))) { + return werr; + } + if (kd->subkeys == NULL) { W_ERROR_NOT_OK_RETURN(cache_subkeys(kd)); } @@ -985,6 +1000,10 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, } if (num_values != NULL) { *num_values = kd->value_count; + /* also consider the default value if it exists */ + if (default_value.data != NULL) { + ++(*num_values); + } } @@ -1006,6 +1025,12 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, struct ldb_message_element *el; W_ERROR_NOT_OK_RETURN(cache_values(kd)); + /* also consider the default value if it exists */ + if ((max_valbufsize != NULL) && (default_value.data != NULL)) { + *max_valbufsize = MAX(*max_valbufsize, + default_value.length); + } + for (i = 0; i < kd->value_count; i++) { if (max_valnamelen != NULL) { el = ldb_msg_find_element(kd->values[i], "value"); @@ -1029,6 +1054,8 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, } } + talloc_free(default_value.data); + return WERR_OK; } |