postgresql/contrib
Andrew Gierth 757c5182f2 Avoid crashes in contrib/intarray gist__int_ops (bug #15518)
1. Integer overflow in internal_size could result in memory corruption
in decompression since a zero-length array would be allocated and then
written to. This leads to crashes or corruption when traversing an
index which has been populated with sufficiently sparse values. Fix by
using int64 for computations and checking for overflow.

2. Integer overflow in g_int_compress could cause pessimal merge
choices, resulting in unnecessarily large ranges (which would in turn
trigger issue 1 above). Fix by using int64 again.

3. Even without overflow, array sizes could become large enough to
cause unexplained memory allocation errors. Fix by capping the sizes
to a safe limit and report actual errors pointing at gist__intbig_ops
as needed.

4. Large inputs to the compression function always consist of large
runs of consecutive integers, and the compression loop was processing
these one at a time in an O(N^2) manner with a lot of overhead. The
expected runtime of this function could easily exceed 6 months for a
single call as a result. Fix by performing a linear-time first pass,
which reduces the worst case to something on the order of seconds.

Backpatch all the way, since this has been wrong forever.

Per bug #15518 from report from irc user "dymk", analysis and patch by
me.

Discussion: https://postgr.es/m/15518-799e426c3b4f8358@postgresql.org
2018-11-24 08:48:36 +00:00
..
adminpack Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
amcheck Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
auth_delay Update copyright for 2018 2018-01-02 23:30:12 -05:00
auto_explain Fix issues around EXPLAIN with JIT. 2018-10-03 12:48:37 -07:00
bloom Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
btree_gin Provide separate header file for built-in float types 2018-07-29 03:30:48 +02:00
btree_gist Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
citext Add a 64-bit hash function for type citext. 2018-11-23 13:24:45 -05:00
cube Make float exponent output on Windows look the same as elsewhere. 2018-10-12 11:14:27 -04:00
dblink Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
dict_int Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
dict_xsyn Avoid unnecessary use of pg_strcasecmp for already-downcased identifiers. 2018-01-26 18:25:14 -05:00
earthdistance Fix earthdistance test suite function name typo. 2018-07-29 12:02:07 -07:00
file_fdw Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
fuzzystrmatch Replace search.cpan.org with metacpan.org 2018-06-29 22:02:20 +09:00
hstore Add a 64-bit hash function for type hstore. 2018-11-23 13:37:34 -05:00
hstore_plperl Still further rethinking of build changes for macOS Mojave. 2018-10-18 14:55:23 -04:00
hstore_plpython Fix out-of-tree build for transform modules. 2018-09-16 18:46:45 +01:00
intagg Schema-qualify some references to regprocedure. 2016-06-10 10:41:58 -04:00
intarray Avoid crashes in contrib/intarray gist__int_ops (bug #15518) 2018-11-24 08:48:36 +00:00
isn Provide for contrib and pgxs modules to install include files. 2018-07-31 20:07:39 +01:00
jsonb_plperl Still further rethinking of build changes for macOS Mojave. 2018-10-18 14:55:23 -04:00
jsonb_plpython Remove redundant allocation 2018-10-05 17:10:58 +02:00
lo lo: Add test suite 2017-09-14 22:22:59 -04:00
ltree Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
ltree_plpython Fix out-of-tree build for transform modules. 2018-09-16 18:46:45 +01:00
oid2name Clean up after TAP tests in oid2name and vacuumlo. 2018-09-04 10:52:01 -04:00
pageinspect Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
passwordcheck Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_buffercache Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
pg_freespacemap Default monitoring roles 2017-03-30 14:18:53 -04:00
pg_prewarm Silence compiler warnings 2018-11-23 13:01:05 -03:00
pg_standby Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:17 -04:00
pg_stat_statements Revoke pg_stat_statements_reset() permissions 2018-09-25 09:55:44 +09:00
pg_trgm Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
pg_visibility Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
pgcrypto Allow btree comparison functions to return INT_MIN. 2018-10-05 16:01:29 -04:00
pgrowlocks Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
pgstattuple pgstatindex, pageinspect: handle partitioned indexes 2018-05-09 14:22:59 -03:00
postgres_fdw Add WL_EXIT_ON_PM_DEATH pseudo-event. 2018-11-23 20:46:34 +13:00
seg Make float exponent output on Windows look the same as elsewhere. 2018-10-12 11:14:27 -04:00
sepgsql Blind attempt at fixing sepgsql output for 578b22. 2018-11-20 21:02:38 -08:00
spi Remove timetravel extension. 2018-10-11 11:43:56 -07:00
sslinfo Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
start-scripts Remove contrib/start-scripts/osx/. 2017-11-17 12:53:20 -05:00
tablefunc Update copyright for 2018 2018-01-02 23:30:12 -05:00
tcn Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
test_decoding Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
tsm_system_rows Update copyright for 2018 2018-01-02 23:30:12 -05:00
tsm_system_time Rethink how to get float.h in old Windows API for isnan/isinf 2018-07-11 09:11:48 -04:00
unaccent Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
uuid-ossp Update copyright for 2018 2018-01-02 23:30:12 -05:00
vacuumlo Clean up after TAP tests in oid2name and vacuumlo. 2018-09-04 10:52:01 -04:00
xml2 Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
Makefile Transforms for jsonb to PL/Perl 2018-04-03 09:47:18 -04:00
README Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00
contrib-global.mk Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00

README

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.