Re: BUG #17847: Unaligned memory access in ltree_gist

Alexander Law <exclusion@gmail.com>

From: Alexander Lakhin <exclusion@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org, Alexander Korotkov <aekorotkov@gmail.com>
Date: 2023-03-18T07:00:01Z
Lists: pgsql-bugs
16.03.2023 22:35, Tom Lane wrote:
> I wonder which other opclasses besides ltree have the same issue.

I found no other similar places: siglen is also accepted by opclasses
gist__intbig_ops, gist_hstore_ops, gist_trgm_ops, tsvector_ops,
which implementations use functions
_intbig_alloc, ghstore_alloc, gtrgm_alloc, gtsvector_alloc,
and none of them adds siglen to a pointer.
Quick testing confirms that.

(gist__ltree_ops uses ltree_gist_alloc(), but the problematic branch
"if (left) ..." not reached for gist__ltree_ops)

Best regards,
Alexander

Commits

  1. Validate ltree siglen GiST option to be int-aligned

  2. Fix custom validators call in build_local_reloptions()