Skip to content

Commit

Permalink
Fix iso9660::ReadFile() to no longer read one sector past file size
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbreuer committed Jul 13, 2013
1 parent 2960939 commit 8cb05d6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions xbmc/filesystem/iso9660.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,15 +902,13 @@ long iso9660::ReadFile(HANDLE hFile, uint8_t *pBuffer, long lSize)
if ( pContext->m_bUseMode2 )
sectorSize = MODE2_DATA_SIZE;

while (lSize > 0 && pContext->m_dwFilePos <= pContext->m_dwFileSize)
while (lSize > 0 && pContext->m_dwFilePos + sectorSize <= pContext->m_dwFileSize)
{
pContext->m_dwCurrentBlock = (DWORD) (pContext->m_dwFilePos / sectorSize);
int64_t iOffsetInBuffer = pContext->m_dwFilePos - (sectorSize * pContext->m_dwCurrentBlock);
pContext->m_dwCurrentBlock += pContext->m_dwStartBlock;

//char szBuf[256];
//sprintf(szBuf,"pos:%i cblk:%i sblk:%i off:%i",(long)m_dwFilePos, (long)m_dwCurrentBlock,(long)m_dwStartBlock,(long)iOffsetInBuffer);
//DBG(szBuf);
// CLog::Log(LOGDEBUG, "pos:%li cblk:%li sblk:%li off:%li",(long)pContext->m_dwFilePos, (long)pContext->m_dwCurrentBlock,(long)pContext->m_dwStartBlock,(long)iOffsetInBuffer);

uint8_t* pSector;
bError = !ReadSectorFromCache(pContext, pContext->m_dwCurrentBlock, &pSector);
Expand Down

0 comments on commit 8cb05d6

Please sign in to comment.