mirror of
https://github.com/reactos/reactos.git
synced 2025-07-13 02:34:15 +00:00
[ZIPFLDR] Fix off-by-one count error during enumeration (#6040)
CORE-19342
This commit is contained in:
parent
af7defb556
commit
c7777f5963
1 changed files with 23 additions and 10 deletions
|
@ -37,22 +37,35 @@ public:
|
||||||
if (!rgelt || (!pceltFetched && celt != 1))
|
if (!rgelt || (!pceltFetched && celt != 1))
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
ULONG fetched = 0;
|
||||||
LPITEMIDLIST item;
|
LPITEMIDLIST item;
|
||||||
CStringW name;
|
CStringW name;
|
||||||
bool dir;
|
bool dir;
|
||||||
unz_file_info64 info;
|
unz_file_info64 info;
|
||||||
for (ULONG i = 0; i < celt; ++i)
|
|
||||||
|
while (fetched < celt)
|
||||||
|
{
|
||||||
|
if (mEnumerator.next_unique(m_Prefix, name, dir, info))
|
||||||
{
|
{
|
||||||
if (pceltFetched)
|
|
||||||
*pceltFetched = i;
|
|
||||||
if (!mEnumerator.next_unique(m_Prefix, name, dir, info))
|
|
||||||
return S_FALSE;
|
|
||||||
item = _ILCreate(dir ? ZIP_PIDL_DIRECTORY : ZIP_PIDL_FILE, name, info);
|
item = _ILCreate(dir ? ZIP_PIDL_DIRECTORY : ZIP_PIDL_FILE, name, info);
|
||||||
if (!item)
|
if (!item)
|
||||||
return i ? S_FALSE : E_OUTOFMEMORY;
|
{
|
||||||
rgelt[i] = item;
|
hr = fetched ? S_FALSE : E_OUTOFMEMORY;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return S_OK;
|
rgelt[fetched++] = item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = S_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pceltFetched)
|
||||||
|
*pceltFetched = fetched;
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
STDMETHODIMP Skip(ULONG celt)
|
STDMETHODIMP Skip(ULONG celt)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue