net: fix a crash with net ads keytab create
authorUri Simchoni <urisimchoni@gmail.com>
Wed, 23 Sep 2015 11:45:47 +0000 (14:45 +0300)
committerKarolin Seeger <kseeger@samba.org>
Mon, 5 Oct 2015 07:40:10 +0000 (09:40 +0200)
Fix a crash that happens when executing "net ads keytab create"
and the machine account in AD does not have setvice principal names
attached to it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11528

Signed-off-by: Uri Simchoni <urisimchoni@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit e224e622971853bddbe24df717ea5dcddef71b89)

source3/libads/ldap.c

index 70301de16fad894d511146e11e9040cdac479989..6031b421e984e924707e8be6c54f3563e8c3de23 100644 (file)
@@ -2004,6 +2004,13 @@ ADS_STATUS ads_get_service_principal_names(TALLOC_CTX *mem_ctx,
                                      res,
                                      "servicePrincipalName",
                                      num_spns);
+       if (*spn_array == NULL) {
+               DEBUG(1, ("Host account for %s does not have service principal "
+                         "names.\n",
+                         machine_name));
+               status = ADS_ERROR(LDAP_NO_SUCH_OBJECT);
+               goto done;
+       }
 
 done:
        ads_msgfree(ads, res);