[PostGIS] #6109: Out-of-bounds heap read in BOX2D_out and BOX2D_expand on 65-byte box2d under ASAN

PostGIS trac at osgeo.org
Mon Aug 3 00:29:44 PDT 2026


#6109: Out-of-bounds heap read in BOX2D_out and BOX2D_expand on 65-byte box2d
under ASAN
----------------------+---------------------------
  Reporter:  dtighe   |      Owner:  pramsey
      Type:  defect   |     Status:  new
  Priority:  medium   |  Milestone:  PostGIS 3.6.5
 Component:  postgis  |    Version:  3.6.x
Resolution:           |   Keywords:
----------------------+---------------------------
Comment (by Regina Obe <lr@…>):

 In [changeset:"8227f9b542e6c3fcd8c05b80e1126df6ae621daa/git"
 8227f9b5/git]:
 {{{#!CommitTicketReference repository="git"
 revision="8227f9b542e6c3fcd8c05b80e1126df6ae621daa"
 Fix out-of-bounds read in BOX2D_out and BOX2D_expand

 box2d is declared with internallength=65 (postgis.sql.in), which is 7
 bytes short of sizeof(GBOX) (72). Copying the full GBOX struct (72 bytes)
 via
 memcpy in BOX2D_out and BOX2D_expand causes a 7-byte out-of-bounds heap
 read under ASAN. Reference: #6109

 This change fixes this by copying only up to offsetof(GBOX, zmin), which
 contains all
 2D box fields (xmin, xmax, ymin, ymax, flags, SRID) within the 65-byte
 payload.
 This also memzeros the target buffer out as a defensive measure where it
 wasn't
 done previously.

 Add regression test regress/core/box2d.sql (these fail under ASAN today).

 References #6109 for PostGIS 3.6.5
 Closes https://gitea.osgeo.org/postgis/postgis/pulls/628 for PostGIS 3.6.5
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6109#comment:4>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list