s3:registry: Prevent creation of keys containing the '/' character.
authorMichael Adam <obnox@samba.org>
Fri, 17 Apr 2009 09:40:17 +0000 (11:40 +0200)
committerKarolin Seeger <kseeger@samba.org>
Fri, 17 Apr 2009 14:14:33 +0000 (16:14 +0200)
This creates a broken registry that can only be fixed with
tdbtool, since the '/' sign is used as a key separator after
normalization at a lower level.

This makes e.g. "net conf setparm abc/def comment xyz" fail with
WERR_INVALID_PARAM, which is much more desirable than a broken
registry.tdb.

Michael
(cherry picked from commit 943b33587c9905e0b6b6ee090fe9bf9bdfc77465)

source/registry/reg_api.c

index c49ee03fab7ebf16bcf07c1ba5e5f68b1086fea0..0f12c786c3e7b9240bf29aa2c13e6d83b3e3293d 100644 (file)
@@ -459,6 +459,16 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
        char *path, *end;
        WERROR err;
 
+       /*
+        * We must refuse to handle subkey-paths containing
+        * a '/' character because at a lower level, after
+        * normalization, '/' is treated as a key separator
+        * just like '\\'.
+        */
+       if (strchr(subkeypath, '/') != NULL) {
+               return WERR_INVALID_PARAM;
+       }
+
        if (!(mem_ctx = talloc_new(ctx))) return WERR_NOMEM;
 
        if (!(path = talloc_strdup(mem_ctx, subkeypath))) {