postgresql/src/include
Tom Lane e24daa94b2 Detect integer overflow while computing new array dimensions.
array_set_element() and related functions allow an array to be
enlarged by assigning to subscripts outside the current array bounds.
While these places were careful to check that the new bounds are
allowable, they neglected to consider the risk of integer overflow
in computing the new bounds.  In edge cases, we could compute new
bounds that are invalid but get past the subsequent checks,
allowing bad things to happen.  Memory stomps that are potentially
exploitable for arbitrary code execution are possible, and so is
disclosure of server memory.

To fix, perform the hazardous computations using overflow-detecting
arithmetic routines, which fortunately exist in all still-supported
branches.

The test cases added for this generate (after patching) errors that
mention the value of MaxArraySize, which is platform-dependent.
Rather than introduce multiple expected-files, use psql's VERBOSITY
parameter to suppress the printing of the message text.  v11 psql
lacks that parameter, so omit the tests in that branch.

Our thanks to Pedro Gallegos for reporting this problem.

Security: CVE-2023-5869
2023-11-06 10:56:43 -05:00
..
access Fix btmarkpos/btrestrpos array key wraparound bug. 2023-09-28 16:29:35 -07:00
archive Redesign archive modules 2023-02-17 14:26:42 +09:00
backup Fix some typos and some incorrectly duplicated words 2023-04-18 14:03:49 +12:00
bootstrap Update copyright for 2023 2023-01-02 15:00:37 -05:00
catalog Dissociate btequalimage() from interval_ops, ending its deduplication. 2023-10-14 16:33:54 -07:00
commands Revert MAINTAIN privilege and pg_maintain predefined role. 2023-07-07 11:25:23 -07:00
common Remove stray mid-sentence tabs in comments 2023-05-19 16:13:16 +02:00
datatype Code review for commit 05a7be935. 2023-01-26 12:51:00 -05:00
executor Remove obsolete comment 2023-06-05 15:33:08 +02:00
fe_utils Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
foreign Update copyright for 2023 2023-01-02 15:00:37 -05:00
jit jit: Supply LLVMGlobalGetValueType() for LLVM < 8. 2023-10-19 03:07:18 +13:00
lib Fix type of iterator variable in SH_START_ITERATE 2023-07-06 09:57:29 -07:00
libpq Remove a few unused global variables and declarations. 2023-06-12 16:25:37 +03:00
mb Update copyright for 2023 2023-01-02 15:00:37 -05:00
nodes Fix problems when a plain-inheritance parent table is excluded. 2023-10-24 14:48:34 -04:00
optimizer Disallow replacing joins with scans in problematic cases. 2023-07-28 15:45:01 +09:00
parser Avoid unnecessary plancache revalidation of utility statements. 2023-08-24 12:02:40 -04:00
partitioning Revert "Move PartitionPruneInfo out of plan nodes into PlannedStmt" 2023-05-04 12:09:59 +02:00
pch Update copyright for 2023 2023-01-02 15:00:37 -05:00
port Don't use _BitScanForward64/_BitScanReverse64 on 32-bit MSVC builds 2023-06-08 10:10:34 +12:00
portability instr_time: Represent time as an int64 on all platforms 2023-01-20 21:16:47 -08:00
postmaster Fix wal_writer_flush_after initializer value. 2023-05-15 11:19:54 +12:00
regex Fix various typos 2023-04-18 13:23:23 +12:00
replication Rename logical_replication_mode to debug_logical_replication_streaming 2023-08-29 15:24:09 +02:00
rewrite Make Vars be outer-join-aware. 2023-01-30 13:16:20 -05:00
snowball Update copyright for 2023 2023-01-02 15:00:37 -05:00
statistics Update copyright for 2023 2023-01-02 15:00:37 -05:00
storage ExtendBufferedWhat -> BufferManagerRelation. 2023-08-23 12:33:24 +12:00
tcop Update copyright for 2023 2023-01-02 15:00:37 -05:00
tsearch Update tsearch regex memory management. 2023-04-08 22:09:17 +12:00
utils Detect integer overflow while computing new array dimensions. 2023-11-06 10:56:43 -05:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
Makefile Include headers of archive/ in installation 2023-03-10 20:08:10 +09:00
c.h Introduce PG_IO_ALIGN_SIZE and align all I/O buffers. 2023-04-08 16:34:50 +12:00
fmgr.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
funcapi.h Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
getopt_long.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
meson.build meson: Make some Meson style more consistent with surrounding code 2023-06-29 13:06:02 +02:00
miscadmin.h Add VACUUM/ANALYZE BUFFER_USAGE_LIMIT option 2023-04-07 11:40:31 +12:00
pg_config.h.in Further cleanup of autoconf output files for GSSAPI changes. 2023-04-17 11:21:50 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.meson meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pg_config_manual.h Fix typos in comments 2023-05-02 12:23:08 +09:00
pg_getopt.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_trace.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgstat.h Add writeback to pg_stat_io 2023-05-17 11:18:35 -07:00
pgtar.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgtime.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
port.h Add SHELL_ERROR and SHELL_EXIT_CODE magic variables to psql. 2023-03-21 13:03:56 -04:00
postgres.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
postgres_ext.h Move RelFileNumber declarations to common/relpath.h. 2022-09-27 12:01:57 -04:00
postgres_fe.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
varatt.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
windowapi.h Update copyright for 2023 2023-01-02 15:00:37 -05:00