Commit 03335de8 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Return ERROR_INVALID_PARAMETER if a string pointer is non-NULL and the size pointer is NULL.

parent 856800c8
...@@ -1519,6 +1519,10 @@ UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf, ...@@ -1519,6 +1519,10 @@ UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL; LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
UINT ret = ERROR_OUTOFMEMORY; UINT ret = ERROR_OUTOFMEMORY;
if ((lpVersionBuf && !pcchVersionBuf) ||
(lpLangBuf && !pcchLangBuf))
return ERROR_INVALID_PARAMETER;
if( szFilePath ) if( szFilePath )
{ {
szwFilePath = strdupAtoW( szFilePath ); szwFilePath = strdupAtoW( szFilePath );
...@@ -1579,6 +1583,10 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf, ...@@ -1579,6 +1583,10 @@ UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0, lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
lpLangBuf, pcchLangBuf?*pcchLangBuf:0); lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
if ((lpVersionBuf && !pcchVersionBuf) ||
(lpLangBuf && !pcchLangBuf))
return ERROR_INVALID_PARAMETER;
dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL); dwVerLen = GetFileVersionInfoSizeW(szFilePath, NULL);
if( !dwVerLen ) if( !dwVerLen )
{ {
......
...@@ -1877,17 +1877,14 @@ static void test_MsiGetFileVersion(void) ...@@ -1877,17 +1877,14 @@ static void test_MsiGetFileVersion(void)
lstrcpyA(version, "version"); lstrcpyA(version, "version");
lstrcpyA(lang, "lang"); lstrcpyA(lang, "lang");
r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz); r = MsiGetFileVersionA("nonexistent", version, NULL, lang, &langsz);
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(!lstrcmpA(version, "version"), ok(!lstrcmpA(version, "version"),
"Expected version to be unchanged, got %s\n", version); "Expected version to be unchanged, got %s\n", version);
ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz); ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
ok(!lstrcmpA(lang, "lang"), ok(!lstrcmpA(lang, "lang"),
"Expected lang to be unchanged, got %s\n", lang); "Expected lang to be unchanged, got %s\n", lang);
ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz); ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
todo_wine
{
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
}
/* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */ /* nonexistent szFilePath, valid lpLangBuf, NULL pcchLangBuf */
versz = MAX_PATH; versz = MAX_PATH;
...@@ -1895,17 +1892,14 @@ static void test_MsiGetFileVersion(void) ...@@ -1895,17 +1892,14 @@ static void test_MsiGetFileVersion(void)
lstrcpyA(version, "version"); lstrcpyA(version, "version");
lstrcpyA(lang, "lang"); lstrcpyA(lang, "lang");
r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL); r = MsiGetFileVersionA("nonexistent", version, &versz, lang, NULL);
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(!lstrcmpA(version, "version"), ok(!lstrcmpA(version, "version"),
"Expected version to be unchanged, got %s\n", version); "Expected version to be unchanged, got %s\n", version);
ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz); ok(versz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, versz);
ok(!lstrcmpA(lang, "lang"), ok(!lstrcmpA(lang, "lang"),
"Expected lang to be unchanged, got %s\n", lang); "Expected lang to be unchanged, got %s\n", lang);
ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz); ok(langsz == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, langsz);
todo_wine
{
ok(r == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", r);
}
/* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */ /* nonexistent szFilePath, valid lpVersionBuf, pcchVersionBuf is zero */
versz = 0; versz = 0;
......
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