mstr- / twp-ggdump

Tool for listing and extracting files from data archive files of the game Thimbleweed Park.
GNU General Public License v2.0
19 stars 5 forks source link

For loop xor code needs tweaking - misses end of file #4

Open bgbennyboy opened 6 years ago

bgbennyboy commented 6 years ago

The code for the for loops (lines 151-155) needs tweaking. It misses a case in ggpack1 in the latest version. 5 bytes from the end the filename ends up as "zzycwhjpjk#ogg" The second for loop doesnt catch it because its less than 6 bytes from the end.

Possible fixes:

Replace both for loops with a while

   i = 5
    while i+1 < buf_len:
        buffer[i] = buffer[i] ^ 0x0D
        buffer[i+1] = buffer[i+1] ^ 0x0D
        i += 16

Or combine the for loops:

  for i in range(5, buf_len - 5, 16):
        buffer[i] = buffer[i] ^ 0x0D
        buffer[i+1] = buffer[i+1] ^ 0x0D