Skip to content

Commit

Permalink
Fuzzing formats, lh.library corner case fix (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
temisu authored Jul 7, 2024
1 parent f5a679b commit ab9704a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 73 deletions.
149 changes: 79 additions & 70 deletions fuzzing/all_formats.dict
Original file line number Diff line number Diff line change
@@ -1,80 +1,89 @@
"XPKF"
"TPWM"
"TDCS"
"ACCA"
"SASC"
"SHSC"
"ARTM"
"BLZW"
"BZP2"
"BZh1"
"BZh2"
"BZh3"
"BZh4"
"BZh5"
"BZh6"
"BZh7"
"BZh8"
"BZh9"
"CBR0"
"CBR1"
"CRMS"
"CYB2"
"CrM!"
"CrM2"
"Crm!"
"Crm2"
"DLTA"
"DMS!"
"DUKE"
"ELZX"
"FAST"
"FBR2"
"FRHT"
"FRLE"
"GZIP"
"HFMN"
"HUFF"
"ICE!"
"ILZR"
"IMP!"
"IMPL"
"Ice!"
"LHLB"
"LIN1"
"LIN2"
"LIN3"
"LIN4"
"LZBS"
"LZCB"
"LZW2"
"LZW3"
"LZW4"
"LZW5"
"LZX\x00"
"MASH"
"NONE"
"NUKE"
"PP11"
"PP20"
"PPMQ"
"PWPK"
"PX20"
"RAKE"
"RDCN"
"RLEN"
"RNC\x01"
"RNC\x02"
"S300"
"S310"
"S400"
"S401"
"S403"
"S404"
"SQSH"
"SMPL"
"SLZ3"
"SHRI"
"SHR3"
"SASC"
"SDHC"
"RNC\x01"
"RNC\x02"
"RLEN"
"RDCN"
"FRHT"
"RAKE"
"PP11"
"PP20"
"PWPK"
"NUKE"
"DUKE"
"NONE"
"ziRCONia"
"MASH"
"ELZX"
"SFCD"
"SFHD"
"SHR3"
"SHRI"
"SHSC"
"SLZ3"
"SLZX"
"LZW5"
"LZW4"
"LZW2"
"LZW3"
"LZCB"
"LZBS"
"LIN2"
"LIN4"
"LIN1"
"LIN3"
"LHLB"
"ATN!"
"EDAM"
"IMP!"
"M.H."
"BDPI"
"CHFI"
"RDC9"
"Dupa"
"FLT!"
"PARA"
"IMPL"
"ILZR"
"HUFF"
"HFMN"
"FRLE"
"FBR2"
"FAST"
"DMS!"
"TR"
"DLTA"
"GZIP"
"CYB2"
"CrM!"
"CrM2"
"Crm!"
"Crm2"
"CRM2"
"CRMS"
"CBR0"
"CBR1"
"BZP2"
"BZh2"
"BLZW"
"ARTM"
"SMPL"
"SQSH"
"TDCS"
"TPWM"
"Vic2"
"Vice"
"XPKF"
"ZENO"
"\x01LOB"
"\x02LOB"
"\x03LOB"
"ziRCONia"
4 changes: 3 additions & 1 deletion src/LHDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void LHDecompressor::decompressLhLib(Buffer &rawData,const Buffer &packedData)
uint32_t distance{vlcDecoder.decode(readBits,readBits(4U))};
uint32_t count{code-255U};

outputStream.copy(distance,count);
// Very interesting LH-bug on zero distance.
if (distance) outputStream.copy(distance,count);
else for (uint32_t i=0;i<count;i++) outputStream.writeByte(0);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/StoneCrackerDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ bool StoneCrackerDecompressor::detectHeaderAndGeneration(uint32_t hdr,uint32_t &
// Specials
switch (hdr&0xffff'ff00U)
{
case FourCC("1AM\000"): // Reunion
case FourCC("1AM\0"): // Reunion
generation=3;
return true;

case FourCC("2AM\000"): // Reunion
case FourCC("2AM\0"): // Reunion
generation=6;
return true;

Expand Down

0 comments on commit ab9704a

Please sign in to comment.