pgsql: Don't read fields of a misaligned ExpandedObjectHeader or AnyArr

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't read fields of a misaligned ExpandedObjectHeader or AnyArr
Date: 2019-07-01 00:36:19
Message-ID: E1hhkIt-0004A3-CD@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType.

UBSan complains about this. Instead, cast to a suitable type requiring
only 4-byte alignment. DatumGetAnyArrayP() already assumes one can cast
between AnyArrayType and ArrayType, so this doesn't introduce a new
assumption. Back-patch to 9.5, where AnyArrayType was introduced.

Reviewed by Tom Lane.

Discussion: https://postgr.es/m/20190629210334.GA1244217@rfd.leadboat.com

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b664b187d7ea6546ef4e0f32167a93c6a74dca08

Modified Files
--------------
src/backend/utils/adt/arrayfuncs.c | 2 +-
src/include/utils/array.h | 19 +++++++++++++------
src/include/utils/arrayaccess.h | 4 ++--
src/include/utils/expandeddatum.h | 2 +-
4 files changed, 17 insertions(+), 10 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2019-07-01 01:02:02 pgsql: Fix many typos and inconsistencies
Previous Message Andrew Gierth 2019-06-30 22:55:07 pgsql: Repair logic for reordering grouping sets optimization.