s3-rpc_server: Fixed possible segfaults in svcctl server.
authorAndreas Schneider <asn@samba.org>
Tue, 8 Feb 2011 14:33:51 +0000 (15:33 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 10 Feb 2011 16:47:04 +0000 (17:47 +0100)
Signed-off-by: Günther Deschner <gd@samba.org>
source3/rpc_server/srv_svcctl_reg.c

index 7de47d8927e507277b265f3a857b6ccf2d8f5fae..ca6a68a2fd100415314c703c39d2fbb1be0969ee 100644 (file)
@@ -483,6 +483,7 @@ static bool svcctl_add_service(TALLOC_CTX *mem_ctx,
        if (is_valid_policy_hnd(&key_hnd)) {
                dcerpc_winreg_CloseKey(h, mem_ctx, &key_hnd, &result);
        }
+       ZERO_STRUCT(key_hnd);
 
        ZERO_STRUCT(wkey);
        wkey.name = talloc_asprintf(mem_ctx, "%s\\%s\\Security", key, name);
@@ -564,7 +565,13 @@ bool svcctl_init_winreg(struct messaging_context *msg_ctx)
 
        DEBUG(3, ("Initialise the svcctl registry keys if needed.\n"));
 
+       ZERO_STRUCT(hive_hnd);
+       ZERO_STRUCT(key_hnd);
+
        key = talloc_strdup(tmp_ctx, TOP_LEVEL_SERVICES_KEY);
+       if (key == NULL) {
+               goto done;
+       }
 
        status = dcerpc_winreg_int_hklm_openkey(tmp_ctx,
                                                get_server_info_system(),
@@ -653,6 +660,7 @@ bool svcctl_init_winreg(struct messaging_context *msg_ctx)
                if (is_valid_policy_hnd(&key_hnd)) {
                        dcerpc_winreg_CloseKey(h, tmp_ctx, &key_hnd, &result);
                }
+               ZERO_STRUCT(key_hnd);
 
                if (!ok) {
                        goto done;