Blame SOURCES/openchange-2.3-samba-4.4.patch

afa884
diff -up openchange-openchange-2.3-VULCAN/configure.ac.samba44 openchange-openchange-2.3-VULCAN/configure.ac
afa884
--- openchange-openchange-2.3-VULCAN/configure.ac.samba44	2016-02-09 11:51:31.089982153 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/configure.ac	2016-02-09 12:04:55.985948047 +0100
afa884
@@ -657,10 +657,11 @@ AC_CHECK_LIB([popt], [poptFreeContext],
afa884
 	       enable_libpopt="no"
afa884
              ])
afa884
 
afa884
+mapitest=0
afa884
 if test x"$enable_libpopt" = x"yes"; then
afa884
    	if test x"$enable_libmapiadmin" = x"yes"; then
afa884
 	   openchangepfadmin=1
afa884
-	   mapitest=1
afa884
+	   mapitest=0
afa884
 	fi
afa884
 
afa884
 	if test x"$enable_libocpf" = x"yes"; then
afa884
@@ -692,7 +693,7 @@ OC_RULE_ADD(mapipropsdump, TOOLS)
afa884
 OC_RULE_ADD(exchange2ical, TOOLS)
afa884
 #OC_RULE_ADD(rpcextract, TOOLS)
afa884
 OC_RULE_ADD(openchangepfadmin, TOOLS)
afa884
-OC_RULE_ADD(mapitest, TOOLS)
afa884
+#OC_RULE_ADD(mapitest, TOOLS)
afa884
 OC_RULE_ADD(mapiprofile, TOOLS)
afa884
 OC_RULE_ADD(openchangemapidump, TOOLS)
afa884
 OC_RULE_ADD(schemaIDGUID, TOOLS)
afa884
diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c
afa884
--- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44	2016-02-09 11:46:45.211994266 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c	2016-02-09 12:04:07.330950109 +0100
afa884
@@ -22,6 +22,37 @@
afa884
 #include "libexchange2ical/libexchange2ical.h"
afa884
 #include <ldb.h>
afa884
 
