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)
committerJeremy Allison <jra@samba.org>
Fri, 25 Sep 2015 03:19:23 +0000 (05:19 +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>
source3/libads/ldap.c

index e8ccfa9c3d4c0826f3bec33cb7b9cb662e52589c..15385005e9a742a4b78a3049a09fb95700ff80fc 100644 (file)
@@ -2076,6 +2076,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);