Commit 7bdf023e authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

ole32: Validate pointer parameters in MkParseDisplayName.

parent c4ea80cf
......@@ -1109,7 +1109,13 @@ HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(szDisplayName), pchEaten, ppmk);
if (!(IsValidInterface((LPUNKNOWN) pbc)))
if (!pbc || !IsValidInterface((LPUNKNOWN) pbc))
return E_INVALIDARG;
if (!szDisplayName || !*szDisplayName)
return E_INVALIDARG;
if (!pchEaten || !ppmk)
return E_INVALIDARG;
*pchEaten = 0;
......
......@@ -814,12 +814,53 @@ static void test_MkParseDisplayName(void)
static const WCHAR wszDisplayNameProgId1[] = {'S','t','d','F','o','n','t',':',0};
static const WCHAR wszDisplayNameProgId2[] = {'@','S','t','d','F','o','n','t',0};
static const WCHAR wszDisplayNameProgIdFail[] = {'S','t','d','F','o','n','t',0};
static const WCHAR wszEmpty[] = {0};
char szDisplayNameFile[256];
WCHAR wszDisplayNameFile[256];
int i;
const struct
{
LPBC *ppbc;
LPCOLESTR szDisplayName;
LPDWORD pchEaten;
LPMONIKER *ppmk;
} invalid_parameters[] =
{
{NULL, NULL, NULL, NULL},
{NULL, NULL, NULL, &pmk},
{NULL, NULL, &eaten, NULL},
{NULL, NULL, &eaten, &pmk},
{NULL, wszEmpty, NULL, NULL},
{NULL, wszEmpty, NULL, &pmk},
{NULL, wszEmpty, &eaten, NULL},
{NULL, wszEmpty, &eaten, &pmk},
{&pbc, NULL, NULL, NULL},
{&pbc, NULL, NULL, &pmk},
{&pbc, NULL, &eaten, NULL},
{&pbc, NULL, &eaten, &pmk},
{&pbc, wszEmpty, NULL, NULL},
{&pbc, wszEmpty, NULL, &pmk},
{&pbc, wszEmpty, &eaten, NULL},
{&pbc, wszEmpty, &eaten, &pmk},
};
hr = CreateBindCtx(0, &pbc);
ok_ole_success(hr, CreateBindCtx);
for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
{
eaten = 0xdeadbeef;
pmk = (IMoniker *)0xdeadbeef;
hr = MkParseDisplayName(invalid_parameters[i].ppbc ? *invalid_parameters[i].ppbc : NULL,
invalid_parameters[i].szDisplayName,
invalid_parameters[i].pchEaten,
invalid_parameters[i].ppmk);
ok(hr == E_INVALIDARG, "[%d] MkParseDisplayName should have failed with E_INVALIDARG instead of 0x%08x\n", i, hr);
ok(eaten == 0xdeadbeef, "[%d] Processed character count should have been 0xdeadbeef instead of %u\n", i, eaten);
ok(pmk == (IMoniker *)0xdeadbeef, "[%d] Output moniker pointer should have been 0xdeadbeef instead of %p\n", i, pmk);
}
hr = MkParseDisplayName(pbc, wszNonExistentProgId, &eaten, &pmk);
ok(hr == MK_E_SYNTAX || hr == MK_E_CANTOPENFILE /* Win9x */,
"MkParseDisplayName should have failed with MK_E_SYNTAX or MK_E_CANTOPENFILE instead of 0x%08x\n", hr);
......
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