afa884
+static void openchange_all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
afa884
+{
afa884
+	char *p;
afa884
+	ssize_t ls,lp,li;
afa884
+
afa884
+	if (!insert || !pattern || !s)
afa884
+		return;
afa884
+
afa884
+	ls = (ssize_t)strlen(s);
afa884
+	lp = (ssize_t)strlen(pattern);
afa884
+	li = (ssize_t)strlen(insert);
afa884
+
afa884
+	if (!*pattern)
afa884
+		return;
afa884
+
afa884
+	if (len == 0)
afa884
+		len = ls + 1; /* len is number of *bytes* */
afa884
+
afa884
+	while (lp <= ls && (p = strstr_m(s,pattern))) {
afa884
+		if (ls + (li-lp) >= len) {
afa884
+			break;
afa884
+		}
afa884
+		if (li != lp) {
afa884
+			memmove(p+li,p+lp,strlen(p+lp)+1);
afa884
+		}
afa884
+		memcpy(p, insert, li);
afa884
+		s = p + li;
afa884
+		ls += (li-lp);
afa884
+	}
afa884
+}
afa884
+
afa884
 struct RRULE_byday {
afa884
 	uint16_t	DayOfWeek;
afa884
 	const char	*DayName;
afa884
@@ -1019,7 +1050,7 @@ void ical_property_RESOURCES(struct exch
afa884
 	if (!exchange2ical->NonSendableBcc) return;
afa884
 	
afa884
 	NonSendableBcc = talloc_strdup(exchange2ical->mem_ctx, exchange2ical->NonSendableBcc);
afa884
-	all_string_sub(NonSendableBcc, ";", ",", 0);
afa884
+	openchange_all_string_sub(NonSendableBcc, ";", ",", 0);
afa884
 	prop = icalproperty_new_resources(NonSendableBcc);
afa884
 	icalcomponent_add_property(exchange2ical->vevent, prop);
afa884
 	talloc_free(NonSendableBcc);
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c	2016-02-08 22:19:17.750956440 +0100
afa884
@@ -24,19 +24,251 @@
afa884
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
afa884
  */
afa884
 
afa884
+#include <ldb.h>
afa884
+
afa884
 #include "libmapiadmin/libmapiadmin.h"
afa884
 
afa884
 #include <param.h>
afa884
 #include <credentials.h>
afa884
+#include <ctype.h>
afa884
 #include <ldb_errors.h>
afa884
 #include <ldb_wrap.h>
afa884
-#include <ldap_ndr.h>
afa884
 
afa884
 #include <gen_ndr/ndr_samr.h>
afa884
 #include <gen_ndr/ndr_samr_c.h>
afa884
 
afa884
 #include <time.h>
afa884
 
afa884
+static ssize_t openchange_sys_read(int fd, void *buf, size_t count)
afa884
+{
afa884
+	ssize_t ret;
afa884
+
afa884
+	do {
afa884
+		ret = read(fd, buf, count);
afa884
+	} while (ret == -1 && (errno == EINTR || errno == EAGAIN ||
afa884
+			       errno == EWOULDBLOCK));
afa884
+
afa884
+	return ret;
afa884
+}
afa884
+
afa884
+static ssize_t openchange_read_data(int fd, void *buffer, size_t n)
afa884
+{
afa884
+	ssize_t nread;
afa884
+
afa884
+	nread = 0;
afa884
+
afa884
+	while (nread < n) {
afa884
+		ssize_t ret;
afa884
+		ret = openchange_sys_read(fd, ((char *)buffer) + nread, n - nread);
afa884
+		if (ret <= 0) {
afa884
+			return ret;
afa884
+		}
afa884
+		nread += ret;
afa884
+	}
afa884
+
afa884
+	return nread;
afa884
+}
afa884
+
afa884
+static int openchange_urand_fd = -1;
afa884
+static void openchange_open_urandom(void)
afa884
+{
afa884
+	if (openchange_urand_fd != -1) {
afa884
+		return;
afa884
+	}
afa884
+	openchange_urand_fd = open( "/dev/urandom", O_RDONLY,0);
afa884
+	if (openchange_urand_fd == -1) {
afa884
+		abort();
afa884
+	}
afa884
+}
afa884
+
afa884
+static void openchange_generate_random_buffer(uint8_t *out, int len)
afa884
+{
afa884
+	ssize_t rw_ret;
afa884
+
afa884
+	openchange_open_urandom();
afa884
+
afa884
+	rw_ret = openchange_read_data(openchange_urand_fd, out, len);
afa884
+	if (rw_ret != len) {
afa884
+		abort();
afa884
+	}
afa884
+}
afa884
+
afa884
+static enum ndr_err_code openchange_ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *r)
afa884
+{
afa884
+	uint32_t cntr_sub_auths_0;
afa884
+	if (ndr_flags & NDR_SCALARS) {
afa884
+		NDR_CHECK(ndr_push_align(ndr, 4));
afa884
+		NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->sid_rev_num));
afa884
+		NDR_CHECK(ndr_push_int8(ndr, NDR_SCALARS, r->num_auths));
afa884
+		NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6));
afa884
+		if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) {
afa884
+			return ndr_push_error(ndr, NDR_ERR_RANGE, "value out of range");
afa884
+		}
afa884
+		for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) {
afa884
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sub_auths[cntr_sub_auths_0]));
afa884
+		}
afa884
+	}
afa884
+	return NDR_ERR_SUCCESS;
afa884
+}
afa884
+
afa884
+static char *openchange_ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
afa884
+{
afa884
+#undef ldb_val
afa884
+	DATA_BLOB blob;
afa884
+	struct ldb_val val;
afa884
+	enum ndr_err_code ndr_err;
afa884
+	char *ret;
afa884
+	ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid,
afa884
+				       (ndr_push_flags_fn_t)openchange_ndr_push_dom_sid);
afa884
+	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
afa884
+		return NULL;
afa884
+	}
afa884
+	val.data = blob.data;
afa884
+	val.length = blob.length;
afa884
+	ret = ldb_binary_encode(mem_ctx, val);
afa884
+	data_blob_free(&blob;;
afa884
+	return ret;
afa884
+}
afa884
+
afa884
+static bool openchange_check_password_quality(const char *pwd)
afa884
+{
afa884
+	size_t ofs = 0;
afa884
+	size_t num_chars = 0;
afa884
+	size_t num_digits = 0;
afa884
+	size_t num_upper = 0;
afa884
+	size_t num_lower = 0;
afa884
+	size_t num_nonalpha = 0;
afa884
+	size_t num_unicode = 0;
afa884
+	size_t num_categories = 0;
afa884
+
afa884
+	if (pwd == NULL) {
afa884
+		return false;
afa884
+	}
afa884
+
afa884
+	while (true) {
afa884
+		const char *s = &pwd[ofs];
afa884
+		size_t len = 0;
afa884
+		codepoint_t c;
afa884
+
afa884
+		c = next_codepoint(s, &len;;
afa884
+		if (c == INVALID_CODEPOINT) {
afa884
+			return false;
afa884
+		} else if (c == 0) {
afa884
+			break;
afa884
+		}
afa884
+		ofs += len;
afa884
+		num_chars += 1;
afa884
+
afa884
+		if (len == 1) {
afa884
+			const char *na = "~!@#$%^&*_-+=`|\\(){}[]:;\"'<>,.?/";
afa884
+
afa884
+			if (isdigit(c)) {
afa884
+				num_digits += 1;
afa884
+				continue;
afa884
+			}
afa884
+
afa884
+			if (isupper(c)) {
afa884
+				num_upper += 1;
afa884
+				continue;
afa884
+			}
afa884
+
afa884
+			if (islower(c)) {
afa884
+				num_lower += 1;
afa884
+				continue;
afa884
+			}
afa884
+
afa884
+			if (strchr(na, c)) {
afa884
+				num_nonalpha += 1;
afa884
+				continue;
afa884
+			}
afa884
+
afa884
+			/*
afa884
+			 * the rest does not belong to
afa884
+			 * a category.
afa884
+			 */
afa884
+			continue;
afa884
+		}
afa884
+
afa884
+		if (isupper_m(c)) {
afa884
+			num_upper += 1;
afa884
+			continue;
afa884
+		}
afa884
+
afa884
+		if (islower_m(c)) {
afa884
+			num_lower += 1;
afa884
+			continue;
afa884
+		}
afa884
+
afa884
+		/*
afa884
+		 * Note: for now do not check if the unicode category is
afa884
+		 *       alphabetic character
afa884
+		 *
afa884
+		 * We would have to import the details from
afa884
+		 * ftp://ftp.unicode.org/Public/6.3.0/ucd/UnicodeData-6.3.0d1.txt
afa884
+		 */
afa884
+		num_unicode += 1;
afa884
+		continue;
afa884
+	}
afa884
+
afa884
+	if (num_digits > 0) {
afa884
+		num_categories += 1;
afa884
+	}
afa884
+	if (num_upper > 0) {
afa884
+		num_categories += 1;
afa884
+	}
afa884
+	if (num_lower > 0) {
afa884
+		num_categories += 1;
afa884
+	}
afa884
+	if (num_nonalpha > 0) {
afa884
+		num_categories += 1;
afa884
+	}
afa884
+	if (num_unicode > 0) {
afa884
+		num_categories += 1;
afa884
+	}
afa884
+
afa884
+	if (num_categories >= 3) {
afa884
+		return true;
afa884
+	}
afa884
+
afa884
+	return false;
afa884
+}
afa884
+
afa884
+static char *openchange_generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list)
afa884
+{
afa884
+	size_t i;
afa884
+	size_t list_len = strlen(list);
afa884
+
afa884
+	char *retstr = talloc_array(mem_ctx, char, len + 1);
afa884
+	if (!retstr) return NULL;
afa884
+
afa884
+	openchange_generate_random_buffer((uint8_t *)retstr, len);
afa884
+	for (i = 0; i < len; i++) {
afa884
+		retstr[i] = list[retstr[i] % list_len];
afa884
+	}
afa884
+	retstr[i] = '\0';
afa884
+
afa884
+	return retstr;
afa884
+}
afa884
+
afa884
+static char *openchange_generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
afa884
+{
afa884
+	char *retstr;
afa884
+	const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
afa884
+
afa884
+again:
afa884
+	retstr = openchange_generate_random_str_list(mem_ctx, len, c_list);
afa884
+	if (!retstr) return NULL;
afa884
+
afa884
+	/* we need to make sure the random string passes basic quality tests
afa884
+	   or it might be rejected by windows as a password */
afa884
+	if (len >= 7 && !openchange_check_password_quality(retstr)) {
afa884
+		talloc_free(retstr);
afa884
+		goto again;
afa884
+	}
afa884
+
afa884
+	return retstr;
afa884
+}
afa884
+
afa884
 /**
afa884
 	\file
afa884
 	User management functions for mapiadmin
afa884
@@ -232,10 +464,10 @@ _PUBLIC_ enum MAPISTATUS mapiadmin_user_
afa884
 	/* Search the user_dn */
afa884
 	account_dn = samdb_search_dn(remote_ldb, mem_ctx, NULL, 
afa884
 				     "(&(objectSid=%s)(objectClass=user))", 
afa884
-				     ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
afa884
+				     openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
afa884
 
afa884
 	ret = ldb_search(remote_ldb, mem_ctx, &res, account_dn, LDB_SCOPE_SUBTREE, dom_attrs, "(objectSid=%s)",
afa884
-			 ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
afa884
+			 openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
afa884
 	MAPI_RETVAL_IF(ret != LDB_SUCCESS, MAPI_E_NOT_FOUND, mem_ctx);
afa884
 	MAPI_RETVAL_IF(res->count != 1, MAPI_E_NOT_FOUND, mem_ctx);
afa884
 
afa884
@@ -422,7 +654,7 @@ again:
afa884
 	}
afa884
 
afa884
 	if (!mapiadmin_ctx->password) {
afa884
-		mapiadmin_ctx->password = generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
afa884
+		mapiadmin_ctx->password = openchange_generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
afa884
 	}
afa884
 
afa884
 	OC_DEBUG(3, "Setting account password '%s'", mapiadmin_ctx->password);
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapidump.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44	2016-02-09 11:03:18.565104717 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/mapidump.c	2016-02-09 11:03:29.508104254 +0100
afa884
@@ -119,7 +119,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
afa884
 		data = get_SPropValue_data(&lpProp);
afa884
 		if (data) {
afa884
 			printf("%s%s:\n", sep?sep:"", proptag);
afa884
-			dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
afa884
+			oc_dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
afa884
 		} else {
afa884
 			printf("%s%s: (NULL)\n", sep?sep:"", proptag);
afa884
 		}
afa884
@@ -153,7 +153,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
afa884
 		printf("%s%s: ARRAY(%d)\n", sep?sep:"", proptag, BinaryArray_r->cValues);
afa884
 		for (i = 0; i < BinaryArray_r->cValues; i++) {
afa884
 			printf("\tPT_MV_BINARY [%d]:\n", i);
afa884
-			dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
afa884
+			oc_dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
afa884
 		}
afa884
 		break;
afa884
 	default:
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44	2016-02-09 11:02:57.062105628 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c	2016-02-09 11:03:01.012105461 +0100
afa884
@@ -412,7 +412,7 @@ _PUBLIC_ enum MAPISTATUS mapi_object_boo
afa884
 	while (bookmark) {
afa884
 		OC_DEBUG(0, "mapi_object_bookmark {");
afa884
 		OC_DEBUG(0, ".index == %u", bookmark->index);
afa884
-		dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
afa884
+		oc_dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
afa884
 		OC_DEBUG(0, "};");
afa884
 
afa884
 		bookmark = bookmark->next;
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44	2016-02-09 10:49:20.292140237 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.c	2016-02-09 11:30:13.912036271 +0100
afa884
@@ -21,6 +21,12 @@
afa884
 
afa884
 #include "libmapi/libmapi.h"
afa884
 #include <stdio.h>
afa884
+#include <stdlib.h>
afa884
+#include <ctype.h>
afa884
+
afa884
+#ifndef MIN
afa884
+#define MIN(a,b) ((a)<(b)?(a):(b))
afa884
+#endif
afa884
 
afa884
 int _oc_log_samba_level = 0;
afa884
 
afa884
@@ -84,3 +90,119 @@ void oc_log_init_server(const char *prog
afa884
 {
afa884
 	setup_logging(progname, DEBUG_FILE);
afa884
 }
afa884
+
afa884
+void oc_panic(const char *why)
afa884
+{
afa884
+	if (why) {
afa884
+		fprintf(stderr, "PANIC: %s\n", why);
afa884
+		fflush(stderr);
afa884
+	}
afa884
+
afa884
+	abort();
afa884
+}
afa884
+static void oc_debugadd_cb(const char *buf, void *private_data)
afa884
+{
afa884
+	int *plevel = (int *)private_data;
afa884
+	if (plevel && *plevel <= _oc_log_samba_level) {
afa884
+		printf ("%s", buf);
afa884
+	}
afa884
+}
afa884
+
afa884
+static void oc_print_asc_cb(const uint8_t *buf, int len,
afa884
+			    void (*cb)(const char *buf, void *private_data),
afa884
+			    void *private_data)
afa884
+{
afa884
+	int i;
afa884
+	char s[2];
afa884
+	s[1] = 0;
afa884
+
afa884
+	for (i=0; i
afa884
+		s[0] = isprint(buf[i]) ? buf[i] : '.';
afa884
+		cb(s, private_data);
afa884
+	}
afa884
+}
afa884
+
afa884
+static void oc_dump_data_cb(const uint8_t *buf, int len,
afa884
+			    bool omit_zero_bytes,
afa884
+			    void (*cb)(const char *buf, void *private_data),
afa884
+			    void *private_data)
afa884
+{
afa884
+	int i=0;
afa884
+	static const uint8_t empty[16] = { 0, };
afa884
+	bool skipped = false;
afa884
+	char tmp[16];
afa884
+
afa884
+	if (len<=0) return;
afa884
+
afa884
+	for (i=0;i
afa884
+
afa884
+		if (i%16 == 0) {
afa884
+			if ((omit_zero_bytes == true) &&
afa884
+			    (i > 0) &&
afa884
+			    (len > i+16) &&
afa884
+			    (memcmp(&buf[i], &empty, 16) == 0))
afa884
+			{
afa884
+				i +=16;
afa884
+				continue;
afa884
+			}
afa884
+
afa884
+			if (i
afa884
+				snprintf(tmp, sizeof(tmp), "[%04X] ", i);
afa884
+				cb(tmp, private_data);
afa884
+			}
afa884
+		}
afa884
+
afa884
+		snprintf(tmp, sizeof(tmp), "%02X ", (int)buf[i]);
afa884
+		cb(tmp, private_data);
afa884
+		i++;
afa884
+		if (i%8 == 0) {
afa884
+			cb("  ", private_data);
afa884
+		}
afa884
+		if (i%16 == 0) {
afa884
+
afa884
+			oc_print_asc_cb(&buf[i-16], 8, cb, private_data);
afa884
+			cb(" ", private_data);
afa884
+			oc_print_asc_cb(&buf[i-8], 8, cb, private_data);
afa884
+			cb("\n", private_data);
afa884
+
afa884
+			if ((omit_zero_bytes == true) &&
afa884
+			    (len > i+16) &&
afa884
+			    (memcmp(&buf[i], &empty, 16) == 0)) {
afa884
+				if (!skipped) {
afa884
+					cb("skipping zero buffer bytes\n",
afa884
+					   private_data);
afa884
+					skipped = true;
afa884
+				}
afa884
+			}
afa884
+		}
afa884
+	}
afa884
+
afa884
+	if (i%16) {
afa884
+		int n;
afa884
+		n = 16 - (i%16);
afa884
+		cb("  ", private_data);
afa884
+		if (n>8) {
afa884
+			cb(" ", private_data);
afa884
+		}
afa884
+		while (n--) {
afa884
+			cb("   ", private_data);
afa884
+		}
afa884
+		n = MIN(8,i%16);
afa884
+		oc_print_asc_cb(&buf[i-(i%16)], n, cb, private_data);
afa884
+		cb(" ", private_data);
afa884
+		n = (i%16) - n;
afa884
+		if (n>0) {
afa884
+			oc_print_asc_cb(&buf[i-n], n, cb, private_data);
afa884
+		}
afa884
+		cb("\n", private_data);
afa884
+	}
afa884
+
afa884
+}
afa884
+
afa884
+void oc_dump_data(int level, const uint8_t *buf,int len)
afa884
+{
afa884
+	if (_oc_log_samba_level < level || !buf || !len)
afa884
+		return;
afa884
+
afa884
+	oc_dump_data_cb(buf, len, false, oc_debugadd_cb, &level);
afa884
+}
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.h
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44	2016-02-09 10:49:16.132140414 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.h	2016-02-09 10:51:57.121133592 +0100
afa884
@@ -79,4 +79,7 @@ void oc_log_init_server(const char *prog
afa884
 
afa884
 extern int _oc_log_samba_level; /* Private, do not change it other than by SetMAPIDebugLevel() */
afa884
 
afa884
+void oc_panic(const char *why);
afa884
+void oc_dump_data(int level, const uint8_t *buf,int len);
afa884
+
afa884
 #endif /* _OC_LOG_H_ */
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/property.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44	2016-02-09 10:46:51.040146561 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/property.c	2016-02-09 10:48:47.626141621 +0100
afa884
@@ -777,7 +777,7 @@ _PUBLIC_ void mapi_copy_spropvalues(TALL
afa884
 				// TODO: Replace this with OC_PANIC() macro when it gets visible in libmapi too
afa884
 				OC_DEBUG(0, "Unexpected multi-value property type: %s.",
afa884
 						get_proptag_name(source_value->ulPropTag));
afa884
-				smb_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
afa884
+				oc_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
afa884
 			}
afa884
 		}
afa884
 	}
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44	2016-02-09 11:09:43.147088421 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c	2016-02-09 11:31:47.664032298 +0100
afa884
@@ -90,6 +90,213 @@ static void add_interface(TALLOC_CTX *me
afa884
 	OC_DEBUG(2, "added interface ip=%s nmask=%s", iface->ip_s, iface->nmask_s);
afa884
 }
afa884
 
afa884
+enum oc_protocol_types {
afa884
+	PROTOCOL_DEFAULT=-1,
afa884
+	PROTOCOL_NONE=0,
afa884
+	PROTOCOL_CORE,
afa884
+	PROTOCOL_COREPLUS,
afa884
+	PROTOCOL_LANMAN1,
afa884
+	PROTOCOL_LANMAN2,
afa884
+	PROTOCOL_NT1,
afa884
+	PROTOCOL_SMB2_02,
afa884
+	PROTOCOL_SMB2_10,
afa884
+	PROTOCOL_SMB2_22,
afa884
+	PROTOCOL_SMB2_24,
afa884
+	PROTOCOL_SMB3_00,
afa884
+	PROTOCOL_SMB3_02,
afa884
+	PROTOCOL_SMB3_10,
afa884
+	PROTOCOL_SMB3_11
afa884
+};
afa884
+
afa884
+static int openchange_null_match(const char *p)
afa884
+{
afa884
+	for (;*p;p++) {
afa884
+		if (*p != '*' &&
afa884
+		    *p != '<' &&
afa884
+		    *p != '"' &&
afa884
+		    *p != '>') return -1;
afa884
+	}
afa884
+	return 0;
afa884
+}
afa884
+
afa884
+/*
afa884
+  the max_n structure is purely for efficiency, it doesn't contribute
afa884
+  to the matching algorithm except by ensuring that the algorithm does
afa884
+  not grow exponentially
afa884
+*/
afa884
+struct max_n {
afa884
+	const char *predot;
afa884
+	const char *postdot;
afa884
+};
afa884
+
afa884
+
afa884
+/*
afa884
+  p and n are the pattern and string being matched. The max_n array is
afa884
+  an optimisation only. The ldot pointer is NULL if the string does
afa884
+  not contain a '.', otherwise it points at the last dot in 'n'.
afa884
+*/
afa884
+static int openchange_ms_fnmatch_core(const char *p, const char *n, 
afa884
+				      struct max_n *max_n, const char *ldot)
afa884
+{
afa884
+	codepoint_t c, c2;
afa884
+	int i;
afa884
+	size_t size, size_n;
afa884
+
afa884
+	while ((c = next_codepoint(p, &size))) {
afa884
+		p += size;
afa884
+
afa884
+		switch (c) {
afa884
+		case '*':
afa884
+			/* a '*' matches zero or more characters of any type */
afa884
+			if (max_n->predot && max_n->predot <= n) {
afa884
+				return openchange_null_match(p);
afa884
+			}
afa884
+			for (i=0; n[i]; i += size_n) {
afa884
+				next_codepoint(n+i, &size_n);
afa884
+				if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
afa884
+					return 0;
afa884
+				}
afa884
+			}
afa884
+			if (!max_n->predot || max_n->predot > n) max_n->predot = n;
afa884
+			return openchange_null_match(p);
afa884
+
afa884
+		case '<':
afa884
+			/* a '<' matches zero or more characters of
afa884
+			   any type, but stops matching at the last
afa884
+			   '.' in the string. */
afa884
+			if (max_n->predot && max_n->predot <= n) {
afa884
+				return openchange_null_match(p);
afa884
+			}
afa884
+			if (max_n->postdot && max_n->postdot <= n && n <= ldot) {
afa884
+				return -1;
afa884
+			}
afa884
+			for (i=0; n[i]; i += size_n) {
afa884
+				next_codepoint(n+i, &size_n);
afa884
+				if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
afa884
+				if (n+i == ldot) {
afa884
+					if (openchange_ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
afa884
+					if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
afa884
+					return -1;
afa884
+				}
afa884
+			}
afa884
+			if (!max_n->predot || max_n->predot > n) max_n->predot = n;
afa884
+			return openchange_null_match(p);
afa884
+
afa884
+		case '?':
afa884
+			/* a '?' matches any single character */
afa884
+			if (! *n) {
afa884
+				return -1;
afa884
+			}
afa884
+			next_codepoint(n, &size_n);
afa884
+			n += size_n;
afa884
+			break;
afa884
+
afa884
+		case '>':
afa884
+			/* a '?' matches any single character, but
afa884
+			   treats '.' specially */
afa884
+			if (n[0] == '.') {
afa884
+				if (! n[1] && openchange_null_match(p) == 0) {
afa884
+					return 0;
afa884
+				}
afa884
+				break;
afa884
+			}
afa884
+			if (! *n) return openchange_null_match(p);
afa884
+			next_codepoint(n, &size_n);
afa884
+			n += size_n;
afa884
+			break;
afa884
+
afa884
+		case '"':
afa884
+			/* a bit like a soft '.' */
afa884
+			if (*n == 0 && openchange_null_match(p) == 0) {
afa884
+				return 0;
afa884
+			}
afa884
+			if (*n != '.') return -1;
afa884
+			next_codepoint(n, &size_n);
afa884
+			n += size_n;
afa884
+			break;
afa884
+
afa884
+		default:
afa884
+			c2 = next_codepoint(n, &size_n);
afa884
+			if (c != c2 && codepoint_cmpi(c, c2) != 0) {
afa884
+				return -1;
afa884
+			}
afa884
+			n += size_n;
afa884
+			break;
afa884
+		}
afa884
+	}
afa884
+	
afa884
+	if (! *n) {
afa884
+		return 0;
afa884
+	}
afa884
+	
afa884
+	return -1;
afa884
+}
afa884
+
afa884
+static int openchange_ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
afa884
+{
afa884
+	int ret, count, i;
afa884
+	struct max_n *max_n = NULL;
afa884
+
afa884
+	if (strcmp(string, "..") == 0) {
afa884
+		string = ".";
afa884
+	}
afa884
+
afa884
+	if (strpbrk(pattern, "<>*?\"") == NULL) {
afa884
+		/* this is not just an optimisation - it is essential
afa884
+		   for LANMAN1 correctness */
afa884
+		return strcasecmp_m(pattern, string);
afa884
+	}
afa884
+
afa884
+	if (protocol <= PROTOCOL_LANMAN2) {
afa884
+		char *p = talloc_strdup(NULL, pattern);
afa884
+		if (p == NULL) {
afa884
+			return -1;
afa884
+		}
afa884
+		/*
afa884
+		  for older negotiated protocols it is possible to
afa884
+		  translate the pattern to produce a "new style"
afa884
+		  pattern that exactly matches w2k behaviour
afa884
+		*/
afa884
+		for (i=0;p[i];i++) {
afa884
+			if (p[i] == '?') {
afa884
+				p[i] = '>';
afa884
+			} else if (p[i] == '.' && 
afa884
+				   (p[i+1] == '?' || 
afa884
+				    p[i+1] == '*' ||
afa884
+				    p[i+1] == 0)) {
afa884
+				p[i] = '"';
afa884
+			} else if (p[i] == '*' && 
afa884
+				   p[i+1] == '.') {
afa884
+				p[i] = '<';
afa884
+			}
afa884
+		}
afa884
+		ret = openchange_ms_fnmatch_protocol(p, string, PROTOCOL_NT1);
afa884
+		talloc_free(p);
afa884
+		return ret;
afa884
+	}
afa884
+
afa884
+	for (count=i=0;pattern[i];i++) {
afa884
+		if (pattern[i] == '*' || pattern[i] == '<') count++;
afa884
+	}
afa884
+
afa884
+	max_n = talloc_zero_array(NULL, struct max_n, count);
afa884
+	if (max_n == NULL) {
afa884
+		return -1;
afa884
+	}
afa884
+
afa884
+	ret = openchange_ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
afa884
+
afa884
+	talloc_free(max_n);
afa884
+
afa884
+	return ret;
afa884
+}
afa884
+
afa884
+
afa884
+/** a generic fnmatch function - uses for non-CIFS pattern matching */
afa884
+static int openchange_gen_fnmatch(const char *pattern, const char *string)
afa884
+{
afa884
+	return openchange_ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1);
afa884
+}
afa884
 
afa884
 
afa884
 /**
afa884
@@ -119,7 +326,7 @@ static void interpret_interface(TALLOC_C
afa884
 	
afa884
 	/* first check if it is an interface name */
afa884
 	for (i=0;i
afa884
-		if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
afa884
+		if (openchange_gen_fnmatch(token, probed_ifaces[i].name) == 0) {
afa884
 			add_interface(mem_ctx, probed_ifaces[i].ip,
afa884
 				      probed_ifaces[i].netmask,
afa884
 				      local_interfaces);
afa884
diff -up openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44 openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c
afa884
--- openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c	2016-02-08 17:43:52.578645298 +0100
afa884
@@ -31,8 +31,6 @@
afa884
 #include "mapiproxy/libmapiserver/libmapiserver.h"
afa884
 #include "mapiproxy/libmapiproxy/fault_util.h"
afa884
 
afa884
-#include <ldap_ndr.h>
afa884
-
afa884
 /* Expose samdb_connect prototype */
afa884
 struct ldb_context *samdb_connect(TALLOC_CTX *, struct tevent_context *,
afa884
 				  struct loadparm_context *,
afa884
diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 openchange-openchange-2.3-VULCAN/ndr_mapi.c
afa884
--- openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44	2016-02-09 11:04:30.054101688 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/ndr_mapi.c	2016-02-09 11:04:49.763100853 +0100
afa884
@@ -1616,7 +1616,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
afa884
 				if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
afa884
 					ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
afa884
 				} else {
afa884
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
 					talloc_free(mapi_request);
afa884
 					break;
afa884
 				}
afa884
@@ -1662,7 +1662,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
afa884
 				if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
afa884
 					ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
afa884
 				} else {
afa884
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
 					talloc_free(mapi_response);
afa884
 					break;
afa884
 				}
afa884
@@ -1735,7 +1735,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
afa884
 				if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
afa884
 					ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
afa884
 				} else {
afa884
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
 					talloc_free(mapi_request);
afa884
 					return;
afa884
 				}
afa884
@@ -1786,7 +1786,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
afa884
 				if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
afa884
 					ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
afa884
 				} else {
afa884
-					dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
+					oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
afa884
 					talloc_free(mapi_response);
afa884
 					break;
afa884
 				}
afa884
@@ -2041,7 +2041,7 @@ _PUBLIC_ void ndr_print_SBinary_short(st
afa884
 		uint32_t _flags_save_STRUCT = ndr->flags;
afa884
 		ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
afa884
 		ndr->depth++;
afa884
-		dump_data(0, r->lpb, r->cb);
afa884
+		oc_dump_data(0, r->lpb, r->cb);
afa884
 		ndr->depth--;
afa884
 		ndr->flags = _flags_save_STRUCT;
afa884
 	}
afa884
@@ -2054,7 +2054,7 @@ _PUBLIC_ void ndr_print_Binary_r(struct
afa884
 		uint32_t _flags_save_STRUCT = ndr->flags;
afa884
 		ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
afa884
 		ndr->depth++;
afa884
-		dump_data(0, r->lpb, r->cb);
afa884
+		oc_dump_data(0, r->lpb, r->cb);
afa884
 		ndr->depth--;
afa884
 		ndr->flags = _flags_save_STRUCT;
afa884
 	}
afa884
diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c
afa884
--- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c	2016-02-09 10:35:42.207174902 +0100
afa884
@@ -24,6 +24,9 @@
afa884
 #include "gen_ndr/ndr_exchange.h"
afa884
 #include <popt.h>
afa884
 #include <dlfcn.h>
