X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=Client%20Applications%2Frcracki_mt%2FRTI2Reader.cpp;h=54538986c009b478c56265a66f991f9dcbe679a9;hb=47c71901e7a97c226c8f1df749e3606d43656f32;hp=abd855076517797a322f22c81be219e749963112;hpb=0fb676244827a448dc60118d6558c4a4e346ffee;p=freerainbowtables diff --git a/Client Applications/rcracki_mt/RTI2Reader.cpp b/Client Applications/rcracki_mt/RTI2Reader.cpp index abd8550..5453898 100644 --- a/Client Applications/rcracki_mt/RTI2Reader.cpp +++ b/Client Applications/rcracki_mt/RTI2Reader.cpp @@ -4,7 +4,7 @@ * * Copyright 2010 Martin Westergaard Jørgensen * Copyright 2010 Daniël Niggebrugge - * Copyright 2010 James Nobis + * Copyright 2010, 2011 James Nobis * * This file is part of rcracki_mt. * @@ -48,7 +48,11 @@ RTI2Reader::RTI2Reader(string Filename) long len = GetFileLen(pFileIndex); fseek(pFileIndex, 0, SEEK_SET); - m_pIndex = new unsigned char[len]; + m_pIndex = new (nothrow) unsigned char[len]; + if(m_pIndex == NULL) { + printf("Error allocating %ld MB memory for index in RTI2Reader::RTI2Reader()", len / (1024 * 1024)); + exit(-2); + } if(fread(m_pIndex, 1, len, pFileIndex) != (unsigned long)len) { printf("Error while reading index file"); @@ -67,7 +71,7 @@ RTI2Reader::RTI2Reader(string Filename) fseek(m_pFile, 0, SEEK_SET); if(len % m_chainsizebytes > 0) { - printf("Invalid filesize %ld\n", len); + printf("Invalid filesize %lu\n", len); return; } @@ -81,7 +85,7 @@ RTI2Reader::~RTI2Reader(void) } -unsigned int RTI2Reader::GetChainsLeft() +uint32 RTI2Reader::GetChainsLeft() { long len = GetFileLen(m_pFile); return len / m_chainsizebytes - m_chainPosition; @@ -101,6 +105,7 @@ int RTI2Reader::ReadChains(unsigned int &numChains, RainbowChainO *pData) while(true) // Fast forward to current position { + /// XXX // ALERT: Possible problem here if m_indexrowsizebytes > 1 as pNumChains is a unsigned char. unsigned int NumChainsInRow = (unsigned int)*(pNumChains + indexRow * m_indexrowsizebytes); if(m_indexrowsizebytes > 1)