postgresql/src/include
Tom Lane 97031f4404 Fix bogus casting in BlockIdGetBlockNumber().
This macro cast the result to BlockNumber after shifting, not before,
which is the wrong thing.  Per the C spec, the uint16 fields would
promote to int not unsigned int, so that (for 32-bit int) the shift
potentially shifts a nonzero bit into the sign position.  I doubt
there are any production systems where this would actually end with
the wrong answer, but it is undefined behavior per the C spec, and
clang's -fsanitize=undefined option reputedly warns about it on some
platforms.  (I can't reproduce that right now, but the code is
undeniably wrong per spec.)  It's easy to fix by casting to
BlockNumber (uint32) in the proper places.

It's been wrong for ages, so back-patch to all supported branches.

Report and patch by Zhihong Yu (cosmetic tweaking by me)

Discussion: https://postgr.es/m/CALNJ-vT9r0DSsAOw9OXVJFxLENoVS_68kJ5x0p44atoYH+H4dg@mail.gmail.com
2022-03-03 19:03:42 -05:00
..
access Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions. 2021-10-23 18:36:42 -07:00
bootstrap Update copyrights for 2020 2020-01-01 12:21:45 -05:00
catalog Correct comment and some documentation about REPLICA_IDENTITY_INDEX 2021-12-22 16:38:42 +09:00
commands Invalidate all partitions for a partitioned table in publication. 2021-09-22 08:24:20 +05:30
common Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:58 -07:00
datatype Update copyrights for 2020 2020-01-01 12:21:45 -05:00
executor Restore the portal-level snapshot after procedure COMMIT/ROLLBACK. 2021-05-21 14:03:53 -04:00
fe_utils Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:58 -07:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit jit: Do not try to shut down LLVM state in case of LLVM triggered errors. 2021-09-13 18:26:18 -07:00
lib Fix frontend version of sh_error() in simplehash.h. 2021-10-22 16:43:38 -04:00
libpq Harden be-gssapi-common.h for headerscheck 2021-11-26 17:00:29 -03:00
mb Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
nodes Fix index-only scan plans, take 2. 2022-01-03 15:42:27 -05:00
optimizer Fix planner failure in some cases of sorting by an aggregate. 2021-04-20 11:32:02 -04:00
parser Fix failure to validate the result of select_common_type(). 2022-01-29 11:41:12 -05:00
partitioning Fix hash partition pruning with asymmetric partition sets. 2021-01-28 13:41:55 -05:00
port Get rid of artificial restriction on hash table sizes on Windows. 2021-07-25 14:02:27 -04:00
portability Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Fix race condition between shutdown and unstarted background workers. 2020-12-24 17:00:43 -05:00
regex Assume that we have <wchar.h>. 2020-02-21 14:30:47 -05:00
replication Fix limitations on what SQL commands can be issued to a walsender. 2022-01-24 15:33:34 -05:00
rewrite Calculate extraUpdatedCols in query rewriter, not parser. 2020-10-28 13:47:02 -04:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Initial pgindent and pgperltidy run for v13. 2020-05-14 13:06:50 -04:00
storage Fix bogus casting in BlockIdGetBlockNumber(). 2022-03-03 19:03:42 -05:00
tcop Restore the portal-level snapshot after procedure COMMIT/ROLLBACK. 2021-05-21 14:03:53 -04:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 21:44:43 -04:00
utils Fix ordering of XIDs in ProcArrayApplyRecoveryInfo 2022-01-27 20:16:39 +01:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h pg_attribute_no_sanitize_alignment() macro 2021-02-13 17:49:08 -05:00
fmgr.h Fix minor violations of FunctionCallInvoke usage protocol. 2020-04-21 14:23:53 -04:00
funcapi.h Avoid holding a directory FD open across assorted SRF calls. 2020-03-16 21:05:52 -04:00
getaddrinfo.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
getopt_long.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
miscadmin.h Get rid of artificial restriction on hash table sizes on Windows. 2021-07-25 14:02:27 -04:00
pg_config.h.in Suppress warning about stack_base_ptr with late-model GCC. 2022-02-17 22:45:34 -05: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_manual.h Fix concurrency issues with WAL segment recycling on Windows 2021-03-22 14:02:36 +09:00
pg_getopt.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_trace.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgstat.h Mop-up for wait event naming issues. 2020-05-16 21:00:11 -04:00
pgtar.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgtime.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
port.h Add fallback implementation for setenv() 2021-06-01 09:27:25 +09:00
postgres.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
rusagestub.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
windowapi.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00