[postgis-tickets] [PostGIS] #3970: Undefined behaviour in lwcollection.c and lwpoly.c
PostGIS
trac at osgeo.org
Fri Jan 5 01:48:36 PST 2018
#3970: Undefined behaviour in lwcollection.c and lwpoly.c
-------------------------+---------------------------
Reporter: Algunenano | Owner: strk
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.5.0
Component: liblwgeom | Version: trunk
Resolution: | Keywords:
-------------------------+---------------------------
Comment (by Algunenano):
In `gserialized_from_lwcollection` it is written as `uint32_t`
{{{
/* Write in the number of subgeoms. */
memcpy(loc, &coll->ngeoms, sizeof(uint32_t));
loc += sizeof(uint32_t);
}}}
Then it's read as an `uint32_t` and implicitly casted to `int` in
`lwcollection_from_gserialized_buffer`:
{{{
ngeoms = gserialized_get_uint32_t(data_ptr);
collection->ngeoms = ngeoms; /* Zero => empty geometry */
}}}
I'm all about changing it to unsigned, but I'd rather use the `uint32_t`
and be sure it's 4 bytes.
Since that change (either way) requires a lot of modifications I'd rather
do it in another ticket. It was being discussed in the mailing list
(http://lists.osgeo.org/pipermail/postgis-devel/2017-December/026773.html)
but I don't think anyone is working on it.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3970#comment:2>
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