1 --- openchange-openchange-2.3-VULCAN/configure.ac.orig 2021-03-26 18:49:09.587370999 +0100
2 +++ openchange-openchange-2.3-VULCAN/configure.ac 2021-03-26 18:50:40.332056045 +0100
3 @@ -657,10 +657,11 @@ AC_CHECK_LIB([popt], [poptFreeContext],
8 if test x"$enable_libpopt" = x"yes"; then
9 if test x"$enable_libmapiadmin" = x"yes"; then
15 if test x"$enable_libocpf" = x"yes"; then
16 @@ -692,7 +693,7 @@ OC_RULE_ADD(mapipropsdump, TOOLS)
17 OC_RULE_ADD(exchange2ical, TOOLS)
18 OC_RULE_ADD(rpcextract, TOOLS)
19 OC_RULE_ADD(openchangepfadmin, TOOLS)
20 -OC_RULE_ADD(mapitest, TOOLS)
21 +#OC_RULE_ADD(mapitest, TOOLS)
22 OC_RULE_ADD(mapiprofile, TOOLS)
23 OC_RULE_ADD(openchangemapidump, TOOLS)
24 OC_RULE_ADD(schemaIDGUID, TOOLS)
25 diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c
26 --- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 2016-02-09 11:46:45.211994266 +0100
27 +++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c 2016-02-09 12:04:07.330950109 +0100
29 #include "libexchange2ical/libexchange2ical.h"
32 +static void openchange_all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
37 + if (!insert || !pattern || !s)
40 + ls = (ssize_t)strlen(s);
41 + lp = (ssize_t)strlen(pattern);
42 + li = (ssize_t)strlen(insert);
48 + len = ls + 1; /* len is number of *bytes* */
50 + while (lp <= ls && (p = strstr_m(s,pattern))) {
51 + if (ls + (li-lp) >= len) {
55 + memmove(p+li,p+lp,strlen(p+lp)+1);
57 + memcpy(p, insert, li);
66 @@ -1019,7 +1050,7 @@ void ical_property_RESOURCES(struct exch
67 if (!exchange2ical->NonSendableBcc) return;
69 NonSendableBcc = talloc_strdup(exchange2ical->mem_ctx, exchange2ical->NonSendableBcc);
70 - all_string_sub(NonSendableBcc, ";", ",", 0);
71 + openchange_all_string_sub(NonSendableBcc, ";", ",", 0);
72 prop = icalproperty_new_resources(NonSendableBcc);
73 icalcomponent_add_property(exchange2ical->vevent, prop);
74 talloc_free(NonSendableBcc);
75 diff -up openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c
76 --- openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 2015-05-16 17:22:04.000000000 +0200
77 +++ openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c 2016-02-08 22:19:17.750956440 +0100
79 along with this program. If not, see <http://www.gnu.org/licenses/>.
84 #include "libmapiadmin/libmapiadmin.h"
87 #include <credentials.h>
89 #include <ldb_errors.h>
91 -#include <ldap_ndr.h>
93 #include <gen_ndr/ndr_samr.h>
94 #include <gen_ndr/ndr_samr_c.h>
98 +static ssize_t openchange_sys_read(int fd, void *buf, size_t count)
103 + ret = read(fd, buf, count);
104 + } while (ret == -1 && (errno == EINTR || errno == EAGAIN ||
105 + errno == EWOULDBLOCK));
110 +static ssize_t openchange_read_data(int fd, void *buffer, size_t n)
116 + while (nread < n) {
118 + ret = openchange_sys_read(fd, ((char *)buffer) + nread, n - nread);
128 +static int openchange_urand_fd = -1;
129 +static void openchange_open_urandom(void)
131 + if (openchange_urand_fd != -1) {
134 + openchange_urand_fd = open( "/dev/urandom", O_RDONLY,0);
135 + if (openchange_urand_fd == -1) {
140 +static void openchange_generate_random_buffer(uint8_t *out, int len)
144 + openchange_open_urandom();
146 + rw_ret = openchange_read_data(openchange_urand_fd, out, len);
147 + if (rw_ret != len) {
152 +static enum ndr_err_code openchange_ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *r)
154 + uint32_t cntr_sub_auths_0;
155 + if (ndr_flags & NDR_SCALARS) {
156 + NDR_CHECK(ndr_push_align(ndr, 4));
157 + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->sid_rev_num));
158 + NDR_CHECK(ndr_push_int8(ndr, NDR_SCALARS, r->num_auths));
159 + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6));
160 + if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) {
161 + return ndr_push_error(ndr, NDR_ERR_RANGE, "value out of range");
163 + for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) {
164 + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sub_auths[cntr_sub_auths_0]));
167 + return NDR_ERR_SUCCESS;
170 +static char *openchange_ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
174 + struct ldb_val val;
175 + enum ndr_err_code ndr_err;
177 + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid,
178 + (ndr_push_flags_fn_t)openchange_ndr_push_dom_sid);
179 + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
182 + val.data = blob.data;
183 + val.length = blob.length;
184 + ret = ldb_binary_encode(mem_ctx, val);
185 + data_blob_free(&blob);
189 +static bool openchange_check_password_quality(const char *pwd)
192 + size_t num_chars = 0;
193 + size_t num_digits = 0;
194 + size_t num_upper = 0;
195 + size_t num_lower = 0;
196 + size_t num_nonalpha = 0;
197 + size_t num_unicode = 0;
198 + size_t num_categories = 0;
205 + const char *s = &pwd[ofs];
209 + c = next_codepoint(s, &len);
210 + if (c == INVALID_CODEPOINT) {
212 + } else if (c == 0) {
219 + const char *na = "~!@#$%^&*_-+=`|\\(){}[]:;\"'<>,.?/";
236 + if (strchr(na, c)) {
242 + * the rest does not belong to
248 + if (isupper_m(c)) {
253 + if (islower_m(c)) {
259 + * Note: for now do not check if the unicode category is
260 + * alphabetic character
262 + * We would have to import the details from
263 + * ftp://ftp.unicode.org/Public/6.3.0/ucd/UnicodeData-6.3.0d1.txt
269 + if (num_digits > 0) {
270 + num_categories += 1;
272 + if (num_upper > 0) {
273 + num_categories += 1;
275 + if (num_lower > 0) {
276 + num_categories += 1;
278 + if (num_nonalpha > 0) {
279 + num_categories += 1;
281 + if (num_unicode > 0) {
282 + num_categories += 1;
285 + if (num_categories >= 3) {
292 +static char *openchange_generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list)
295 + size_t list_len = strlen(list);
297 + char *retstr = talloc_array(mem_ctx, char, len + 1);
298 + if (!retstr) return NULL;
300 + openchange_generate_random_buffer((uint8_t *)retstr, len);
301 + for (i = 0; i < len; i++) {
302 + retstr[i] = list[retstr[i] % list_len];
309 +static char *openchange_generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
312 + const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
315 + retstr = openchange_generate_random_str_list(mem_ctx, len, c_list);
316 + if (!retstr) return NULL;
318 + /* we need to make sure the random string passes basic quality tests
319 + or it might be rejected by windows as a password */
320 + if (len >= 7 && !openchange_check_password_quality(retstr)) {
321 + talloc_free(retstr);
330 User management functions for mapiadmin
331 @@ -232,10 +464,10 @@ _PUBLIC_ enum MAPISTATUS mapiadmin_user_
332 /* Search the user_dn */
333 account_dn = samdb_search_dn(remote_ldb, mem_ctx, NULL,
334 "(&(objectSid=%s)(objectClass=user))",
335 - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
336 + openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
338 ret = ldb_search(remote_ldb, mem_ctx, &res, account_dn, LDB_SCOPE_SUBTREE, dom_attrs, "(objectSid=%s)",
339 - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
340 + openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
341 MAPI_RETVAL_IF(ret != LDB_SUCCESS, MAPI_E_NOT_FOUND, mem_ctx);
342 MAPI_RETVAL_IF(res->count != 1, MAPI_E_NOT_FOUND, mem_ctx);
344 @@ -422,7 +654,7 @@ again:
347 if (!mapiadmin_ctx->password) {
348 - mapiadmin_ctx->password = generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
349 + mapiadmin_ctx->password = openchange_generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
352 OC_DEBUG(3, "Setting account password '%s'", mapiadmin_ctx->password);
353 diff -up openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapidump.c
354 --- openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 2016-02-09 11:03:18.565104717 +0100
355 +++ openchange-openchange-2.3-VULCAN/libmapi/mapidump.c 2016-02-09 11:03:29.508104254 +0100
356 @@ -119,7 +119,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
357 data = get_SPropValue_data(&lpProp);
359 printf("%s%s:\n", sep?sep:"", proptag);
360 - dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
361 + oc_dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
363 printf("%s%s: (NULL)\n", sep?sep:"", proptag);
365 @@ -153,7 +153,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
366 printf("%s%s: ARRAY(%d)\n", sep?sep:"", proptag, BinaryArray_r->cValues);
367 for (i = 0; i < BinaryArray_r->cValues; i++) {
368 printf("\tPT_MV_BINARY [%d]:\n", i);
369 - dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
370 + oc_dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
374 diff -up openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c
375 --- openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 2016-02-09 11:02:57.062105628 +0100
376 +++ openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c 2016-02-09 11:03:01.012105461 +0100
377 @@ -412,7 +412,7 @@ _PUBLIC_ enum MAPISTATUS mapi_object_boo
379 OC_DEBUG(0, "mapi_object_bookmark {");
380 OC_DEBUG(0, ".index == %u", bookmark->index);
381 - dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
382 + oc_dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
385 bookmark = bookmark->next;
386 diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.c
387 --- openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 2016-02-09 10:49:20.292140237 +0100
388 +++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.c 2016-02-09 11:30:13.912036271 +0100
391 #include "libmapi/libmapi.h"
397 +#define MIN(a,b) ((a)<(b)?(a):(b))
400 int _oc_log_samba_level = 0;
402 @@ -84,3 +90,119 @@ void oc_log_init_server(const char *prog
404 setup_logging(progname, DEBUG_FILE);
407 +void oc_panic(const char *why)
410 + fprintf(stderr, "PANIC: %s\n", why);
416 +static void oc_debugadd_cb(const char *buf, void *private_data)
418 + int *plevel = (int *)private_data;
419 + if (plevel && *plevel <= _oc_log_samba_level) {
420 + printf ("%s", buf);
424 +static void oc_print_asc_cb(const uint8_t *buf, int len,
425 + void (*cb)(const char *buf, void *private_data),
426 + void *private_data)
432 + for (i=0; i<len; i++) {
433 + s[0] = isprint(buf[i]) ? buf[i] : '.';
434 + cb(s, private_data);
438 +static void oc_dump_data_cb(const uint8_t *buf, int len,
439 + bool omit_zero_bytes,
440 + void (*cb)(const char *buf, void *private_data),
441 + void *private_data)
444 + static const uint8_t empty[16] = { 0, };
445 + bool skipped = false;
448 + if (len<=0) return;
453 + if ((omit_zero_bytes == true) &&
456 + (memcmp(&buf[i], &empty, 16) == 0))
463 + snprintf(tmp, sizeof(tmp), "[%04X] ", i);
464 + cb(tmp, private_data);
468 + snprintf(tmp, sizeof(tmp), "%02X ", (int)buf[i]);
469 + cb(tmp, private_data);
472 + cb(" ", private_data);
476 + oc_print_asc_cb(&buf[i-16], 8, cb, private_data);
477 + cb(" ", private_data);
478 + oc_print_asc_cb(&buf[i-8], 8, cb, private_data);
479 + cb("\n", private_data);
481 + if ((omit_zero_bytes == true) &&
483 + (memcmp(&buf[i], &empty, 16) == 0)) {
485 + cb("skipping zero buffer bytes\n",
496 + cb(" ", private_data);
498 + cb(" ", private_data);
501 + cb(" ", private_data);
504 + oc_print_asc_cb(&buf[i-(i%16)], n, cb, private_data);
505 + cb(" ", private_data);
508 + oc_print_asc_cb(&buf[i-n], n, cb, private_data);
510 + cb("\n", private_data);
515 +void oc_dump_data(int level, const uint8_t *buf,int len)
517 + if (_oc_log_samba_level < level || !buf || !len)
520 + oc_dump_data_cb(buf, len, false, oc_debugadd_cb, &level);
522 diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.h
523 --- openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 2016-02-09 10:49:16.132140414 +0100
524 +++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.h 2016-02-09 10:51:57.121133592 +0100
525 @@ -79,4 +79,7 @@ void oc_log_init_server(const char *prog
527 extern int _oc_log_samba_level; /* Private, do not change it other than by SetMAPIDebugLevel() */
529 +void oc_panic(const char *why);
530 +void oc_dump_data(int level, const uint8_t *buf,int len);
532 #endif /* _OC_LOG_H_ */
533 diff -up openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/property.c
534 --- openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 2016-02-09 10:46:51.040146561 +0100
535 +++ openchange-openchange-2.3-VULCAN/libmapi/property.c 2016-02-09 10:48:47.626141621 +0100
536 @@ -777,7 +777,7 @@ _PUBLIC_ void mapi_copy_spropvalues(TALL
537 // TODO: Replace this with OC_PANIC() macro when it gets visible in libmapi too
538 OC_DEBUG(0, "Unexpected multi-value property type: %s.",
539 get_proptag_name(source_value->ulPropTag));
540 - smb_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
541 + oc_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
545 diff -up openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c
546 --- openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 2016-02-09 11:09:43.147088421 +0100
547 +++ openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c 2016-02-09 11:31:47.664032298 +0100
548 @@ -90,6 +90,213 @@ static void add_interface(TALLOC_CTX *me
549 OC_DEBUG(2, "added interface ip=%s nmask=%s", iface->ip_s, iface->nmask_s);
552 +enum oc_protocol_types {
553 + PROTOCOL_DEFAULT=-1,
570 +static int openchange_null_match(const char *p)
576 + *p != '>') return -1;
582 + the max_n structure is purely for efficiency, it doesn't contribute
583 + to the matching algorithm except by ensuring that the algorithm does
584 + not grow exponentially
587 + const char *predot;
588 + const char *postdot;
593 + p and n are the pattern and string being matched. The max_n array is
594 + an optimisation only. The ldot pointer is NULL if the string does
595 + not contain a '.', otherwise it points at the last dot in 'n'.
597 +static int openchange_ms_fnmatch_core(const char *p, const char *n,
598 + struct max_n *max_n, const char *ldot)
602 + size_t size, size_n;
604 + while ((c = next_codepoint(p, &size))) {
609 + /* a '*' matches zero or more characters of any type */
610 + if (max_n->predot && max_n->predot <= n) {
611 + return openchange_null_match(p);
613 + for (i=0; n[i]; i += size_n) {
614 + next_codepoint(n+i, &size_n);
615 + if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
619 + if (!max_n->predot || max_n->predot > n) max_n->predot = n;
620 + return openchange_null_match(p);
623 + /* a '<' matches zero or more characters of
624 + any type, but stops matching at the last
625 + '.' in the string. */
626 + if (max_n->predot && max_n->predot <= n) {
627 + return openchange_null_match(p);
629 + if (max_n->postdot && max_n->postdot <= n && n <= ldot) {
632 + for (i=0; n[i]; i += size_n) {
633 + next_codepoint(n+i, &size_n);
634 + if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
636 + if (openchange_ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
637 + if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
641 + if (!max_n->predot || max_n->predot > n) max_n->predot = n;
642 + return openchange_null_match(p);
645 + /* a '?' matches any single character */
649 + next_codepoint(n, &size_n);
654 + /* a '?' matches any single character, but
655 + treats '.' specially */
657 + if (! n[1] && openchange_null_match(p) == 0) {
662 + if (! *n) return openchange_null_match(p);
663 + next_codepoint(n, &size_n);
668 + /* a bit like a soft '.' */
669 + if (*n == 0 && openchange_null_match(p) == 0) {
672 + if (*n != '.') return -1;
673 + next_codepoint(n, &size_n);
678 + c2 = next_codepoint(n, &size_n);
679 + if (c != c2 && codepoint_cmpi(c, c2) != 0) {
694 +static int openchange_ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
697 + struct max_n *max_n = NULL;
699 + if (strcmp(string, "..") == 0) {
703 + if (strpbrk(pattern, "<>*?\"") == NULL) {
704 + /* this is not just an optimisation - it is essential
705 + for LANMAN1 correctness */
706 + return strcasecmp_m(pattern, string);
709 + if (protocol <= PROTOCOL_LANMAN2) {
710 + char *p = talloc_strdup(NULL, pattern);
715 + for older negotiated protocols it is possible to
716 + translate the pattern to produce a "new style"
717 + pattern that exactly matches w2k behaviour
719 + for (i=0;p[i];i++) {
722 + } else if (p[i] == '.' &&
727 + } else if (p[i] == '*' &&
732 + ret = openchange_ms_fnmatch_protocol(p, string, PROTOCOL_NT1);
737 + for (count=i=0;pattern[i];i++) {
738 + if (pattern[i] == '*' || pattern[i] == '<') count++;
741 + max_n = talloc_zero_array(NULL, struct max_n, count);
742 + if (max_n == NULL) {
746 + ret = openchange_ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
748 + talloc_free(max_n);
754 +/** a generic fnmatch function - uses for non-CIFS pattern matching */
755 +static int openchange_gen_fnmatch(const char *pattern, const char *string)
757 + return openchange_ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1);
762 @@ -119,7 +326,7 @@ static void interpret_interface(TALLOC_C
764 /* first check if it is an interface name */
765 for (i=0;i<total_probed;i++) {
766 - if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
767 + if (openchange_gen_fnmatch(token, probed_ifaces[i].name) == 0) {
768 add_interface(mem_ctx, probed_ifaces[i].ip,
769 probed_ifaces[i].netmask,
771 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
772 --- openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44 2015-05-16 17:22:04.000000000 +0200
773 +++ openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c 2016-02-08 17:43:52.578645298 +0100
775 #include "mapiproxy/libmapiserver/libmapiserver.h"
776 #include "mapiproxy/libmapiproxy/fault_util.h"
778 -#include <ldap_ndr.h>
780 /* Expose samdb_connect prototype */
781 struct ldb_context *samdb_connect(TALLOC_CTX *, struct tevent_context *,
782 struct loadparm_context *,
783 diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 openchange-openchange-2.3-VULCAN/ndr_mapi.c
784 --- openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 2016-02-09 11:04:30.054101688 +0100
785 +++ openchange-openchange-2.3-VULCAN/ndr_mapi.c 2016-02-09 11:04:49.763100853 +0100
786 @@ -1616,7 +1616,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
787 if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
788 ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
790 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
791 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
792 talloc_free(mapi_request);
795 @@ -1662,7 +1662,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
796 if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
797 ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
799 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
800 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
801 talloc_free(mapi_response);
804 @@ -1735,7 +1735,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
805 if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
806 ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
808 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
809 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
810 talloc_free(mapi_request);
813 @@ -1786,7 +1786,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
814 if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
815 ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
817 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
818 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
819 talloc_free(mapi_response);
822 @@ -2041,7 +2041,7 @@ _PUBLIC_ void ndr_print_SBinary_short(st
823 uint32_t _flags_save_STRUCT = ndr->flags;
824 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
826 - dump_data(0, r->lpb, r->cb);
827 + oc_dump_data(0, r->lpb, r->cb);
829 ndr->flags = _flags_save_STRUCT;
831 @@ -2054,7 +2054,7 @@ _PUBLIC_ void ndr_print_Binary_r(struct
832 uint32_t _flags_save_STRUCT = ndr->flags;
833 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
835 - dump_data(0, r->lpb, r->cb);
836 + oc_dump_data(0, r->lpb, r->cb);
838 ndr->flags = _flags_save_STRUCT;
840 diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c
841 --- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 2015-05-16 17:22:04.000000000 +0200
842 +++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c 2016-02-09 10:35:42.207174902 +0100
844 #include "gen_ndr/ndr_exchange.h"
847 +#include <sys/types.h>
848 +#include <sys/stat.h>
851 #define PLUGIN "libmapi.so"
853 @@ -97,6 +100,51 @@ static const const struct ndr_interface_
857 +static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
863 + if (fstat(fd, &sbuf) != 0) return NULL;
865 + size = sbuf.st_size;
868 + size = size < maxsize ? size : maxsize;
871 + p = (char *)talloc_size(mem_ctx, size+1);
872 + if (!p) return NULL;
874 + if (read(fd, p, size) != size) {
880 + if (psize) *psize = size;
885 +static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
890 + if (!fname || !*fname) return NULL;
892 + fd = open(fname,O_RDONLY);
893 + if (fd == -1) return NULL;
895 + p = openchange_fd_load(fd, size, maxsize, mem_ctx);
902 static struct SPropTagArray *process_request(TALLOC_CTX *mem_ctx,
903 const struct ndr_interface_call *f,
904 const char *filename,
905 @@ -123,7 +171,7 @@ static struct SPropTagArray *process_req
909 - data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
910 + data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
914 @@ -224,7 +272,7 @@ static int process_response(TALLOC_CTX *
918 - data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
919 + data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
923 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
924 --- openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44 2016-02-09 11:06:00.717097846 +0100
925 +++ openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c 2016-02-09 11:48:38.200989479 +0100
927 along with this program. If not, see <http://www.gnu.org/licenses/>.
930 +#include <sys/types.h>
931 +#include <sys/stat.h>
934 #include "utils/mapitest/mapitest.h"
935 #include "utils/mapitest/proto.h"
936 #include "gen_ndr/ndr_exchange.h"
937 +#include "libmapi/libmapi.h"
938 #include "libmapi/libmapi_private.h"
940 +static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
946 + if (fstat(fd, &sbuf) != 0) return NULL;
948 + size = sbuf.st_size;
951 + size = size < maxsize ? size : maxsize;
954 + p = (char *)talloc_size(mem_ctx, size+1);
955 + if (!p) return NULL;
957 + if (read(fd, p, size) != size) {
963 + if (psize) *psize = size;
968 +static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
973 + if (!fname || !*fname) return NULL;
975 + fd = open(fname,O_RDONLY);
976 + if (fd == -1) return NULL;
978 + p = openchange_fd_load(fd, size, maxsize, mem_ctx);
986 \file module_lzxpress.c
988 @@ -51,7 +101,7 @@ _PUBLIC_ bool mapitest_lzxpress_validate
989 /* Step 1. Load Test File 001_Outlook_2007_in_ModifyRecipients_comp.dat */
990 filename = talloc_asprintf(mt->mem_ctx, "%s/001_Outlook_2007_in_ModifyRecipients_comp.dat", LZXPRESS_DATADIR);
991 /* filename = talloc_asprintf(mt->mem_ctx, "%s/002_Outlook_2007_in_Tables_operations_comp.dat", LZXPRESS_DATADIR); */
992 - data = (uint8_t *)file_load(filename, &size, 0, mt->mem_ctx);
993 + data = (uint8_t *)openchange_file_load(filename, &size, 0, mt->mem_ctx);
996 mapitest_print_retval_fmt(mt, "lzxpress_validate", "Error while loading %s", filename);
997 @@ -137,12 +187,12 @@ _PUBLIC_ bool mapitest_lzxpress_validate
999 mapitest_print(mt, "Compressed rgbIn by Outlook\n");
1000 mapitest_print(mt, "==============================\n");
1001 - dump_data(0, r.in.rgbIn, r.in.cbIn);
1002 + oc_dump_data(0, r.in.rgbIn, r.in.cbIn);
1003 mapitest_print(mt, "==============================\n");
1005 mapitest_print(mt, "Compressed rgbIn by OpenChange\n");
1006 mapitest_print(mt, "==============================\n");
1007 - dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
1008 + oc_dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
1009 mapitest_print(mt, "==============================\n");
1011 talloc_free(ndr_rgbIn);
1012 diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 openchange-openchange-2.3-VULCAN/utils/openchangeclient.c
1013 --- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 2015-05-16 17:22:04.000000000 +0200
1014 +++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c 2016-02-08 22:24:59.212942206 +0100
1015 @@ -97,6 +97,52 @@ static void init_oclient(struct oclient
1016 oclient->ocpf_dump = NULL;
1019 +static char **openchange_str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
1021 + int num_elements = 0;
1022 + char **ret = NULL;
1024 + if (sep == NULL) {
1028 + ret = talloc_array(mem_ctx, char *, 1);
1029 + if (ret == NULL) {
1033 + while (string && *string) {
1034 + size_t len = strcspn(string, sep);
1038 + string += strspn(string, sep);
1042 + ret2 = talloc_realloc(mem_ctx, ret, char *,
1044 + if (ret2 == NULL) {
1050 + ret[num_elements] = talloc_strndup(ret, string, len);
1051 + if (ret[num_elements] == NULL) {
1060 + ret[num_elements] = NULL;
1065 static enum MAPISTATUS openchangeclient_getdir(TALLOC_CTX *mem_ctx,
1066 mapi_object_t *obj_container,
1067 mapi_object_t *obj_child,
1068 @@ -115,7 +161,7 @@ static enum MAPISTATUS openchangeclient_
1071 /* Step 1. Extract the folder list from full path */
1072 - folder = str_list_make(mem_ctx, path, "/");
1073 + folder = openchange_str_list_make(mem_ctx, path, "/");
1074 mapi_object_copy(&obj_folder, obj_container);
1076 for (i = 0; folder[i]; i++) {