mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +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))
|
||||
return E_POINTER;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
ULONG fetched = 0;
|
||||
LPITEMIDLIST item;
|
||||
CStringW name;
|
||||
bool dir;
|
||||
unz_file_info64 info;
|
||||
for (ULONG i = 0; i < celt; ++i)
|
||||
|
||||
while (fetched < celt)
|
||||
{
|
||||
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);
|
||||
if (!item)
|
||||
return i ? S_FALSE : E_OUTOFMEMORY;
|
||||
rgelt[i] = item;
|
||||
if (mEnumerator.next_unique(m_Prefix, name, dir, info))
|
||||
{
|
||||
item = _ILCreate(dir ? ZIP_PIDL_DIRECTORY : ZIP_PIDL_FILE, name, info);
|
||||
if (!item)
|
||||
{
|
||||
hr = fetched ? S_FALSE : E_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
rgelt[fetched++] = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = S_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
if (pceltFetched)
|
||||
*pceltFetched = fetched;
|
||||
return hr;
|
||||
}
|
||||
STDMETHODIMP Skip(ULONG celt)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue