On Thu, 2010-04-29 at 19:49 +0200, Milan Crha wrote:
> > The problem is that you're hitting cases that I don't see. So the
> TDD process
> > is a bit harder here...
>
> Sure, no problem, as long as we get this fixed before release.
Hi there,
I'm still in process of testing the PT_DOUBLE bug, with not much
success, but that might be Evolution's issue, I'll investigate more.
But meanwhile, I'm offering you this patch. It slightly simplifies
cast_mapi_SPropValue function, and adds not as that many handled types,
but few it does. With this patch applied I can read my items from the
server with no crash, where after revision 1762 I couldn't. This patch
is applicable to revision 1775.
Bye,
Milan
Index: libmapi/property.c
===================================================================
--- libmapi/property.c (revision 1775)
+++ libmapi/property.c (working copy)
@@ -469,18 +469,25 @@
mapi_sprop->ulPropTag = sprop->ulPropTag;
switch(sprop->ulPropTag & 0xFFFF) {
- case PT_BOOLEAN:
- mapi_sprop->value.b = sprop->value.b;
- return sizeof(uint8_t);
- case PT_I2:
- mapi_sprop->value.i = sprop->value.i;
- return sizeof(uint16_t);
- case PT_LONG:
- mapi_sprop->value.l = sprop->value.l;
- return sizeof(uint32_t);
- case PT_DOUBLE:
- mapi_sprop->value.dbl = sprop->value.dbl;
- return sizeof(uint64_t);
+ #define direct_copy_case(_tp, _mbr) \
+ case _tp: \
+ mapi_sprop->value._mbr = sprop->value._mbr; \
+ return sizeof(mapi_sprop->value._mbr);
+ direct_copy_case (PT_BOOLEAN, b)
+ direct_copy_case (PT_I2, i)
+ direct_copy_case (PT_I8, d)
+ direct_copy_case (PT_LONG, l)
+ direct_copy_case (PT_DOUBLE, dbl)
+ direct_copy_case (PT_SYSTIME, ft)
+ direct_copy_case (PT_ERROR, err)
+ #undef direct_copy_case
+
+ case PT_NULL:
+ case PT_OBJECT:
+ case PT_MV_SHORT:
+ /* types, which cannot be stored in mapi_SPropValue */
+ printf ("cast_mapi_SPropValue: Cannot cast prop value 0x%x to mapi type\n", sprop->ulPropTag & 0xFFFF);
+ break;
case PT_STRING8:
mapi_sprop->value.lpszA = sprop->value.lpszA;
if (!mapi_sprop->value.lpszA) return 0;
@@ -489,17 +496,10 @@
mapi_sprop->value.lpszW = sprop->value.lpszW;
if (!mapi_sprop->value.lpszW) return 0;
return get_utf8_utf16_conv_length(mapi_sprop->value.lpszW);
- case PT_SYSTIME:
- mapi_sprop->value.ft.dwLowDateTime = sprop->value.ft.dwLowDateTime;
- mapi_sprop->value.ft.dwHighDateTime = sprop->value.ft.dwHighDateTime;
- return (sizeof (struct FILETIME));
case PT_BINARY:
mapi_sprop->value.bin.cb = sprop->value.bin.cb;
mapi_sprop->value.bin.lpb = sprop->value.bin.lpb;
return (mapi_sprop->value.bin.cb + sizeof(uint16_t));
- case PT_ERROR:
- mapi_sprop->value.err = sprop->value.err;
- return sizeof(uint32_t);
case PT_MV_STRING8:
{
uint32_t i;
@@ -515,6 +515,21 @@
}
return size;
}
+ case PT_MV_UNICODE:
+ {
+ uint32_t i;
+ uint32_t size = 0;
+
+ mapi_sprop->value.MVszW.cValues = sprop->value.MVszW.cValues;
+ size += 4;
+
+ mapi_sprop->value.MVszW.strings = talloc_array(global_mapi_ctx->mem_ctx, struct mapi_LPWSTR, mapi_sprop->value.MVszW.cValues);
+ for (i = 0; i < mapi_sprop->value.MVszW.cValues; i++) {
+ mapi_sprop->value.MVszW.strings[i].lppszW = sprop->value.MVszW.lppszW[i];
+ size += strlen(mapi_sprop->value.MVszW.strings[i].lppszW) + 1;
+ }
+ return size;
+ }
case PT_MV_BINARY:
{
uint32_t i;
@@ -531,6 +546,18 @@
}
return size;
}
+ case PT_MV_LONG:
+ {
+ uint32_t i;
+
+ mapi_sprop->value.MVl.cValues = sprop->value.MVl.cValues;
+ mapi_sprop->value.MVl.lpl = talloc_array (global_mapi_ctx->mem_ctx, uint32_t, mapi_sprop->value.MVl.cValues);
+ for (i = 0; i < mapi_sprop->value.MVl.cValues; i++) {
+ mapi_sprop->value.MVl.lpl[i] = sprop->value.MVl.lpl[i];
+ }
+ return sizeof(mapi_sprop->value.MVl.cValues) +
+ (mapi_sprop->value.MVl.cValues * sizeof (uint32_t));
+ }
default:
printf("unhandled conversion case in cast_mapi_SPropValue(): 0x%x\n", (sprop->ulPropTag & 0xFFFF));
OPENCHANGE_ASSERT();
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel