Improve pglz_decompress() so that it cannot clobber memory beyond the
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 8 Mar 2008 01:09:36 +0000 (01:09 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 8 Mar 2008 01:09:36 +0000 (01:09 +0000)
commit0ff7a6eae2898cf705ca27746b4760e4fe6bd0fc
tree5c03447e361dbefa7032913a2af723c3d3f1a279
parent3b6942b3f2fe733572c05a71cb2d12e5ece60cdb
Improve pglz_decompress() so that it cannot clobber memory beyond the
available output buffer when presented with corrupt input.  Some testing
suggests that this slows the decompression loop about 1%, which seems an
acceptable price to pay for more robustness.  (Curiously, the penalty
seems to be *less* on not-very-compressible data, which I didn't expect
since the overhead per output byte ought to be more in the literal-bytes
path.)

Patch from Zdenek Kotala.  I fixed a corner case and did some renaming
of variables to make the routine more readable.
src/backend/utils/adt/pg_lzcompress.c