From d4f1b08c935cc5c2c7509c50334d3b3f6cc3b371 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 9 Jul 2007 09:35:03 +0000 Subject: r23760: Untangle use of strrchr_m and strequal and add some checks for the validity of the given registry key name. Michael (This used to be commit 4b4ba7724ee77a93e32cd7f3c5884d965fe9bcaa) --- source3/utils/net_conf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/utils/net_conf.c') diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c index 4990541384..61bcb60aaf 100644 --- a/source3/utils/net_conf.c +++ b/source3/utils/net_conf.c @@ -151,6 +151,7 @@ static WERROR reg_setvalue_internal(struct registry_key *key, { struct registry_value val; WERROR werr = WERR_OK; + char *subkeyname; ZERO_STRUCT(val); @@ -171,12 +172,20 @@ static WERROR reg_setvalue_internal(struct registry_key *key, goto done; } - if (!strequal(strrchr_m(key->key->name, '\\')+1, GLOBAL_NAME) && + subkeyname = strrchr_m(key->key->name, '\\'); + if ((subkeyname == NULL) || (*(subkeyname +1) == '\0')) { + d_fprintf(stderr, "Invalid registry key '%s' given as " + "smbconf section.\n", key->key->name); + werr = WERR_INVALID_PARAM; + goto done; + } + subkeyname++; + if (!strequal(subkeyname, GLOBAL_NAME) && lp_parameter_is_global(valname)) { d_fprintf(stderr, "Global paramter '%s' not allowed in " "service definition ('%s').\n", valname, - strrchr_m(key->key->name, '\\')+1); + subkeyname); werr = WERR_INVALID_PARAM; goto done; } -- cgit