auth: Make sure error_string is not used uninitialized
authorAndreas Schneider <asn@cryptomilk.org>
Tue, 19 May 2015 08:35:47 +0000 (10:35 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 19 May 2015 11:42:32 +0000 (13:42 +0200)
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Simo Sorce <idra@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue May 19 13:42:32 CEST 2015 on sn-devel-104

auth/credentials/credentials_secrets.c

index 5945ffdb4a1a292a852dcb545037236a4604ce91..784e3454a7e7d069c9f907488b6a291c638fc7d0 100644 (file)
@@ -270,7 +270,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
 {
        NTSTATUS status;
        char *filter;
-       char *error_string;
+       char *error_string = NULL;
        const char *domain;
        bool secrets_tdb_password_more_recent;
        time_t secrets_tdb_lct = 0;
@@ -372,7 +372,8 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
                                = talloc_asprintf(cred,
                                                  "Failed to fetch machine account password for %s from both "
                                                  "secrets.ldb (%s) and from %s",
-                                                 domain, error_string,
+                                                 domain,
+                                                 error_string == NULL ? "error" : error_string,
                                                  dbwrap_name(db_ctx));
                } else {
                        char *secrets_tdb_path;
@@ -387,10 +388,12 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account_db_ctx(struct cli_credenti
                        error_string = talloc_asprintf(cred,
                                                       "Failed to fetch machine account password from "
                                                       "secrets.ldb: %s and failed to open %s",
-                                                      error_string, secrets_tdb_path);
+                                                      error_string == NULL ? "error" : error_string,
+                                                      secrets_tdb_path);
                }
-               DEBUG(1, ("Could not find machine account in secrets database: %s: %s\n", 
-                         error_string, nt_errstr(status)));
+               DEBUG(1, ("Could not find machine account in secrets database: %s: %s\n",
+                         error_string == NULL ? "error" : error_string,
+                         nt_errstr(status)));
                /* set anonymous as the fallback, if the machine account won't work */
                cli_credentials_set_anonymous(cred);
        }