afa884
+#include <sys/types.h>
afa884
+#include <sys/stat.h>
afa884
+#include <unistd.h>
afa884
 
afa884
 #define	PLUGIN		"libmapi.so"
afa884
 #define	FUNCTION	0xB
afa884
@@ -97,6 +100,51 @@ static const const struct ndr_interface_
afa884
 	return p;
afa884
 }
afa884
 
afa884
+static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
afa884
+{
afa884
+	struct stat sbuf;
afa884
+	char *p;
afa884
+	size_t size;
afa884
+
afa884
+	if (fstat(fd, &sbuf) != 0) return NULL;
afa884
+
afa884
+	size = sbuf.st_size;
afa884
+
afa884
+	if (maxsize) {
afa884
+		size = size < maxsize ? size : maxsize;
afa884
+	}
afa884
+
afa884
+	p = (char *)talloc_size(mem_ctx, size+1);
afa884
+	if (!p) return NULL;
afa884
+
afa884
+	if (read(fd, p, size) != size) {
afa884
+		talloc_free(p);
afa884
+		return NULL;
afa884
+	}
afa884
+	p[size] = 0;
afa884
+
afa884
+	if (psize) *psize = size;
afa884
+
afa884
+	return p;
afa884
+}
afa884
+
afa884
+static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
afa884
+{
afa884
+	int fd;
afa884
+	char *p;
afa884
+
afa884
+	if (!fname || !*fname) return NULL;
afa884
+
afa884
+	fd = open(fname,O_RDONLY);
afa884
+	if (fd == -1) return NULL;
afa884
+
afa884
+	p = openchange_fd_load(fd, size, maxsize, mem_ctx);
afa884
+
afa884
+	close(fd);
afa884
+
afa884
+	return p;
afa884
+}
afa884
+
afa884
 static struct SPropTagArray *process_request(TALLOC_CTX *mem_ctx,
afa884
 					     const struct ndr_interface_call *f,
afa884
 					     const char *filename,
afa884
@@ -123,7 +171,7 @@ static struct SPropTagArray *process_req
afa884
 		return NULL;
afa884
 	}
