- fix MsiSummaryInfoGetProperty to return ERROR_MORE_DATA if the buffer is too small (based on a patch by Aric Stewart) - add a test case to show correct behaviour
diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c index 46c1e5b..a59863a 100644 --- a/dlls/msi/suminfo.c +++ b/dlls/msi/suminfo.c
@@ -544,6 +544,7 @@ { MSISUMMARYINFO *si; PROPVARIANT *prop; + UINT ret = ERROR_SUCCESS; TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType, piValue, pftValue, str, pcchValueBuf); @@ -583,6 +584,8 @@ if( str->str.a ) lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf ); } + if (len >= *pcchValueBuf) + ret = ERROR_MORE_DATA; *pcchValueBuf = len; } break; @@ -597,7 +600,7 @@ break; } msiobj_release( &si->hdr ); - return ERROR_SUCCESS; + return ret; } UINT WINAPI MsiSummaryInfoGetPropertyA(
diff --git a/dlls/msi/tests/suminfo.c b/dlls/msi/tests/suminfo.c index b0f81b0..80c050a 100644 --- a/dlls/msi/tests/suminfo.c +++ b/dlls/msi/tests/suminfo.c
@@ -67,7 +67,7 @@ const char *msifile = "winetest.msi"; MSIHANDLE hdb = 0, hsuminfo; UINT r, count, type; - DWORD dwcount; + DWORD sz; INT val; FILETIME ft; char buf[0x10]; @@ -112,11 +112,11 @@ buf[0]='x'; buf[1]=0; - dwcount = 0x10; - r = MsiSummaryInfoGetProperty(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &dwcount); + sz = 0x10; + r = MsiSummaryInfoGetProperty(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &sz); ok(r == ERROR_SUCCESS, "getpropcount failed\n"); ok(buf[0]=='x', "cleared buffer\n"); - ok(dwcount == 0x10, "count wasn't zero\n"); + ok(sz == 0x10, "count wasn't zero\n"); ok(type == VT_EMPTY, "should be empty\n"); r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike"); @@ -177,6 +177,22 @@ r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike"); ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n"); + sz = 2; + strcpy(buf,"x"); + r = MsiSummaryInfoGetProperty(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz ); + ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n"); + ok(sz == 4, "count was wrong\n"); + ok(type == VT_LPSTR, "type was wrong\n"); + ok(!strcmp(buf,"M"), "buffer was wrong\n"); + + sz = 4; + strcpy(buf,"x"); + r = MsiSummaryInfoGetProperty(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz ); + ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n"); + ok(sz == 4, "count was wrong\n"); + ok(type == VT_LPSTR, "type was wrong\n"); + ok(!strcmp(buf,"Mik"), "buffer was wrong\n"); + r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh"); ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");