shlwapi: Fix AssocQueryStringW parameter checking.
This commit is contained in:
parent
0c568c2ae8
commit
db08d6e807
|
@ -244,7 +244,7 @@ HRESULT WINAPI AssocQueryStringW(ASSOCF cfFlags, ASSOCSTR str, LPCWSTR pszAssoc,
|
||||||
debugstr_w(pszExtra), pszOut, pcchOut);
|
debugstr_w(pszExtra), pszOut, pcchOut);
|
||||||
|
|
||||||
if (!pcchOut)
|
if (!pcchOut)
|
||||||
return E_INVALIDARG;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
lpAssoc = IQueryAssociations_Constructor();
|
lpAssoc = IQueryAssociations_Constructor();
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
|
||||||
debugstr_a(pszExtra), pszOut, pcchOut);
|
debugstr_a(pszExtra), pszOut, pcchOut);
|
||||||
|
|
||||||
if (!pcchOut)
|
if (!pcchOut)
|
||||||
hRet = E_INVALIDARG;
|
hRet = E_UNEXPECTED;
|
||||||
else if (SHLWAPI_ParamAToW(pszAssoc, szAssocW, MAX_PATH, &lpszAssocW) &&
|
else if (SHLWAPI_ParamAToW(pszAssoc, szAssocW, MAX_PATH, &lpszAssocW) &&
|
||||||
SHLWAPI_ParamAToW(pszExtra, szExtraW, MAX_PATH, &lpszExtraW))
|
SHLWAPI_ParamAToW(pszExtra, szExtraW, MAX_PATH, &lpszExtraW))
|
||||||
{
|
{
|
||||||
|
@ -520,7 +520,7 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
|
||||||
{
|
{
|
||||||
static const WCHAR szProgID[] = {'P','r','o','g','I','D',0};
|
static const WCHAR szProgID[] = {'P','r','o','g','I','D',0};
|
||||||
IQueryAssociationsImpl *This = (IQueryAssociationsImpl *)iface;
|
IQueryAssociationsImpl *This = (IQueryAssociationsImpl *)iface;
|
||||||
HRESULT hr;
|
LONG ret;
|
||||||
|
|
||||||
TRACE("(%p)->(%d,%s,%p,%p)\n", iface,
|
TRACE("(%p)->(%d,%s,%p,%p)\n", iface,
|
||||||
cfFlags,
|
cfFlags,
|
||||||
|
@ -533,23 +533,21 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
|
||||||
FIXME("unsupported flags: %x\n", cfFlags);
|
FIXME("unsupported flags: %x\n", cfFlags);
|
||||||
if (pszAssoc != NULL)
|
if (pszAssoc != NULL)
|
||||||
{
|
{
|
||||||
hr = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT,
|
||||||
pszAssoc,
|
pszAssoc,
|
||||||
0,
|
0,
|
||||||
KEY_READ,
|
KEY_READ,
|
||||||
&This->hkeySource);
|
&This->hkeySource);
|
||||||
if (FAILED(hr))
|
if (ret != ERROR_SUCCESS)
|
||||||
return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION);
|
return E_FAIL;
|
||||||
/* if this is not a prog id */
|
/* if this is not a prog id */
|
||||||
if ((*pszAssoc == '.') || (*pszAssoc == '{'))
|
if ((*pszAssoc == '.') || (*pszAssoc == '{'))
|
||||||
{
|
{
|
||||||
hr = RegOpenKeyExW(This->hkeySource,
|
RegOpenKeyExW(This->hkeySource,
|
||||||
szProgID,
|
szProgID,
|
||||||
0,
|
0,
|
||||||
KEY_READ,
|
KEY_READ,
|
||||||
&This->hkeyProgID);
|
&This->hkeyProgID);
|
||||||
if (FAILED(hr))
|
|
||||||
FIXME("Don't know what to return\n");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
This->hkeyProgID = This->hkeySource;
|
This->hkeyProgID = This->hkeySource;
|
||||||
|
@ -561,7 +559,7 @@ static HRESULT WINAPI IQueryAssociations_fnInit(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return E_FAIL;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -38,31 +38,31 @@ static void test_getstring_bad(void)
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, NULL, open, NULL, &len);
|
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, NULL, open, NULL, &len);
|
||||||
todo_wine expect_hr(E_INVALIDARG, hr);
|
expect_hr(E_INVALIDARG, hr);
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, badBad, open, NULL, &len);
|
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, badBad, open, NULL, &len);
|
||||||
todo_wine expect_hr(E_FAIL, hr);
|
expect_hr(E_FAIL, hr);
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, NULL, &len);
|
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, NULL, &len);
|
||||||
todo_wine expect_hr(E_FAIL, hr);
|
expect_hr(E_FAIL, hr);
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL,
|
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, invalid, NULL,
|
||||||
&len);
|
&len);
|
||||||
todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
|
todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, NULL);
|
hr = AssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotHtml, open, NULL, NULL);
|
||||||
todo_wine expect_hr(E_UNEXPECTED, hr);
|
expect_hr(E_UNEXPECTED, hr);
|
||||||
|
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, NULL, open, NULL, &len);
|
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, NULL, open, NULL, &len);
|
||||||
todo_wine expect_hr(E_INVALIDARG, hr);
|
expect_hr(E_INVALIDARG, hr);
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL,
|
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, badBad, open, NULL,
|
||||||
&len);
|
&len);
|
||||||
todo_wine expect_hr(E_FAIL, hr);
|
expect_hr(E_FAIL, hr);
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL,
|
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotBad, open, NULL,
|
||||||
&len);
|
&len);
|
||||||
todo_wine expect_hr(E_FAIL, hr);
|
expect_hr(E_FAIL, hr);
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL,
|
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, invalid, NULL,
|
||||||
&len);
|
&len);
|
||||||
todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
|
todo_wine expect_hr(0x80070002, hr); /* NOT FOUND */
|
||||||
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
|
hr = AssocQueryStringW(0, ASSOCSTR_FRIENDLYAPPNAME, dotHtml, open, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
todo_wine expect_hr(E_UNEXPECTED, hr);
|
expect_hr(E_UNEXPECTED, hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_getstring_basic(void)
|
static void test_getstring_basic(void)
|
||||||
|
|
Loading…
Reference in New Issue