Commit c6e5e394 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

urlmon: Validate parameters in MkParseDisplayNameEx.

parent 07325c7d
......@@ -1418,8 +1418,50 @@ static void test_MkParseDisplayNameEx(void)
'2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8',
'-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
const struct
{
LPBC *ppbc;
LPCWSTR szDisplayName;
ULONG *pchEaten;
LPMONIKER *ppmk;
} invalid_parameters[] =
{
{NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, &mon},
{NULL, NULL, &eaten, NULL},
{NULL, NULL, &eaten, &mon},
{NULL, wszEmpty, NULL, NULL},
{NULL, wszEmpty, NULL, &mon},
{NULL, wszEmpty, &eaten, NULL},
{NULL, wszEmpty, &eaten, &mon},
{&bctx, NULL, NULL, NULL},
{&bctx, NULL, NULL, &mon},
{&bctx, NULL, &eaten, NULL},
{&bctx, NULL, &eaten, &mon},
{&bctx, wszEmpty, NULL, NULL},
{&bctx, wszEmpty, NULL, &mon},
{&bctx, wszEmpty, &eaten, NULL},
{&bctx, wszEmpty, &eaten, &mon},
};
int i;
CreateBindCtx(0, &bctx);
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
{
eaten = 0xdeadbeef;
mon = (IMoniker *)0xdeadbeef;
hres = MkParseDisplayNameEx(invalid_parameters[i].ppbc ? *invalid_parameters[i].ppbc : NULL,
invalid_parameters[i].szDisplayName,
invalid_parameters[i].pchEaten,
invalid_parameters[i].ppmk);
ok(hres == E_INVALIDARG,
"[%d] Expected MkParseDisplayNameEx to return E_INVALIDARG, got %08x\n", i, hres);
ok(eaten == 0xdeadbeef, "[%d] Expected eaten to be 0xdeadbeef, got %u\n", i, eaten);
ok(mon == (IMoniker *)0xdeadbeef, "[%d] Expected mon to be 0xdeadbeef, got %p\n", i, mon);
}
hres = MkParseDisplayNameEx(bctx, url9, &eaten, &mon);
ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
ok(eaten == sizeof(url9)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
......
......@@ -625,6 +625,9 @@ HRESULT WINAPI MkParseDisplayNameEx(IBindCtx *pbc, LPCWSTR szDisplayName, ULONG
{
TRACE("(%p %s %p %p)\n", pbc, debugstr_w(szDisplayName), pchEaten, ppmk);
if (!pbc || !szDisplayName || !*szDisplayName || !pchEaten || !ppmk)
return E_INVALIDARG;
if(is_registered_protocol(szDisplayName)) {
HRESULT hres;
......
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