From ad83995de5df5a738c2fdad48866e226533b9b0a Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sun, 21 Mar 2010 15:33:52 +0100 Subject: s4:registry - "LDB backend" - reg_key_get_info - adapt max. subkey and value length Those lengths are measured in UTF8 string lengths and not in UTF16 ones (the returned strings are generally in this format). Discovered this by checking the s3 registry code. Therefore we have to multiply the both numbers by two. Discovered with the "regedt32" (old NT registry editor). --- source4/lib/registry/ldb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/registry/ldb.c') diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 5f1a06c501..46b340da88 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -991,12 +991,13 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, unsigned int i; struct ldb_message_element *el; - *max_subkeynamelen = 0; - for (i = 0; i < kd->subkey_count; i++) { el = ldb_msg_find_element(kd->subkeys[i], "key"); *max_subkeynamelen = MAX(*max_subkeynamelen, el->values[0].length); } + + /* for UTF16 encoding */ + *max_subkeynamelen *= 2; } if (max_valnamelen != NULL || max_valbufsize != NULL) { @@ -1004,12 +1005,6 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, struct ldb_message_element *el; W_ERROR_NOT_OK_RETURN(cache_values(kd)); - if (max_valbufsize != NULL) - *max_valbufsize = 0; - - if (max_valnamelen != NULL) - *max_valnamelen = 0; - for (i = 0; i < kd->value_count; i++) { if (max_valnamelen != NULL) { el = ldb_msg_find_element(kd->values[i], "value"); @@ -1026,6 +1021,11 @@ static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, talloc_free(data.data); } } + + if (max_valnamelen != NULL) { + /* for UTF16 encoding */ + *max_valnamelen *= 2; + } } return WERR_OK; -- cgit