postgresql/src
Tom Lane 2330f4d3a8 Fix two issues in TOAST decompression.
pglz_maximum_compressed_size() potentially underestimated the amount
of compressed data required to produce N bytes of decompressed data;
this is a fault in commit 11a078cf8.

Separately from that, pglz_decompress() failed to protect itself
against corrupt compressed data, particularly off == 0 in a match
tag.  Commit c60e520f6 turned such a situation into an infinite loop,
where before it'd just have resulted in garbage output.

The combination of these two bugs seems like it may explain bug #16694
from Tom Vijlbrief, though it's impossible to be quite sure without
direct inspection of the failing session.  (One needs to assume that
the pglz_maximum_compressed_size() bug caused us to fail to fetch the
second byte of a match tag, and what happened to be there instead was
a zero.  The reported infinite loop is hard to explain without off == 0,
though.)

Aside from fixing the bugs, rewrite associated comments for more
clarity.

Back-patch to v13 where both these commits landed.

Discussion: https://postgr.es/m/16694-f107871e499ec114@postgresql.org
2020-11-01 18:38:42 -05:00
..
backend Preserve index data in pg_statistic across REINDEX CONCURRENTLY 2020-11-01 21:24:10 +09:00
bin Avoid null pointer dereference if error result lacks SQLSTATE. 2020-11-01 11:26:25 -05:00
common Fix two issues in TOAST decompression. 2020-11-01 18:38:42 -05:00
fe_utils Message fixes and style improvements 2020-09-14 06:42:07 +02:00
include Preserve index data in pg_statistic across REINDEX CONCURRENTLY 2020-11-01 21:24:10 +09:00
interfaces Fix ancient bug in ecpg's pthread_once() emulation for Windows. 2020-10-24 13:12:19 -04:00
makefiles Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
pl Fix incorrect assertion on number of array dimensions. 2020-10-01 11:50:34 +03:00
port Clear some style deviations. 2020-05-21 08:31:16 -07:00
template Makefile comment: remove reference to tools/thread/thread_test 2020-10-27 14:00:49 -04:00
test Preserve index data in pg_statistic across REINDEX CONCURRENTLY 2020-11-01 21:24:10 +09:00
timezone Update time zone data files to tzdata release 2020d. 2020-10-22 21:24:01 -04:00
tools Sync our copy of the timezone library with IANA release tzcode2020c. 2020-10-16 21:40:16 -04:00
tutorial Update copyrights for 2020 2020-01-01 12:21:45 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Update Unicode data to Unicode 13.0.0 and CLDR 37 2020-04-24 09:52:59 +02:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:04:20 +02:00