Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType.
Noah Misch <noah@leadboat.com>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/arrayfuncs.c | modified | +1 −1 |
| src/include/utils/arrayaccess.h | modified | +2 −2 |
| src/include/utils/array.h | modified | +13 −6 |
| src/include/utils/expandeddatum.h | modified | +1 −1 |
Discussion
- BUG #15121: Multiple UBSAN errors 20 messages · 2018-03-18 → 2019-06-30