summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-03-07 12:02:48 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:59 -0500
commit3e88cae57bd473b492735f90be86940e44e0e78d (patch)
tree4d113993d1dc51a716d8834d3f53488afb7fc963
parent983306c819d0ea439a7a702420c37609ce928294 (diff)
downloadsamba-3e88cae57bd473b492735f90be86940e44e0e78d.tar.gz
samba-3e88cae57bd473b492735f90be86940e44e0e78d.tar.bz2
samba-3e88cae57bd473b492735f90be86940e44e0e78d.zip
r5680: Don't crash if none of the predefined keys is available (reported by Alexander)
(This used to be commit 0d789872a890062b0b95aa039bb853bb6c07b2d0)
-rw-r--r--source4/lib/registry/tools/regshell.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index ac7dbca49b..ee80837bab 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -408,8 +408,34 @@ static char **reg_completion(const char *text, int start, int end)
}
if (h) {
- /*FIXME: What if HKEY_CLASSES_ROOT is not present ? */
- reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey);
+ enum reg_predefined_key try_hkeys[] = {
+ HKEY_CLASSES_ROOT,
+ HKEY_CURRENT_USER,
+ HKEY_LOCAL_MACHINE,
+ HKEY_USERS,
+ HKEY_PERFORMANCE_DATA,
+ HKEY_CURRENT_CONFIG,
+ HKEY_DYN_DATA,
+ HKEY_PERFORMANCE_TEXT,
+ HKEY_PERFORMANCE_NLSTEXT,
+ 0
+ };
+ int i;
+
+ for (i = 0; try_hkeys[i]; i++) {
+ WERROR err;
+ err = reg_get_predefined_key(h, HKEY_CLASSES_ROOT, &curkey);
+ if (W_ERROR_IS_OK(err)) {
+ break;
+ } else {
+ curkey = NULL;
+ }
+ }
+ }
+
+ if (!curkey) {
+ fprintf(stderr, "Unable to access any of the predefined keys\n");
+ return -1;
}
poptFreeContext(pc);