Fix crash when get_gpo_info returns incorrect data.
authorWilco Baan Hofman <wilco@baanhofman.nl>
Wed, 19 May 2010 16:31:19 +0000 (18:31 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 20 Jun 2010 15:19:12 +0000 (17:19 +0200)
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
source4/lib/policy/gp_ldap.c
source4/lib/policy/gp_manage.c

index b8b24d4c8609037f56b91ee4b590e316c0bc615b..5ef161d12c2780e0514b0575e3fcce4804082cc6 100644 (file)
@@ -62,11 +62,18 @@ static NTSTATUS parse_gpo(TALLOC_CTX *mem_ctx, struct ldb_message *msg, struct g
 
        DEBUG(9, ("Parsing GPO LDAP data for %s\n", gpo->dn));
 
-       gpo->display_name = talloc_steal(mem_ctx, ldb_msg_find_attr_as_string(msg, "displayName", ""));
-       gpo->name = talloc_steal(mem_ctx, ldb_msg_find_attr_as_string(msg, "name", ""));
+       gpo->display_name = ldb_msg_find_attr_as_string(msg, "displayName", "");
+       gpo->name = ldb_msg_find_attr_as_string(msg, "name", "");
        gpo->flags = ldb_msg_find_attr_as_uint(msg, "name", 0);
        gpo->version = ldb_msg_find_attr_as_uint(msg, "version", 0);
-       gpo->file_sys_path = talloc_steal(mem_ctx, ldb_msg_find_attr_as_string(msg, "gPCFileSysPath", ""));
+       gpo->file_sys_path = ldb_msg_find_attr_as_string(msg, "gPCFileSysPath", "");
+
+       if (gpo->display_name[0] != '\0')
+               gpo->display_name = talloc_steal(mem_ctx, gpo->display_name);
+       if (gpo->name[0] != '\0')
+               gpo->name = talloc_steal(mem_ctx, gpo->name);
+       if (gpo->file_sys_path[0] != '\0')
+               gpo->file_sys_path = talloc_steal(mem_ctx, gpo->file_sys_path);
 
        /* Pull the security descriptor through the NDR library */
        data = ldb_msg_find_ldb_val(msg, "nTSecurityDescriptor");
@@ -792,8 +799,6 @@ NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
        rv = ldb_msg_add_string(msg, "gpCFunctionalityVersion", "2");
        if (rv != LDB_SUCCESS) goto ldb_msg_add_error;
 
-       /* FIXME Add security descriptor as well */
-
        rv = ldb_add(gp_ctx->ldb_ctx, msg);
        if (rv != LDB_SUCCESS) {
                DEBUG(0, ("LDB add error: %s\n", ldb_errstring(gp_ctx->ldb_ctx)));
@@ -853,6 +858,7 @@ NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
                return NT_STATUS_UNSUCCESSFUL;
        }
 
+       gpo->dn = talloc_steal(gpo, ldb_dn_get_linearized(gpo_dn));
 
        talloc_free(mem_ctx);
        return NT_STATUS_OK;
index 7313ab25579afca04a8275b7e39bee777a614d7d..580f87116de36d687152d71fa2ce53c06078c72d 100644 (file)
@@ -134,6 +134,7 @@ NTSTATUS gp_create_gpo (struct gp_context *gp_ctx, const char *display_name, str
                name[i] = toupper(name[i]);
        }
 
+       gpo->dn = NULL;
        gpo->name = name;
        gpo->flags = 0;
        gpo->version = 0;