File tree 1 file changed +15
-9
lines changed
1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -994,23 +994,29 @@ static int getFileInfo(fileInfo_t* info, const char* inFileName){
994
994
{ int lastBlock = 0 ;
995
995
do {
996
996
BYTE blockHeaderBuffer [3 ];
997
- U32 blockHeader ;
998
- int blockSize ;
999
997
size_t const readBytes = fread (blockHeaderBuffer , 1 , 3 , srcFile );
1000
998
if (readBytes != 3 ) {
1001
999
DISPLAY ("There was a problem reading the block header\n" );
1002
1000
detectError = 1 ;
1003
1001
break ;
1004
1002
}
1005
- blockHeader = MEM_readLE24 (blockHeaderBuffer );
1006
- lastBlock = blockHeader & 1 ;
1007
- blockSize = blockHeader >> 3 ; /* Warning : does not work when block is RLE type */
1008
- { int const ret = fseek (srcFile , blockSize , SEEK_CUR );
1009
- if (ret != 0 ) {
1010
- DISPLAY ("Error: could not skip to end of block\n" );
1003
+ { U32 const blockHeader = MEM_readLE24 (blockHeaderBuffer );
1004
+ U32 const blockTypeID = (blockHeader >> 1 ) & 3 ;
1005
+ U32 const isRLE = (blockTypeID == 1 );
1006
+ U32 const isWrongBlock = (blockTypeID == 3 );
1007
+ long const blockSize = isRLE ? 1 : (long )(blockHeader >> 3 );
1008
+ if (isWrongBlock ) {
1009
+ DISPLAY ("Error: unsupported block type \n" );
1011
1010
detectError = 1 ;
1012
1011
break ;
1013
- } }
1012
+ }
1013
+ lastBlock = blockHeader & 1 ;
1014
+ { int const ret = fseek (srcFile , blockSize , SEEK_CUR );
1015
+ if (ret != 0 ) {
1016
+ DISPLAY ("Error: could not skip to end of block\n" );
1017
+ detectError = 1 ;
1018
+ break ;
1019
+ } } }
1014
1020
} while (lastBlock != 1 );
1015
1021
1016
1022
if (detectError ) break ;
You can’t perform that action at this time.
0 commit comments