From ad2b5fe4131748f474add997621923fd8c88ffa3 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 10 Oct 2012 08:42:44 -0400 Subject: [PATCH] ensure that shifted property ids are correctly "masked" to 16-bit integers --- OpenChange/MAPIStoreCalendarMessage.m | 6 ++++- OpenChange/MAPIStoreObject.m | 33 ++++++++++++++------------- OpenChange/NSObject+MAPIStore.m | 14 ++++++------ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/OpenChange/MAPIStoreCalendarMessage.m b/OpenChange/MAPIStoreCalendarMessage.m index ce53719ed..bd6403f4c 100644 --- a/OpenChange/MAPIStoreCalendarMessage.m +++ b/OpenChange/MAPIStoreCalendarMessage.m @@ -104,11 +104,15 @@ static Class NSArrayK; { BOOL listedProperties[65536]; NSUInteger count; + uint16_t propId; memset (listedProperties, NO, 65536 * sizeof (BOOL)); [super getAvailableProperties: propertiesP inMemCtx: memCtx]; for (count = 0; count < (*propertiesP)->cValues; count++) - listedProperties[(*propertiesP)->aulPropTag[count] >> 16] = YES; + { + propId = ((*propertiesP)->aulPropTag[count] >> 16) & 0xffff; + listedProperties[propId] = YES; + } [MAPIStoreAppointmentWrapper fillAvailableProperties: *propertiesP withExclusions: listedProperties]; diff --git a/OpenChange/MAPIStoreObject.m b/OpenChange/MAPIStoreObject.m index 5679ad5ae..24310a926 100644 --- a/OpenChange/MAPIStoreObject.m +++ b/OpenChange/MAPIStoreObject.m @@ -209,7 +209,7 @@ static Class NSExceptionK, MAPIStoreFolderK; BOOL canGetProperty; NSUInteger count, max; - propValue = (propTag & 0xffff0000) >> 16; + propValue = (propTag >> 16) & 0xffff; canGetProperty = (classGetters[propValue] || [properties objectForKey: MAPIPropertyKey (propTag)]); @@ -336,19 +336,19 @@ static Class NSExceptionK, MAPIStoreFolderK; operations. If they need to be set (move operations), the caller will need to take care of them. */ exclusions = talloc_array (memCtx, bool, 65536); - exclusions[PidTagRowType >> 16] = true; - exclusions[PidTagInstanceKey >> 16] = true; - exclusions[PidTagInstanceNum >> 16] = true; - exclusions[PidTagInstID >> 16] = true; - exclusions[PidTagAttachNumber >> 16] = true; - exclusions[PidTagFolderId >> 16] = true; - exclusions[PidTagMid >> 16] = true; - exclusions[PidTagSourceKey >> 16] = true; - exclusions[PidTagParentSourceKey >> 16] = true; - exclusions[PidTagParentFolderId >> 16] = true; - exclusions[PidTagChangeKey >> 16] = true; - exclusions[PidTagChangeNumber >> 16] = true; - exclusions[PidTagPredecessorChangeList >> 16] = true; + exclusions[(PidTagRowType >> 16) & 0xffff] = true; + exclusions[(PidTagInstanceKey >> 16) & 0xffff] = true; + exclusions[(PidTagInstanceNum >> 16) & 0xffff] = true; + exclusions[(PidTagInstID >> 16) & 0xffff] = true; + exclusions[(PidTagAttachNumber >> 16) & 0xffff] = true; + exclusions[(PidTagFolderId >> 16) & 0xffff] = true; + exclusions[(PidTagMid >> 16) & 0xffff] = true; + exclusions[(PidTagSourceKey >> 16) & 0xffff] = true; + exclusions[(PidTagParentSourceKey >> 16) & 0xffff] = true; + exclusions[(PidTagParentFolderId >> 16) & 0xffff] = true; + exclusions[(PidTagChangeKey >> 16) & 0xffff] = true; + exclusions[(PidTagChangeNumber >> 16) & 0xffff] = true; + exclusions[(PidTagPredecessorChangeList >> 16) & 0xffff] = true; row.cValues = 0; row.lpProps = talloc_array (memCtx, struct SPropValue, 65535); @@ -356,12 +356,13 @@ static Class NSExceptionK, MAPIStoreFolderK; for (count = 0; count < availableProps->cValues; count++) { propTag = availableProps->aulPropTag[count]; - if (!exclusions[propTag >> 16]) + if (!exclusions[(propTag >> 16) & 0xffff]) { error = [self getProperty: &data withTag: propTag inMemCtx: memCtx]; if (error == MAPISTORE_SUCCESS && data) { - set_SPropValue_proptag (row.lpProps + row.cValues, propTag, data); + set_SPropValue_proptag (row.lpProps + row.cValues, propTag, + data); row.cValues++; } } diff --git a/OpenChange/NSObject+MAPIStore.m b/OpenChange/NSObject+MAPIStore.m index 1829b59f3..930b13f11 100644 --- a/OpenChange/NSObject+MAPIStore.m +++ b/OpenChange/NSObject+MAPIStore.m @@ -186,7 +186,7 @@ MAPIStoreTallocWrapperDestroy (void *data) const MAPIStorePropertyGetter *classGetters; NSUInteger count; enum MAPITAGS propTag; - uint16_t propValue; + uint16_t propId; properties = talloc_zero (memCtx, struct SPropTagArray); properties->aulPropTag = talloc_array (properties, enum MAPITAGS, @@ -195,8 +195,8 @@ MAPIStoreTallocWrapperDestroy (void *data) for (count = 0; count < MAPIStoreSupportedPropertiesCount; count++) { propTag = MAPIStoreSupportedProperties[count]; - propValue = (propTag & 0xffff0000) >> 16; - if (classGetters[propValue]) + propId = (propTag >> 16) & 0xffff; + if (classGetters[propId]) { properties->aulPropTag[properties->cValues] = propTag; properties->cValues++; @@ -220,7 +220,7 @@ MAPIStoreTallocWrapperDestroy (void *data) [self getAvailableProperties: &subProperties inMemCtx: localMemCtx]; for (count = 0; count < subProperties->cValues; count++) { - propId = (subProperties->aulPropTag[count] >> 16); + propId = (subProperties->aulPropTag[count] >> 16) & 0xffff; if (!exclusions[propId]) { properties->aulPropTag[properties->cValues] @@ -259,13 +259,13 @@ MAPIStoreTallocWrapperDestroy (void *data) - (BOOL) canGetProperty: (enum MAPITAGS) propTag { - uint16_t propValue; + uint16_t propId; const IMP *classGetters; classGetters = (IMP *) MAPIStorePropertyGettersForClass (isa); - propValue = (propTag & 0xffff0000) >> 16; + propId = (propTag >> 16) & 0xffff; - return (classGetters[propValue] != NULL); + return (classGetters[propId] != NULL); } @end