Commit 0867e48d authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

- 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
parent 575b4116
...@@ -544,6 +544,7 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, ...@@ -544,6 +544,7 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
{ {
MSISUMMARYINFO *si; MSISUMMARYINFO *si;
PROPVARIANT *prop; PROPVARIANT *prop;
UINT ret = ERROR_SUCCESS;
TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType, TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
piValue, pftValue, str, pcchValueBuf); piValue, pftValue, str, pcchValueBuf);
...@@ -583,6 +584,8 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, ...@@ -583,6 +584,8 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
if( str->str.a ) if( str->str.a )
lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf ); lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf );
} }
if (len >= *pcchValueBuf)
ret = ERROR_MORE_DATA;
*pcchValueBuf = len; *pcchValueBuf = len;
} }
break; break;
...@@ -597,7 +600,7 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, ...@@ -597,7 +600,7 @@ static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
break; break;
} }
msiobj_release( &si->hdr ); msiobj_release( &si->hdr );
return ERROR_SUCCESS; return ret;
} }
UINT WINAPI MsiSummaryInfoGetPropertyA( UINT WINAPI MsiSummaryInfoGetPropertyA(
......
...@@ -67,7 +67,7 @@ START_TEST(suminfo) ...@@ -67,7 +67,7 @@ START_TEST(suminfo)
const char *msifile = "winetest.msi"; const char *msifile = "winetest.msi";
MSIHANDLE hdb = 0, hsuminfo; MSIHANDLE hdb = 0, hsuminfo;
UINT r, count, type; UINT r, count, type;
DWORD dwcount; DWORD sz;
INT val; INT val;
FILETIME ft; FILETIME ft;
char buf[0x10]; char buf[0x10];
...@@ -112,11 +112,11 @@ START_TEST(suminfo) ...@@ -112,11 +112,11 @@ START_TEST(suminfo)
buf[0]='x'; buf[0]='x';
buf[1]=0; buf[1]=0;
dwcount = 0x10; sz = 0x10;
r = MsiSummaryInfoGetProperty(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &dwcount); r = MsiSummaryInfoGetProperty(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &sz);
ok(r == ERROR_SUCCESS, "getpropcount failed\n"); ok(r == ERROR_SUCCESS, "getpropcount failed\n");
ok(buf[0]=='x', "cleared buffer\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"); ok(type == VT_EMPTY, "should be empty\n");
r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike"); r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
...@@ -177,6 +177,22 @@ START_TEST(suminfo) ...@@ -177,6 +177,22 @@ START_TEST(suminfo)
r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike"); r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n"); 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"); r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n"); ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment