postgresql/src/backend
Tom Lane f02b9085ad Prevent integer overflows in array subscripting calculations.
While we were (mostly) careful about ensuring that the dimensions of
arrays aren't large enough to cause integer overflow, the lower bound
values were generally not checked.  This allows situations where
lower_bound + dimension overflows an integer.  It seems that that's
harmless so far as array reading is concerned, except that array
elements with subscripts notionally exceeding INT_MAX are inaccessible.
However, it confuses various array-assignment logic, resulting in a
potential for memory stomps.

Fix by adding checks that array lower bounds aren't large enough to
cause lower_bound + dimension to overflow.  (Note: this results in
disallowing cases where the last subscript position would be exactly
INT_MAX.  In principle we could probably allow that, but there's a lot
of code that computes lower_bound + dimension and would need adjustment.
It seems doubtful that it's worth the trouble/risk to allow it.)

Somewhat independently of that, array_set_element() was careless
about possible overflow when checking the subscript of a fixed-length
array, creating a different route to memory stomps.  Fix that too.

Security: CVE-2021-32027
2021-05-10 10:44:38 -04:00
..
access Revert recovery prefetching feature. 2021-05-10 16:06:09 +12:00
bootstrap Split backend status and progress related functionality out of pgstat.c. 2021-04-03 11:42:52 -07:00
catalog Revert recovery prefetching feature. 2021-05-10 16:06:09 +12:00
commands Fix typos in operatorcmds.c 2021-05-10 15:45:54 +09:00
executor Prevent integer overflows in array subscripting calculations. 2021-05-10 10:44:38 -04:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit jit: Fix warning reported by gcc-11 caused by dubious function signature. 2021-05-05 22:13:55 -07:00
lib Fix typo in comment 2021-04-20 14:35:16 +02:00
libpq pg_hba.conf.sample: Reword connection type section 2021-04-29 07:00:20 +02:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Revert per-index collation version tracking feature. 2021-05-07 21:10:11 +12:00
optimizer Revert per-index collation version tracking feature. 2021-05-07 21:10:11 +12:00
parser Fix typos in comments about extended statistics 2021-05-07 14:40:36 +02:00
partitioning Fix typo 2021-05-07 17:53:34 +02:00
po Translation updates 2021-05-10 14:36:21 +02:00
port Use correct format placeholder for WSAGetLastError() 2021-04-23 14:21:37 +02:00
postmaster Revert recovery prefetching feature. 2021-05-10 16:06:09 +12:00
regex Fix performance issue in new regex match-all detection code. 2021-05-03 11:42:31 -04:00
replication Revert recovery prefetching feature. 2021-05-10 16:06:09 +12:00
rewrite Remove unused function argument 2021-05-03 09:05:58 +02:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Fix typos in comments about extended statistics 2021-05-07 14:40:36 +02:00
storage Revert recovery prefetching feature. 2021-05-10 16:06:09 +12:00
tcop Revert per-index collation version tracking feature. 2021-05-07 21:10:11 +12:00
tsearch Fix typos and grammar in comments and docs 2021-04-19 11:32:30 +09:00
utils Prevent integer overflows in array subscripting calculations. 2021-05-10 10:44:38 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2021-05-10 14:36:21 +02:00