Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2014-10

Buffer error in TDecompressionStream when decompressing some data without deflate header

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Архипов Владимир

Hello,

I need to use decompression without deflate header. I use TCompressionStream and TDecompressionStream with Askipheader=True like in zipper.pp
And I get buffer error on some strings only when compile code in FPC.

I tried to read from TDecompressionStream exactly like in zipper.pp unit but I got the same error.

The similar code in Delphi XE2 works fine with any data (windowBits = -15) The similar code with Askipheader=False works fine in FPC and Delphi.

I have noticed that the problem occurs when in string there are many duplicated letters.

I registered the issue http://bugs.freepascal.org/view.php?id=26827 where attached example project ziptest.dpr which can be compiled in FPC and Delphi.

SimpleZipTest('zdeafalatasddfas') - works!
SimpleZipTest('lalalalalalalala') - does not work! buffer error!

In Delphi XE2 both strings compressed and decompressed without errors.

Regards, Vladimir Arkhipov

Reply by email

Marco van de Voort
to Архипов Владимир

In our previous episode, ??????? ???????? said:

Show quoted text 5 lines
SimpleZipTest('zdeafalatasddfas') - works! SimpleZipTest('lalalalalalalala') - does not work! buffer error! In Delphi XE2 both strings compressed and decompressed without errors.

I quickly checked the bugreport last week and had the following conclusions:

1. the compressed stream is the same. So the problem is in the decompression.
2. Probably the first string doesn't compress, so it is stored instead of deflated, so that is pretty normal.
3. I checked in the paszlib source and skipheader does the same as windows bits, but it seems that it was meant to work for both large and small window sizes, while -15 is the value for large windowsizes (small buffers are useful on embedded, but the origins are in 16-bit dos/win3.x systems).

The code looks roughly sane, but it isn't clear where exactly the error shows. I haven't really debugged in detail.

Reply by email

Архипов Владимир
to Marco van de Voort

Hello!

My original task is to make GZIP stream compression/decompression (preferably without external libraries).
I read zlib specification in http://www.zlib.net/manual.html and tried to use WindowBits = 16 for automatic GZIP wrapping, but in FPC it does not works too (in Delphi XE2 works fine).
Also I tried to use simple Deflate mode (DeflateInit and InflateInit instead of DeflateInit2 and InflateInit2). In this case I can extract raw zlib data from compressed stream by myself. But when I try to decompress, I have to emulate simple deflate wrapper, but I have no adler32 checksum. From GZip I can get only crc32 checksum. When I try to decompress data with zero adler checksum or without adler checksum I get error in FPC (but in Delphi XE2 this case works fine too). Decompression with valid adler32 checksum works fine both in FPC and Delphi XE2. It is very strange.

2014-10-13 13:08 GMT+04:00 Marco van de Voort :

Show quoted text 23 lines
In our previous episode, ??????? ???????? said: > > SimpleZipTest('zdeafalatasddfas') - works! > SimpleZipTest('lalalalalalalala') - does not work! buffer error! > > In Delphi XE2 both strings compressed and decompressed without errors. I quickly checked the bugreport last week and had the following conclusions: 1. the compressed stream is the same. So the problem is in the decompression. 2. Probably the first string doesn't compress, so it is stored instead of deflated, so that is pretty normal. 3. I checked in the paszlib source and skipheader does the same as windows bits, but it seems that it was meant to work for both large and small window sizes, while -15 is the value for large windowsizes (small buffers are useful on embedded, but the origins are in 16-bit dos/win3.x systems). The code looks roughly sane, but it isn't clear where exactly the error shows. I haven't really debugged in detail. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Regards, Vladmir Arkhipov

Reply by email