drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
693 stars 90 forks source link

Timestamp constructor may trigger segmentation fault #625

Open mmd-osm opened 3 years ago

mmd-osm commented 3 years ago

One of the Timestamp constructors reads 8 bytes from void*, although a Timestamp has only 5 bytes. I've seen some issues in connection with attic data, where the timestamp was at the very end of an allocated memory block, and reading 8 bytes instead of the permitted 5 remaining bytes triggered a segmentation fault. g++ address sanitizer also complains about undefined behavior due to a heap-buffer-overflow. Proposed fix would be to read exactly 5 bytes instead of 8.

timestamp

A similar issue needs to be fixed in the Attic constructor as well:

timestamp2