From: Julien Kerihuel Date: Mon, 27 Feb 2012 13:31:57 +0000 (+0000) Subject: Fix issue #384, patch from Milan Crha: X-Git-Tag: openchange-1.0~61 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=f676fcc682e8c03d8778b76d7abdf352ee472011;p=jelmer%2Fopenchange-proposed.git%2F.git Fix issue #384, patch from Milan Crha: The nspi_GetMatches currently hardcodes search result limit to 5000, which results in [1], and MAPI_E_TABLE_TOO_BIG errors. It would be nice to provide a new argument for the search result size limit, rather than hard code it. --- diff --git a/doc/examples/fetch_addressbook.c b/doc/examples/fetch_addressbook.c index 370c8789..0991e84a 100644 --- a/doc/examples/fetch_addressbook.c +++ b/doc/examples/fetch_addressbook.c @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) /* construct an explicit table */ MIds = talloc_zero(mem_ctx, struct SPropTagArray); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, NULL, &Filter, &srowset, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, NULL, &Filter, 5000, &srowset, &MIds); MAPI_RETVAL_IF(retval, retval, NULL); /* fetch the contents of the explicit table */ diff --git a/libmapi/IProfAdmin.c b/libmapi/IProfAdmin.c index 08007ea7..1f83005c 100644 --- a/libmapi/IProfAdmin.c +++ b/libmapi/IProfAdmin.c @@ -1632,7 +1632,7 @@ _PUBLIC_ enum MAPISTATUS ProcessNetworkProfile(struct mapi_session *session, SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(SPropTagArray); MAPIFreeBuffer(lpProp); if (retval != MAPI_E_SUCCESS) { diff --git a/libmapi/libmapi.h b/libmapi/libmapi.h index 27468e69..ab32a626 100644 --- a/libmapi/libmapi.h +++ b/libmapi/libmapi.h @@ -96,7 +96,7 @@ enum MAPISTATUS nspi_unbind(struct nspi_context *); enum MAPISTATUS nspi_UpdateStat(struct nspi_context *, TALLOC_CTX *, uint32_t *); enum MAPISTATUS nspi_QueryRows(struct nspi_context *, TALLOC_CTX *, struct SPropTagArray *, struct PropertyTagArray_r *MIds, uint32_t, struct SRowSet **); enum MAPISTATUS nspi_SeekEntries(struct nspi_context *, TALLOC_CTX *, enum TableSortOrders, struct SPropValue *, struct SPropTagArray *, struct PropertyTagArray_r *pMIds, struct SRowSet **); -enum MAPISTATUS nspi_GetMatches(struct nspi_context *, TALLOC_CTX *, struct SPropTagArray *, struct Restriction_r *, struct SRowSet **, struct PropertyTagArray_r **ppOutMIds); +enum MAPISTATUS nspi_GetMatches(struct nspi_context *, TALLOC_CTX *, struct SPropTagArray *, struct Restriction_r *, uint32_t ulRequested, struct SRowSet **, struct PropertyTagArray_r **ppOutMIds); enum MAPISTATUS nspi_ResortRestriction(struct nspi_context *, TALLOC_CTX *, enum TableSortOrders, struct PropertyTagArray_r *pInMIds, struct PropertyTagArray_r **ppMIds); enum MAPISTATUS nspi_DNToMId(struct nspi_context *, TALLOC_CTX *, struct StringsArray_r *, struct PropertyTagArray_r **ppMIds); enum MAPISTATUS nspi_GetPropList(struct nspi_context *, TALLOC_CTX *, bool, uint32_t, struct SPropTagArray **); diff --git a/libmapi/nspi.c b/libmapi/nspi.c index d4743191..e0764801 100644 --- a/libmapi/nspi.c +++ b/libmapi/nspi.c @@ -390,17 +390,22 @@ _PUBLIC_ enum MAPISTATUS nspi_SeekEntries(struct nspi_context *nspi_ctx, \param mem_ctx pointer to the memory context \param pPropTags pointer to an array of property tags of columns \param Filter pointer to the Restriction to apply to the table + \param ulRequested The upper limit for returned rows \param ppRows pointer to pointer to a SRowSet structure holding the rows returned by the server \param ppOutMIds pointer to pointer to a list of MId that comprise a restricted address book container - \return MAPI_E_SUCCESS on success, otherwise MAPI error. + \return MAPI_E_SUCCESS on success, otherwise MAPI error. If the resulting + table rows count will be greater than ulRequested, then an error + MAPI_E_TABLE_TOO_BIG is returned. Note, this error can be also returned + when server limits for table size are exceeded. */ _PUBLIC_ enum MAPISTATUS nspi_GetMatches(struct nspi_context *nspi_ctx, TALLOC_CTX *mem_ctx, struct SPropTagArray *pPropTags, struct Restriction_r *Filter, + uint32_t ulRequested, struct SRowSet **ppRows, struct PropertyTagArray_r **ppOutMIds) { @@ -429,7 +434,7 @@ _PUBLIC_ enum MAPISTATUS nspi_GetMatches(struct nspi_context *nspi_ctx, r.in.Reserved2 = 0; r.in.Filter = Filter; r.in.lpPropName = NULL; - r.in.ulRequested = 5000; + r.in.ulRequested = ulRequested; r.in.pPropTags = pPropTags; pStat = talloc(mem_ctx, struct STAT); diff --git a/utils/mapitest/modules/module_nspi.c b/utils/mapitest/modules/module_nspi.c index ed07be43..30e5838f 100644 --- a/utils/mapitest/modules/module_nspi.c +++ b/utils/mapitest/modules/module_nspi.c @@ -106,7 +106,7 @@ _PUBLIC_ bool mapitest_nspi_QueryRows(struct mapitest *mt) SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(SRowSet); MAPIFreeBuffer(SPropTagArray); @@ -233,7 +233,7 @@ _PUBLIC_ bool mapitest_nspi_GetMatches(struct mapitest *mt) SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(SRowSet); MAPIFreeBuffer(SPropTagArray); @@ -299,7 +299,7 @@ _PUBLIC_ bool mapitest_nspi_ResortRestriction(struct mapitest *mt) SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(SPropTagArray); MAPIFreeBuffer(SRowSet); @@ -400,7 +400,7 @@ _PUBLIC_ bool mapitest_nspi_GetPropList(struct mapitest *mt) SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(SPropTagArray); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(SRowSet); @@ -525,7 +525,7 @@ _PUBLIC_ bool mapitest_nspi_CompareMIds(struct mapitest *mt) SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(SPropTagArray); MAPIFreeBuffer(SRowSet); @@ -602,7 +602,7 @@ _PUBLIC_ bool mapitest_nspi_ModProps(struct mapitest *mt) SRowSet = talloc_zero(mem_ctx, struct SRowSet); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); - retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds); + retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(SRowSet); MAPIFreeBuffer(SPropTagArray);