pgsql: Don't read fields of a misaligned ExpandedObjectHeader orAnyArr - Mailing list pgsql-committers

From Noah Misch
Subject pgsql: Don't read fields of a misaligned ExpandedObjectHeader orAnyArr
Date
Msg-id E1hhkIt-00049y-Bv@gemulon.postgresql.org
Whole thread Raw
List 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
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4b85f20f948d885875a1e1b89979e627b86e6e64

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(-)


pgsql-committers by date:

Previous
From: Andrew Gierth
Date:
Subject: pgsql: Repair logic for reordering grouping sets optimization.
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix many typos and inconsistencies