possible fix for #904: "crash on startup in tr_bitfieldHas"

This commit is contained in:
Charles Kerr 2008-04-29 02:51:02 +00:00
parent ecc8401203
commit b05c7820c2
1 changed files with 5 additions and 1 deletions

View File

@ -585,7 +585,11 @@ parseVersion1( tr_torrent * tor, const uint8_t * buf, const uint8_t * end,
readBytes( &id, &buf, sizeof(id) );
readBytes( &len, &buf, sizeof(len) );
if( fieldsToLoad & internalIdToPublicBitfield( id ) ) switch( id )
if( buf + len > end )
{
tr_torerr( tor, "Resume file seems to be corrupt. Skipping." );
}
else if( fieldsToLoad & internalIdToPublicBitfield( id ) ) switch( id )
{
case FR_ID_DOWNLOADED: ret |= parseDownloaded( tor, buf, len ); break;
case FR_ID_UPLOADED: ret |= parseUploaded( tor, buf, len ); break;