afa884
 
afa884
-	data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
afa884
+	data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
afa884
 	if (!data) {
afa884
 		perror(filename);
afa884
 		return NULL;
afa884
@@ -224,7 +272,7 @@ static int process_response(TALLOC_CTX *
afa884
 		return -1;
afa884
 	}
afa884
 
afa884
-	data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
afa884
+	data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
afa884
 	if (!data) {
afa884
 		perror(filename);
afa884
 		return -1;
afa884
diff -up openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c
afa884
--- openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44	2016-02-09 11:06:00.717097846 +0100
afa884
+++ openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c	2016-02-09 11:48:38.200989479 +0100
afa884
@@ -19,11 +19,61 @@
afa884
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
afa884
 */
afa884
 
afa884
+#include <sys/types.h>
afa884
+#include <sys/stat.h>
afa884
+#include <unistd.h>
afa884
+
afa884
 #include "utils/mapitest/mapitest.h"
afa884
 #include "utils/mapitest/proto.h"
afa884
 #include "gen_ndr/ndr_exchange.h"
afa884
+#include "libmapi/libmapi.h"
afa884
 #include "libmapi/libmapi_private.h"
afa884
 
afa884
+static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
afa884
+{
afa884
+	struct stat sbuf;
afa884
+	char *p;
afa884
+	size_t size;
afa884
+
afa884
+	if (fstat(fd, &sbuf) != 0) return NULL;
afa884
+
afa884
+	size = sbuf.st_size;
afa884
+
afa884
+	if (maxsize) {
afa884
+		size = size < maxsize ? size : maxsize;
afa884
+	}
afa884
+
afa884
+	p = (char *)talloc_size(mem_ctx, size+1);
afa884
+	if (!p) return NULL;
afa884
+
afa884
+	if (read(fd, p, size) != size) {
afa884
+		talloc_free(p);
afa884
+		return NULL;
afa884
+	}
afa884
+	p[size] = 0;
afa884
+
afa884
+	if (psize) *psize = size;
afa884
+
afa884
+	return p;
afa884
+}
afa884
+
afa884
+static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
afa884
+{
afa884
+	int fd;
afa884
+	char *p;
afa884
+
afa884
+	if (!fname || !*fname) return NULL;
afa884
+
afa884
+	fd = open(fname,O_RDONLY);
afa884
+	if (fd == -1) return NULL;
afa884
+
afa884
+	p = openchange_fd_load(fd, size, maxsize, mem_ctx);
afa884
+
afa884
+	close(fd);
afa884
+
afa884
+	return p;
afa884
+}
afa884
+
afa884
 /**
afa884
    \file module_lzxpress.c
afa884
 
afa884
@@ -51,7 +101,7 @@ _PUBLIC_ bool mapitest_lzxpress_validate
afa884
 	/* Step 1. Load Test File 001_Outlook_2007_in_ModifyRecipients_comp.dat */
afa884
 	filename = talloc_asprintf(mt->mem_ctx, "%s/001_Outlook_2007_in_ModifyRecipients_comp.dat", LZXPRESS_DATADIR);
afa884
 /* 	filename = talloc_asprintf(mt->mem_ctx, "%s/002_Outlook_2007_in_Tables_operations_comp.dat", LZXPRESS_DATADIR); */
afa884
-	data = (uint8_t *)file_load(filename, &size, 0, mt->mem_ctx);
afa884
+	data = (uint8_t *)openchange_file_load(filename, &size, 0, mt->mem_ctx);
afa884
 	if (!data) {
afa884
 		perror(filename);
afa884
 		mapitest_print_retval_fmt(mt, "lzxpress_validate", "Error while loading %s", filename);
afa884
@@ -137,12 +187,12 @@ _PUBLIC_ bool mapitest_lzxpress_validate
afa884
 
afa884
 	mapitest_print(mt, "Compressed rgbIn by Outlook\n");
afa884
 	mapitest_print(mt, "==============================\n");
afa884
-	dump_data(0, r.in.rgbIn, r.in.cbIn);
afa884
+	oc_dump_data(0, r.in.rgbIn, r.in.cbIn);
afa884
 	mapitest_print(mt, "==============================\n");
afa884
 
afa884
 	mapitest_print(mt, "Compressed rgbIn by OpenChange\n");
afa884
 	mapitest_print(mt, "==============================\n");
afa884
-	dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
afa884
+	oc_dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
afa884
 	mapitest_print(mt, "==============================\n");
afa884
 
afa884
 	talloc_free(ndr_rgbIn);
afa884
diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 openchange-openchange-2.3-VULCAN/utils/openchangeclient.c
afa884
--- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c	2016-02-08 22:24:59.212942206 +0100
afa884
@@ -97,6 +97,52 @@ static void init_oclient(struct oclient
afa884
 	oclient->ocpf_dump = NULL;
afa884
 }
afa884
 
afa884
+static char **openchange_str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
afa884
+{
afa884
+	int num_elements = 0;
afa884
+	char **ret = NULL;
afa884
+
afa884
+	if (sep == NULL) {
afa884
+		sep = " \t,\n\r";
afa884
+	}
afa884
+
afa884
+	ret = talloc_array(mem_ctx, char *, 1);
afa884
+	if (ret == NULL) {
afa884
+		return NULL;
afa884
+	}
afa884
+
afa884
+	while (string && *string) {
afa884
+		size_t len = strcspn(string, sep);
afa884
+		char **ret2;
afa884
+		
afa884
+		if (len == 0) {
afa884
+			string += strspn(string, sep);
afa884
+			continue;
afa884
+		}
afa884
+
afa884
+		ret2 = talloc_realloc(mem_ctx, ret, char *,
afa884
+			num_elements+2);
afa884
+		if (ret2 == NULL) {
afa884
+			talloc_free(ret);
afa884
+			return NULL;
afa884
+		}
afa884
+		ret = ret2;
afa884
+
afa884
+		ret[num_elements] = talloc_strndup(ret, string, len);
afa884
+		if (ret[num_elements] == NULL) {
afa884
+			talloc_free(ret);
afa884
+			return NULL;
afa884
+		}
afa884
+
afa884
+		num_elements++;
afa884
+		string += len;
afa884
+	}
afa884
+
afa884
+	ret[num_elements] = NULL;
afa884
+
afa884
+	return ret;
afa884
+}
afa884
+
afa884
 static enum MAPISTATUS openchangeclient_getdir(TALLOC_CTX *mem_ctx,
afa884
 					       mapi_object_t *obj_container,
afa884
 					       mapi_object_t *obj_child,
afa884
@@ -115,7 +161,7 @@ static enum MAPISTATUS openchangeclient_
afa884
 	uint32_t		i;
afa884
 
afa884
 	/* Step 1. Extract the folder list from full path */
afa884
-	folder = str_list_make(mem_ctx, path, "/");
afa884
+	folder = openchange_str_list_make(mem_ctx, path, "/");
afa884
 	mapi_object_copy(&obj_folder, obj_container);
afa884
 
afa884
 	for (i = 0; folder[i]; i++) {