]> granicus.if.org Git - postgresql/commit
Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType.
authorNoah Misch <noah@leadboat.com>
Mon, 1 Jul 2019 00:34:17 +0000 (17:34 -0700)
committerNoah Misch <noah@leadboat.com>
Mon, 1 Jul 2019 00:34:21 +0000 (17:34 -0700)
commitb664b187d7ea6546ef4e0f32167a93c6a74dca08
tree676358160351aabbebaf9b2fe43a9d7ee4361d67
parent4a36c77156f2ff6e07a349cddc65e5dd21abc1a8
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
src/backend/utils/adt/arrayfuncs.c
src/include/utils/array.h
src/include/utils/arrayaccess.h
src/include/utils/expandeddatum.h