s3:libnet: accept empty realm for AD domains when only security=domain is set.
[samba.git] / source3 / libnet / libnet_samsync_passdb.c
index cb057a97f252be5fbd4a2590ad6889b6748e4ce9..91482e69f2e627acf88db00697f37599ff66ef17 100644 (file)
@@ -28,6 +28,7 @@
 #include "libnet/libnet_samsync.h"
 #include "../libcli/security/security.h"
 #include "passdb.h"
+#include "lib/util/base64.h"
 
 /* Convert a struct samu_DELTA to a struct samu. */
 #define STRING_CHANGED (old_string && !new_string) ||\
@@ -126,12 +127,15 @@ static NTSTATUS sam_account_from_delta(struct samu *account,
 
        if (r->parameters.array) {
                DATA_BLOB mung;
-               char *newstr;
+               char *newstr = NULL;
                old_string = pdb_get_munged_dial(account);
                mung.length = r->parameters.length * 2;
                mung.data = (uint8_t *) r->parameters.array;
-               newstr = (mung.length == 0) ? NULL :
-                       base64_encode_data_blob(talloc_tos(), mung);
+
+               if (mung.length != 0) {
+                       newstr = base64_encode_data_blob(talloc_tos(), mung);
+                       SMB_ASSERT(newstr != NULL);
+               }
 
                if (STRING_CHANGED_NC(old_string, newstr))
                        pdb_set_munged_dial(account, newstr, PDB_CHANGED);
@@ -689,9 +693,9 @@ static NTSTATUS fetch_domain_info(TALLOC_CTX *mem_ctx,
                        nt_errstr(status));
        }
 
-       u_max_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->max_password_age);
-       u_min_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->min_password_age);
-       u_logout = uint64s_nt_time_to_unix_abs((uint64 *)&r->force_logoff_time);
+       u_max_age = uint64s_nt_time_to_unix_abs((uint64_t *)&r->max_password_age);
+       u_min_age = uint64s_nt_time_to_unix_abs((uint64_t *)&r->min_password_age);
+       u_logout = uint64s_nt_time_to_unix_abs((uint64_t *)&r->force_logoff_time);
 
        domname = r->domain_name.string;
        if (!domname) {