msi: Return ERROR_MORE_DATA if the size is too small.

This commit is contained in:
James Hawkins 2008-02-04 11:38:00 -06:00 committed by Alexandre Julliard
parent dc8f714ade
commit ffc251f5dd
2 changed files with 10 additions and 8 deletions

View File

@ -1621,6 +1621,10 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
HIWORD(ffi->dwFileVersionMS), LOWORD(ffi->dwFileVersionMS),
HIWORD(ffi->dwFileVersionLS), LOWORD(ffi->dwFileVersionLS));
if (lpVersionBuf) lstrcpynW(lpVersionBuf, tmp, *pcchVersionBuf);
if (lstrlenW(tmp) >= *pcchVersionBuf)
ret = ERROR_MORE_DATA;
*pcchVersionBuf = lstrlenW(tmp);
}
else
@ -1637,6 +1641,10 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
FIXME("Retrieve language from file\n");
wsprintfW(tmp, szLangFormat, lang);
if (lpLangBuf) lstrcpynW(lpLangBuf, tmp, *pcchLangBuf);
if (lstrlenW(tmp) >= *pcchLangBuf)
ret = ERROR_MORE_DATA;
*pcchLangBuf = lstrlenW(tmp);
}

View File

@ -2024,25 +2024,19 @@ static void test_MsiGetFileVersion(void)
versz = 5;
lstrcpyA(version, "version");
r = MsiGetFileVersionA(path, version, &versz, NULL, NULL);
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
ok(!strncmp(version, vercheck, 4),
"Expected first 4 characters of %s, got %s\n", vercheck, version);
ok(versz == verchecksz, "Expected %d, got %d\n", verchecksz, versz);
todo_wine
{
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
}
/* pcchLangBuf not big enough */
langsz = 3;
lstrcpyA(lang, "lang");
r = MsiGetFileVersionA(path, NULL, NULL, lang, &langsz);
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
ok(!strncmp(lang, langcheck, 2),
"Expected first character of %s, got %s\n", langcheck, lang);
ok(langsz == langchecksz, "Expected %d, got %d\n", langchecksz, langsz);
todo_wine
{
ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
}
HeapFree(GetProcessHeap(), 0, vercheck);
HeapFree(GetProcessHeap(), 0, langcheck);