Hi,

the following will segfault from ProcessNetworkProfile
if there are no profiles returned from the exchange server(for whatever
reason):

./mapiprofile --username=username --password=***
--workstation=LOCALHOST --domain=LOCAL -I 1.2.3.4
--profile=profilename --create

Attached a patch that returns MAPI_E_NOT_FOUND instead of segfaulting.

Of course, it is expected to return at least one result. 

But anyway, I can't create a profile though. Is there any other way to
query my exchange 2007 for my record?

And what is the reasoning behind the profile db at a whole?

Thanks,
  lofi

Index: IProfAdmin.c
===================================================================
--- IProfAdmin.c        (revision 379)
+++ IProfAdmin.c        (working copy)
@@ -1185,7 +1185,7 @@
        struct nspi_context     *nspi;
        struct SPropTagArray    *SPropTagArray;
        struct SRowSet          rowset;
-       struct SPropValue       *lpProp;
+       struct SPropValue       *lpProp = NULL;
        const char              *profname;
        uint32_t                index = 0;
 
@@ -1195,6 +1195,7 @@
        nspi = (struct nspi_context *) session->nspi->ctx;
        profname = session->profile->profname;
        index = 0;
+       rowset.cRows = 0;
        
        retval = nspi_GetHierarchyInfo(nspi, &rowset);
        if (retval != MAPI_E_SUCCESS) return retval;
@@ -1216,13 +1217,18 @@
        retval = nspi_GetMatches(nspi, SPropTagArray, &rowset, username);
        if (retval != MAPI_E_SUCCESS) return retval;
 
-       /* if rowset count is superior than 1 an callback is specified, call it 
*/
-       if (rowset.cRows > 1 && callback) {
+       if(rowset.cRows == 0) {
+               MAPI_RETVAL_IF(rowset.cRows == 0, MAPI_E_NOT_FOUND, NULL);      
+       }
+
+       /* if rowset count is superior than 1 and callback is specified, call 
it */
+       if (rowset.cRows > 1 && callback != NULL) {
                index = callback(&rowset, private);
                MAPI_RETVAL_IF((index >= rowset.cRows), MAPI_E_USER_CANCEL, 
NULL);
        }
+        
+       lpProp = get_SPropValue_SRow(&(rowset.aRow[index]), PR_INSTANCE_KEY);
 
-       lpProp = get_SPropValue_SRow(&(rowset.aRow[index]), PR_INSTANCE_KEY);
        if (lpProp) {
                struct SBinary bin;
                
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to