juninho12 / freearc

Automatically exported from code.google.com/p/freearc
1 stars 0 forks source link

srep decompression wraparound using 32 bit executable, original input >2^32 bytes #321

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Input file of 512 bytes ascii '0', 4 GiB of ascii '1', 512 bytes of ascii '0'
2. Using srep 32 bit, encode: srep -l512 -a1 file file.srep
3. Using srep 32 bit, decode: srep -d file.srep file.comp
4. srep does not give an error, but file.comp does not match file

What is the expected output? What do you see instead?
Expected output: The file as described in step 1, or an error stating the 
problem
Actual output: A 2^32 byte file, which appears to be the the first 2^32 bytes 
of the expected output, with the remaining expected output overwriting the 
beginning of the file.

What version of the product are you using? On what operating system?
3.0, on linux mint 12, using srep 32 bit elf.

Please provide any additional information below.
srep64 successfully decoded the srep output which srep 32 bit failed to decode 
(the srep output was created with the 32 bit version).

MD5 hashes:
0a1118c2892ea83f6a125cd34f56a8fc  file
c4a43afb997d26893482431eaf575bbe  file.32bit.output
0a1118c2892ea83f6a125cd34f56a8fc  file.64bit.output

Attached is the srep file in question, created with srep 32 bit, which decodes 
successfully on srep64 but fails to decode properly on srep 32 bit.

Original issue reported on code.google.com by jam.pudd...@gmail.com on 22 Sep 2012 at 8:29

Attachments:

GoogleCodeExporter commented 9 years ago
it looks very likely to the lack of 64-bit file offset support. have you tried 
this with SREP 3.0?

Original comment by bulat.zi...@gmail.com on 23 Sep 2012 at 12:54

GoogleCodeExporter commented 9 years ago
Yes, version 3.0 is the version I'm using. The 32 bit windows version works 
fine to decode the test srep attached.

I could be wrong but it might be to do with Common.h line 250:
#define file_seek(stream,pos)                   (fseek(stream, (pos), SEEK_SET))
Maybe it should be fseeko64? This is what has been done on line 199 for windows 
32 bit. Having only a vague grasp of this, wouldn't fseek be 32 bits on 32 bit 
compile, possibly regardless of -D_FILE_OFFSET_BITS=64 ? Unfortunately I cannot 
test it as yet, gcc wont compile it when I add -m32 to try and compile to 32 
bit code from a 64 bit linux.

Original comment by jam.pudd...@gmail.com on 23 Sep 2012 at 9:38

GoogleCodeExporter commented 9 years ago
Use fseeko instead of fseek in Common.h.
Change line:
#define file_seek(stream,pos)                   (fseek(stream, (pos), SEEK_SET))
to:
#define file_seek(stream,pos)                   (fseeko(stream, (pos), 
SEEK_SET))

Original comment by vari...@gmail.com on 22 Dec 2013 at 11:18