summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-04-13 14:49:32 +0200
committerMichael Adam <obnox@samba.org>2008-04-13 15:33:47 +0200
commit5166d562eaf8896493f161c43408fd54a88f7c61 (patch)
tree6bd4bb28ff40755e7c12b77c0ed759aa5cacc096 /source3
parent01f4bd4f4d05e195911f4787f209b2ab6e2d8ab4 (diff)
downloadsamba-5166d562eaf8896493f161c43408fd54a88f7c61.tar.gz
samba-5166d562eaf8896493f161c43408fd54a88f7c61.tar.bz2
samba-5166d562eaf8896493f161c43408fd54a88f7c61.zip
registry cachehook: change helper function keyname_to_path() to return WERROR.
Michael (This used to be commit 78bb005ee45e7a0be24b5222c3f878058b5cd8ea)
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_cachehook.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/source3/registry/reg_cachehook.c b/source3/registry/reg_cachehook.c
index f407f310f7..66b9ae6c4e 100644
--- a/source3/registry/reg_cachehook.c
+++ b/source3/registry/reg_cachehook.c
@@ -28,26 +28,30 @@
static SORTED_TREE *cache_tree = NULL;
extern REGISTRY_OPS regdb_ops; /* these are the default */
-static char *keyname_to_path(TALLOC_CTX *mem_ctx, const char *keyname)
+static WERROR keyname_to_path(TALLOC_CTX *mem_ctx, const char *keyname,
+ char **path)
{
- char *path = NULL;
+ char *tmp_path = NULL;
- if ((keyname == NULL)) {
- return NULL;
+ if ((keyname == NULL) || (path == NULL)) {
+ return WERR_INVALID_PARAM;
}
- path = talloc_asprintf(mem_ctx, "\\%s", keyname);
- if (path == NULL) {
+ tmp_path = talloc_asprintf(mem_ctx, "\\%s", keyname);
+ if (tmp_path == NULL) {
DEBUG(0, ("talloc_asprintf failed!\n"));
- return NULL;
+ return WERR_NOMEM;
}
- path = talloc_string_sub(mem_ctx, path, "\\", "/");
- if (path == NULL) {
+ tmp_path = talloc_string_sub(mem_ctx, tmp_path, "\\", "/");
+ if (tmp_path == NULL) {
DEBUG(0, ("talloc_string_sub_failed!\n"));
+ return WERR_NOMEM;
}
- return path;
+ *path = tmp_path;
+
+ return WERR_OK;
}
/**********************************************************************
@@ -80,16 +84,21 @@ bool reghook_cache_add(const char *keyname, REGISTRY_OPS *ops)
WERROR werr;
char *key = NULL;
- key = keyname_to_path(talloc_tos(), keyname);
-
- if ((key == NULL) || (ops == NULL)) {
+ if ((keyname == NULL) || (ops == NULL)) {
return false;
}
+ werr = keyname_to_path(talloc_tos(), keyname, &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
DEBUG(10, ("reghook_cache_add: Adding ops %p for key [%s]\n",
(void *)ops, key));
werr = pathtree_add(cache_tree, key, ops);
+
+done:
TALLOC_FREE(key);
return W_ERROR_IS_OK(werr);
}
@@ -100,15 +109,19 @@ bool reghook_cache_add(const char *keyname, REGISTRY_OPS *ops)
REGISTRY_OPS *reghook_cache_find(const char *keyname)
{
- char *key;
- REGISTRY_OPS *ops;
-
- key = keyname_to_path(talloc_tos(), keyname);
+ WERROR werr;
+ char *key = NULL;
+ REGISTRY_OPS *ops = NULL;
- if (key == NULL) {
+ if (keyname == NULL) {
return NULL;
}
+ werr = keyname_to_path(talloc_tos(), keyname, &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
DEBUG(10,("reghook_cache_find: Searching for keyname [%s]\n", key));
ops = (REGISTRY_OPS *)pathtree_find(cache_tree, key);
@@ -116,6 +129,7 @@ REGISTRY_OPS *reghook_cache_find(const char *keyname)
DEBUG(10, ("reghook_cache_find: found ops %p for key [%s]\n",
ops ? (void *)ops : 0, key));
+done:
TALLOC_FREE(key);
return ops;