From cab969d5ec67b1b3afbd4be2ff3a0d3cec45fd45 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 25 Feb 2013 15:13:19 +0100 Subject: s4-libregistry: Fix path check and improve while loops. Reviewed-by: David Disseldorp --- source4/lib/registry/local.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/lib') diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c index 98791743ae..79c398b68a 100644 --- a/source4/lib/registry/local.c +++ b/source4/lib/registry/local.c @@ -80,7 +80,7 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx, const char **elements = NULL; int el; - if (path == NULL) { + if (path == NULL || path[0] == '\0') { return WERR_INVALID_PARAM; } @@ -103,7 +103,7 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx, el = 0; } - while (curbegin != NULL && *curbegin) { + do { if (curend != NULL) *curend = '\0'; elements = talloc_realloc(mem_ctx, elements, const char *, el+2); @@ -124,7 +124,7 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx, break; curbegin = curend + 1; curend = strchr(curbegin, '\\'); - } + } while (curbegin != NULL && curbegin[0] != '\0'); talloc_free(orig); *result = reg_import_hive_key(local_parent->global.context, curkey, @@ -184,7 +184,7 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx, const char **elements = NULL; int el; - if (path == NULL) { + if (path == NULL || path[0] == '\0') { return WERR_INVALID_PARAM; } @@ -207,7 +207,7 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx, el = 0; } - while (curbegin != NULL && *curbegin) { + do { if (curend != NULL) *curend = '\0'; elements = talloc_realloc(mem_ctx, elements, const char *, el+2); @@ -233,7 +233,7 @@ static WERROR local_create_key(TALLOC_CTX *mem_ctx, break; curbegin = curend + 1; curend = strchr(curbegin, '\\'); - } + } while (curbegin != NULL && curbegin[0] != '\0'); talloc_free(orig); *result = reg_import_hive_key(local_parent->global.context, curkey, -- cgit