1 diff -up openchange-openchange-2.3-VULCAN/configure.ac.samba44 openchange-openchange-2.3-VULCAN/configure.ac
2 --- openchange-openchange-2.3-VULCAN/configure.ac.samba44 2016-02-09 11:51:31.089982153 +0100
3 +++ openchange-openchange-2.3-VULCAN/configure.ac 2016-02-09 12:04:55.985948047 +0100
4 @@ -657,10 +657,11 @@ AC_CHECK_LIB([popt], [poptFreeContext],
9 if test x"$enable_libpopt" = x"yes"; then
10 if test x"$enable_libmapiadmin" = x"yes"; then
16 if test x"$enable_libocpf" = x"yes"; then
17 @@ -692,7 +693,7 @@ OC_RULE_ADD(mapipropsdump, TOOLS)
18 OC_RULE_ADD(exchange2ical, TOOLS)
19 #OC_RULE_ADD(rpcextract, TOOLS)
20 OC_RULE_ADD(openchangepfadmin, TOOLS)
21 -OC_RULE_ADD(mapitest, TOOLS)
22 +#OC_RULE_ADD(mapitest, TOOLS)
23 OC_RULE_ADD(mapiprofile, TOOLS)
24 OC_RULE_ADD(openchangemapidump, TOOLS)
25 OC_RULE_ADD(schemaIDGUID, TOOLS)
26 diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c
27 --- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.samba44 2016-02-09 11:46:45.211994266 +0100
28 +++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c 2016-02-09 12:04:07.330950109 +0100
30 #include "libexchange2ical/libexchange2ical.h"
33 +static void openchange_all_string_sub(char *s,const char *pattern,const char *insert, size_t len)
38 + if (!insert || !pattern || !s)
41 + ls = (ssize_t)strlen(s);
42 + lp = (ssize_t)strlen(pattern);
43 + li = (ssize_t)strlen(insert);
49 + len = ls + 1; /* len is number of *bytes* */
51 + while (lp <= ls && (p = strstr_m(s,pattern))) {
52 + if (ls + (li-lp) >= len) {
56 + memmove(p+li,p+lp,strlen(p+lp)+1);
58 + memcpy(p, insert, li);
67 @@ -1019,7 +1050,7 @@ void ical_property_RESOURCES(struct exch
68 if (!exchange2ical->NonSendableBcc) return;
70 NonSendableBcc = talloc_strdup(exchange2ical->mem_ctx, exchange2ical->NonSendableBcc);
71 - all_string_sub(NonSendableBcc, ";", ",", 0);
72 + openchange_all_string_sub(NonSendableBcc, ";", ",", 0);
73 prop = icalproperty_new_resources(NonSendableBcc);
74 icalcomponent_add_property(exchange2ical->vevent, prop);
75 talloc_free(NonSendableBcc);
76 diff -up openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c
77 --- openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c.samba44 2015-05-16 17:22:04.000000000 +0200
78 +++ openchange-openchange-2.3-VULCAN/libmapiadmin/mapiadmin_user.c 2016-02-08 22:19:17.750956440 +0100
80 along with this program. If not, see <http://www.gnu.org/licenses/>.
85 #include "libmapiadmin/libmapiadmin.h"
88 #include <credentials.h>
90 #include <ldb_errors.h>
92 -#include <ldap_ndr.h>
94 #include <gen_ndr/ndr_samr.h>
95 #include <gen_ndr/ndr_samr_c.h>
99 +static ssize_t openchange_sys_read(int fd, void *buf, size_t count)
104 + ret = read(fd, buf, count);
105 + } while (ret == -1 && (errno == EINTR || errno == EAGAIN ||
106 + errno == EWOULDBLOCK));
111 +static ssize_t openchange_read_data(int fd, void *buffer, size_t n)
117 + while (nread < n) {
119 + ret = openchange_sys_read(fd, ((char *)buffer) + nread, n - nread);
129 +static int openchange_urand_fd = -1;
130 +static void openchange_open_urandom(void)
132 + if (openchange_urand_fd != -1) {
135 + openchange_urand_fd = open( "/dev/urandom", O_RDONLY,0);
136 + if (openchange_urand_fd == -1) {
141 +static void openchange_generate_random_buffer(uint8_t *out, int len)
145 + openchange_open_urandom();
147 + rw_ret = openchange_read_data(openchange_urand_fd, out, len);
148 + if (rw_ret != len) {
153 +static enum ndr_err_code openchange_ndr_push_dom_sid(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *r)
155 + uint32_t cntr_sub_auths_0;
156 + if (ndr_flags & NDR_SCALARS) {
157 + NDR_CHECK(ndr_push_align(ndr, 4));
158 + NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, r->sid_rev_num));
159 + NDR_CHECK(ndr_push_int8(ndr, NDR_SCALARS, r->num_auths));
160 + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->id_auth, 6));
161 + if (r->num_auths < 0 || r->num_auths > ARRAY_SIZE(r->sub_auths)) {
162 + return ndr_push_error(ndr, NDR_ERR_RANGE, "value out of range");
164 + for (cntr_sub_auths_0 = 0; cntr_sub_auths_0 < r->num_auths; cntr_sub_auths_0++) {
165 + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sub_auths[cntr_sub_auths_0]));
168 + return NDR_ERR_SUCCESS;
171 +static char *openchange_ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
175 + struct ldb_val val;
176 + enum ndr_err_code ndr_err;
178 + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid,
179 + (ndr_push_flags_fn_t)openchange_ndr_push_dom_sid);
180 + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
183 + val.data = blob.data;
184 + val.length = blob.length;
185 + ret = ldb_binary_encode(mem_ctx, val);
186 + data_blob_free(&blob);
190 +static bool openchange_check_password_quality(const char *pwd)
193 + size_t num_chars = 0;
194 + size_t num_digits = 0;
195 + size_t num_upper = 0;
196 + size_t num_lower = 0;
197 + size_t num_nonalpha = 0;
198 + size_t num_unicode = 0;
199 + size_t num_categories = 0;
206 + const char *s = &pwd[ofs];
210 + c = next_codepoint(s, &len);
211 + if (c == INVALID_CODEPOINT) {
213 + } else if (c == 0) {
220 + const char *na = "~!@#$%^&*_-+=`|\\(){}[]:;\"'<>,.?/";
237 + if (strchr(na, c)) {
243 + * the rest does not belong to
249 + if (isupper_m(c)) {
254 + if (islower_m(c)) {
260 + * Note: for now do not check if the unicode category is
261 + * alphabetic character
263 + * We would have to import the details from
264 + * ftp://ftp.unicode.org/Public/6.3.0/ucd/UnicodeData-6.3.0d1.txt
270 + if (num_digits > 0) {
271 + num_categories += 1;
273 + if (num_upper > 0) {
274 + num_categories += 1;
276 + if (num_lower > 0) {
277 + num_categories += 1;
279 + if (num_nonalpha > 0) {
280 + num_categories += 1;
282 + if (num_unicode > 0) {
283 + num_categories += 1;
286 + if (num_categories >= 3) {
293 +static char *openchange_generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const char *list)
296 + size_t list_len = strlen(list);
298 + char *retstr = talloc_array(mem_ctx, char, len + 1);
299 + if (!retstr) return NULL;
301 + openchange_generate_random_buffer((uint8_t *)retstr, len);
302 + for (i = 0; i < len; i++) {
303 + retstr[i] = list[retstr[i] % list_len];
310 +static char *openchange_generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
313 + const char *c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
316 + retstr = openchange_generate_random_str_list(mem_ctx, len, c_list);
317 + if (!retstr) return NULL;
319 + /* we need to make sure the random string passes basic quality tests
320 + or it might be rejected by windows as a password */
321 + if (len >= 7 && !openchange_check_password_quality(retstr)) {
322 + talloc_free(retstr);
331 User management functions for mapiadmin
332 @@ -232,10 +464,10 @@ _PUBLIC_ enum MAPISTATUS mapiadmin_user_
333 /* Search the user_dn */
334 account_dn = samdb_search_dn(remote_ldb, mem_ctx, NULL,
335 "(&(objectSid=%s)(objectClass=user))",
336 - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
337 + openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
339 ret = ldb_search(remote_ldb, mem_ctx, &res, account_dn, LDB_SCOPE_SUBTREE, dom_attrs, "(objectSid=%s)",
340 - ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
341 + openchange_ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
342 MAPI_RETVAL_IF(ret != LDB_SUCCESS, MAPI_E_NOT_FOUND, mem_ctx);
343 MAPI_RETVAL_IF(res->count != 1, MAPI_E_NOT_FOUND, mem_ctx);
345 @@ -422,7 +654,7 @@ again:
348 if (!mapiadmin_ctx->password) {
349 - mapiadmin_ctx->password = generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
350 + mapiadmin_ctx->password = openchange_generate_random_str(mapiadmin_ctx->user_ctx, MAX(8, policy_min_pw_len));
353 OC_DEBUG(3, "Setting account password '%s'", mapiadmin_ctx->password);
354 diff -up openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapidump.c
355 --- openchange-openchange-2.3-VULCAN/libmapi/mapidump.c.samba44 2016-02-09 11:03:18.565104717 +0100
356 +++ openchange-openchange-2.3-VULCAN/libmapi/mapidump.c 2016-02-09 11:03:29.508104254 +0100
357 @@ -119,7 +119,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
358 data = get_SPropValue_data(&lpProp);
360 printf("%s%s:\n", sep?sep:"", proptag);
361 - dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
362 + oc_dump_data(0, ((const struct Binary_r *)data)->lpb, ((const struct Binary_r *)data)->cb);
364 printf("%s%s: (NULL)\n", sep?sep:"", proptag);
366 @@ -153,7 +153,7 @@ _PUBLIC_ void mapidump_SPropValue(struct
367 printf("%s%s: ARRAY(%d)\n", sep?sep:"", proptag, BinaryArray_r->cValues);
368 for (i = 0; i < BinaryArray_r->cValues; i++) {
369 printf("\tPT_MV_BINARY [%d]:\n", i);
370 - dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
371 + oc_dump_data(0, BinaryArray_r->lpbin[i].lpb, BinaryArray_r->lpbin[i].cb);
375 diff -up openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c
376 --- openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c.samba44 2016-02-09 11:02:57.062105628 +0100
377 +++ openchange-openchange-2.3-VULCAN/libmapi/mapi_object.c 2016-02-09 11:03:01.012105461 +0100
378 @@ -412,7 +412,7 @@ _PUBLIC_ enum MAPISTATUS mapi_object_boo
380 OC_DEBUG(0, "mapi_object_bookmark {");
381 OC_DEBUG(0, ".index == %u", bookmark->index);
382 - dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
383 + oc_dump_data(0, bookmark->bin.lpb, bookmark->bin.cb);
386 bookmark = bookmark->next;
387 diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.c
388 --- openchange-openchange-2.3-VULCAN/libmapi/oc_log.c.samba44 2016-02-09 10:49:20.292140237 +0100
389 +++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.c 2016-02-09 11:30:13.912036271 +0100
392 #include "libmapi/libmapi.h"
398 +#define MIN(a,b) ((a)<(b)?(a):(b))
401 int _oc_log_samba_level = 0;
403 @@ -84,3 +90,119 @@ void oc_log_init_server(const char *prog
405 setup_logging(progname, DEBUG_FILE);
408 +void oc_panic(const char *why)
411 + fprintf(stderr, "PANIC: %s\n", why);
417 +static void oc_debugadd_cb(const char *buf, void *private_data)
419 + int *plevel = (int *)private_data;
420 + if (plevel && *plevel <= _oc_log_samba_level) {
421 + printf ("%s", buf);
425 +static void oc_print_asc_cb(const uint8_t *buf, int len,
426 + void (*cb)(const char *buf, void *private_data),
427 + void *private_data)
433 + for (i=0; i<len; i++) {
434 + s[0] = isprint(buf[i]) ? buf[i] : '.';
435 + cb(s, private_data);
439 +static void oc_dump_data_cb(const uint8_t *buf, int len,
440 + bool omit_zero_bytes,
441 + void (*cb)(const char *buf, void *private_data),
442 + void *private_data)
445 + static const uint8_t empty[16] = { 0, };
446 + bool skipped = false;
449 + if (len<=0) return;
454 + if ((omit_zero_bytes == true) &&
457 + (memcmp(&buf[i], &empty, 16) == 0))
464 + snprintf(tmp, sizeof(tmp), "[%04X] ", i);
465 + cb(tmp, private_data);
469 + snprintf(tmp, sizeof(tmp), "%02X ", (int)buf[i]);
470 + cb(tmp, private_data);
473 + cb(" ", private_data);
477 + oc_print_asc_cb(&buf[i-16], 8, cb, private_data);
478 + cb(" ", private_data);
479 + oc_print_asc_cb(&buf[i-8], 8, cb, private_data);
480 + cb("\n", private_data);
482 + if ((omit_zero_bytes == true) &&
484 + (memcmp(&buf[i], &empty, 16) == 0)) {
486 + cb("skipping zero buffer bytes\n",
497 + cb(" ", private_data);
499 + cb(" ", private_data);
502 + cb(" ", private_data);
505 + oc_print_asc_cb(&buf[i-(i%16)], n, cb, private_data);
506 + cb(" ", private_data);
509 + oc_print_asc_cb(&buf[i-n], n, cb, private_data);
511 + cb("\n", private_data);
516 +void oc_dump_data(int level, const uint8_t *buf,int len)
518 + if (_oc_log_samba_level < level || !buf || !len)
521 + oc_dump_data_cb(buf, len, false, oc_debugadd_cb, &level);
523 diff -up openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 openchange-openchange-2.3-VULCAN/libmapi/oc_log.h
524 --- openchange-openchange-2.3-VULCAN/libmapi/oc_log.h.samba44 2016-02-09 10:49:16.132140414 +0100
525 +++ openchange-openchange-2.3-VULCAN/libmapi/oc_log.h 2016-02-09 10:51:57.121133592 +0100
526 @@ -79,4 +79,7 @@ void oc_log_init_server(const char *prog
528 extern int _oc_log_samba_level; /* Private, do not change it other than by SetMAPIDebugLevel() */
530 +void oc_panic(const char *why);
531 +void oc_dump_data(int level, const uint8_t *buf,int len);
533 #endif /* _OC_LOG_H_ */
534 diff -up openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/property.c
535 --- openchange-openchange-2.3-VULCAN/libmapi/property.c.samba44 2016-02-09 10:46:51.040146561 +0100
536 +++ openchange-openchange-2.3-VULCAN/libmapi/property.c 2016-02-09 10:48:47.626141621 +0100
537 @@ -777,7 +777,7 @@ _PUBLIC_ void mapi_copy_spropvalues(TALL
538 // TODO: Replace this with OC_PANIC() macro when it gets visible in libmapi too
539 OC_DEBUG(0, "Unexpected multi-value property type: %s.",
540 get_proptag_name(source_value->ulPropTag));
541 - smb_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
542 + oc_panic("Unexpected multi-value property type while copying 'struct SPropValue'");
546 diff -up openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c
547 --- openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c.samba44 2016-02-09 11:09:43.147088421 +0100
548 +++ openchange-openchange-2.3-VULCAN/libmapi/socket/interface.c 2016-02-09 11:31:47.664032298 +0100
549 @@ -90,6 +90,213 @@ static void add_interface(TALLOC_CTX *me
550 OC_DEBUG(2, "added interface ip=%s nmask=%s", iface->ip_s, iface->nmask_s);
553 +enum oc_protocol_types {
554 + PROTOCOL_DEFAULT=-1,
571 +static int openchange_null_match(const char *p)
577 + *p != '>') return -1;
583 + the max_n structure is purely for efficiency, it doesn't contribute
584 + to the matching algorithm except by ensuring that the algorithm does
585 + not grow exponentially
588 + const char *predot;
589 + const char *postdot;
594 + p and n are the pattern and string being matched. The max_n array is
595 + an optimisation only. The ldot pointer is NULL if the string does
596 + not contain a '.', otherwise it points at the last dot in 'n'.
598 +static int openchange_ms_fnmatch_core(const char *p, const char *n,
599 + struct max_n *max_n, const char *ldot)
603 + size_t size, size_n;
605 + while ((c = next_codepoint(p, &size))) {
610 + /* a '*' matches zero or more characters of any type */
611 + if (max_n->predot && max_n->predot <= n) {
612 + return openchange_null_match(p);
614 + for (i=0; n[i]; i += size_n) {
615 + next_codepoint(n+i, &size_n);
616 + if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
620 + if (!max_n->predot || max_n->predot > n) max_n->predot = n;
621 + return openchange_null_match(p);
624 + /* a '<' matches zero or more characters of
625 + any type, but stops matching at the last
626 + '.' in the string. */
627 + if (max_n->predot && max_n->predot <= n) {
628 + return openchange_null_match(p);
630 + if (max_n->postdot && max_n->postdot <= n && n <= ldot) {
633 + for (i=0; n[i]; i += size_n) {
634 + next_codepoint(n+i, &size_n);
635 + if (openchange_ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
637 + if (openchange_ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
638 + if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
642 + if (!max_n->predot || max_n->predot > n) max_n->predot = n;
643 + return openchange_null_match(p);
646 + /* a '?' matches any single character */
650 + next_codepoint(n, &size_n);
655 + /* a '?' matches any single character, but
656 + treats '.' specially */
658 + if (! n[1] && openchange_null_match(p) == 0) {
663 + if (! *n) return openchange_null_match(p);
664 + next_codepoint(n, &size_n);
669 + /* a bit like a soft '.' */
670 + if (*n == 0 && openchange_null_match(p) == 0) {
673 + if (*n != '.') return -1;
674 + next_codepoint(n, &size_n);
679 + c2 = next_codepoint(n, &size_n);
680 + if (c != c2 && codepoint_cmpi(c, c2) != 0) {
695 +static int openchange_ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
698 + struct max_n *max_n = NULL;
700 + if (strcmp(string, "..") == 0) {
704 + if (strpbrk(pattern, "<>*?\"") == NULL) {
705 + /* this is not just an optimisation - it is essential
706 + for LANMAN1 correctness */
707 + return strcasecmp_m(pattern, string);
710 + if (protocol <= PROTOCOL_LANMAN2) {
711 + char *p = talloc_strdup(NULL, pattern);
716 + for older negotiated protocols it is possible to
717 + translate the pattern to produce a "new style"
718 + pattern that exactly matches w2k behaviour
720 + for (i=0;p[i];i++) {
723 + } else if (p[i] == '.' &&
728 + } else if (p[i] == '*' &&
733 + ret = openchange_ms_fnmatch_protocol(p, string, PROTOCOL_NT1);
738 + for (count=i=0;pattern[i];i++) {
739 + if (pattern[i] == '*' || pattern[i] == '<') count++;
742 + max_n = talloc_zero_array(NULL, struct max_n, count);
743 + if (max_n == NULL) {
747 + ret = openchange_ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
749 + talloc_free(max_n);
755 +/** a generic fnmatch function - uses for non-CIFS pattern matching */
756 +static int openchange_gen_fnmatch(const char *pattern, const char *string)
758 + return openchange_ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1);
763 @@ -119,7 +326,7 @@ static void interpret_interface(TALLOC_C
765 /* first check if it is an interface name */
766 for (i=0;i<total_probed;i++) {
767 - if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
768 + if (openchange_gen_fnmatch(token, probed_ifaces[i].name) == 0) {
769 add_interface(mem_ctx, probed_ifaces[i].ip,
770 probed_ifaces[i].netmask,
772 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
773 --- openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c.samba44 2015-05-16 17:22:04.000000000 +0200
774 +++ openchange-openchange-2.3-VULCAN/mapiproxy/servers/default/emsmdb/emsmdbp.c 2016-02-08 17:43:52.578645298 +0100
776 #include "mapiproxy/libmapiserver/libmapiserver.h"
777 #include "mapiproxy/libmapiproxy/fault_util.h"
779 -#include <ldap_ndr.h>
781 /* Expose samdb_connect prototype */
782 struct ldb_context *samdb_connect(TALLOC_CTX *, struct tevent_context *,
783 struct loadparm_context *,
784 diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 openchange-openchange-2.3-VULCAN/ndr_mapi.c
785 --- openchange-openchange-2.3-VULCAN/ndr_mapi.c.samba44 2016-02-09 11:04:30.054101688 +0100
786 +++ openchange-openchange-2.3-VULCAN/ndr_mapi.c 2016-02-09 11:04:49.763100853 +0100
787 @@ -1616,7 +1616,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
788 if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
789 ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
791 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
792 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
793 talloc_free(mapi_request);
796 @@ -1662,7 +1662,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt(struc
797 if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
798 ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
800 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
801 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
802 talloc_free(mapi_response);
805 @@ -1735,7 +1735,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
806 if (ndr_pull_mapi2k7_request(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_request) == NDR_ERR_SUCCESS) {
807 ndr_print_mapi2k7_request(ndr, "mapi_request", (const struct mapi2k7_request *)mapi_request);
809 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
810 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
811 talloc_free(mapi_request);
814 @@ -1786,7 +1786,7 @@ _PUBLIC_ void ndr_print_EcDoRpcExt2(stru
815 if (ndr_pull_mapi2k7_response(ndr_pull, NDR_SCALARS|NDR_BUFFERS, mapi_response) == NDR_ERR_SUCCESS) {
816 ndr_print_mapi2k7_response(ndr, "mapi_response", (const struct mapi2k7_response *)mapi_response);
818 - dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
819 + oc_dump_data(0, ndr_pull->data + ndr_pull->offset, ndr_pull->data_size - ndr_pull->offset);
820 talloc_free(mapi_response);
823 @@ -2041,7 +2041,7 @@ _PUBLIC_ void ndr_print_SBinary_short(st
824 uint32_t _flags_save_STRUCT = ndr->flags;
825 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
827 - dump_data(0, r->lpb, r->cb);
828 + oc_dump_data(0, r->lpb, r->cb);
830 ndr->flags = _flags_save_STRUCT;
832 @@ -2054,7 +2054,7 @@ _PUBLIC_ void ndr_print_Binary_r(struct
833 uint32_t _flags_save_STRUCT = ndr->flags;
834 ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
836 - dump_data(0, r->lpb, r->cb);
837 + oc_dump_data(0, r->lpb, r->cb);
839 ndr->flags = _flags_save_STRUCT;
841 diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c
842 --- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.samba44 2015-05-16 17:22:04.000000000 +0200
843 +++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c 2016-02-09 10:35:42.207174902 +0100
845 #include "gen_ndr/ndr_exchange.h"
848 +#include <sys/types.h>
849 +#include <sys/stat.h>
852 #define PLUGIN "libmapi.so"
854 @@ -97,6 +100,51 @@ static const const struct ndr_interface_
858 +static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
864 + if (fstat(fd, &sbuf) != 0) return NULL;
866 + size = sbuf.st_size;
869 + size = size < maxsize ? size : maxsize;
872 + p = (char *)talloc_size(mem_ctx, size+1);
873 + if (!p) return NULL;
875 + if (read(fd, p, size) != size) {
881 + if (psize) *psize = size;
886 +static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
891 + if (!fname || !*fname) return NULL;
893 + fd = open(fname,O_RDONLY);
894 + if (fd == -1) return NULL;
896 + p = openchange_fd_load(fd, size, maxsize, mem_ctx);
903 static struct SPropTagArray *process_request(TALLOC_CTX *mem_ctx,
904 const struct ndr_interface_call *f,
905 const char *filename,
906 @@ -123,7 +171,7 @@ static struct SPropTagArray *process_req
910 - data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
911 + data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
915 @@ -224,7 +272,7 @@ static int process_response(TALLOC_CTX *
919 - data = (uint8_t *) file_load(filename, &size, 0, mem_ctx);
920 + data = (uint8_t *) openchange_file_load(filename, &size, 0, mem_ctx);
924 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
925 --- openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c.samba44 2016-02-09 11:06:00.717097846 +0100
926 +++ openchange-openchange-2.3-VULCAN/utils/mapitest/modules/module_lzxpress.c 2016-02-09 11:48:38.200989479 +0100
928 along with this program. If not, see <http://www.gnu.org/licenses/>.
931 +#include <sys/types.h>
932 +#include <sys/stat.h>
935 #include "utils/mapitest/mapitest.h"
936 #include "utils/mapitest/proto.h"
937 #include "gen_ndr/ndr_exchange.h"
938 +#include "libmapi/libmapi.h"
939 #include "libmapi/libmapi_private.h"
941 +static char *openchange_fd_load(int fd, size_t *psize, size_t maxsize, TALLOC_CTX *mem_ctx)
947 + if (fstat(fd, &sbuf) != 0) return NULL;
949 + size = sbuf.st_size;
952 + size = size < maxsize ? size : maxsize;
955 + p = (char *)talloc_size(mem_ctx, size+1);
956 + if (!p) return NULL;
958 + if (read(fd, p, size) != size) {
964 + if (psize) *psize = size;
969 +static char *openchange_file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx)
974 + if (!fname || !*fname) return NULL;
976 + fd = open(fname,O_RDONLY);
977 + if (fd == -1) return NULL;
979 + p = openchange_fd_load(fd, size, maxsize, mem_ctx);
987 \file module_lzxpress.c
989 @@ -51,7 +101,7 @@ _PUBLIC_ bool mapitest_lzxpress_validate
990 /* Step 1. Load Test File 001_Outlook_2007_in_ModifyRecipients_comp.dat */
991 filename = talloc_asprintf(mt->mem_ctx, "%s/001_Outlook_2007_in_ModifyRecipients_comp.dat", LZXPRESS_DATADIR);
992 /* filename = talloc_asprintf(mt->mem_ctx, "%s/002_Outlook_2007_in_Tables_operations_comp.dat", LZXPRESS_DATADIR); */
993 - data = (uint8_t *)file_load(filename, &size, 0, mt->mem_ctx);
994 + data = (uint8_t *)openchange_file_load(filename, &size, 0, mt->mem_ctx);
997 mapitest_print_retval_fmt(mt, "lzxpress_validate", "Error while loading %s", filename);
998 @@ -137,12 +187,12 @@ _PUBLIC_ bool mapitest_lzxpress_validate
1000 mapitest_print(mt, "Compressed rgbIn by Outlook\n");
1001 mapitest_print(mt, "==============================\n");
1002 - dump_data(0, r.in.rgbIn, r.in.cbIn);
1003 + oc_dump_data(0, r.in.rgbIn, r.in.cbIn);
1004 mapitest_print(mt, "==============================\n");
1006 mapitest_print(mt, "Compressed rgbIn by OpenChange\n");
1007 mapitest_print(mt, "==============================\n");
1008 - dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
1009 + oc_dump_data(0, ndr_rgbIn->data, ndr_rgbIn->offset);
1010 mapitest_print(mt, "==============================\n");
1012 talloc_free(ndr_rgbIn);
1013 diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 openchange-openchange-2.3-VULCAN/utils/openchangeclient.c
1014 --- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.samba44 2015-05-16 17:22:04.000000000 +0200
1015 +++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c 2016-02-08 22:24:59.212942206 +0100
1016 @@ -97,6 +97,52 @@ static void init_oclient(struct oclient
1017 oclient->ocpf_dump = NULL;
1020 +static char **openchange_str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
1022 + int num_elements = 0;
1023 + char **ret = NULL;
1025 + if (sep == NULL) {
1029 + ret = talloc_array(mem_ctx, char *, 1);
1030 + if (ret == NULL) {
1034 + while (string && *string) {
1035 + size_t len = strcspn(string, sep);
1039 + string += strspn(string, sep);
1043 + ret2 = talloc_realloc(mem_ctx, ret, char *,
1045 + if (ret2 == NULL) {
1051 + ret[num_elements] = talloc_strndup(ret, string, len);
1052 + if (ret[num_elements] == NULL) {
1061 + ret[num_elements] = NULL;
1066 static enum MAPISTATUS openchangeclient_getdir(TALLOC_CTX *mem_ctx,
1067 mapi_object_t *obj_container,
1068 mapi_object_t *obj_child,
1069 @@ -115,7 +161,7 @@ static enum MAPISTATUS openchangeclient_
1072 /* Step 1. Extract the folder list from full path */
1073 - folder = str_list_make(mem_ctx, path, "/");
1074 + folder = openchange_str_list_make(mem_ctx, path, "/");
1075 mapi_object_copy(&obj_folder, obj_container);
1077 for (i = 0; folder[i]; i++) {