Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mysql-test/main/gis.result
Original file line number Diff line number Diff line change
Expand Up @@ -5565,3 +5565,10 @@ x
020000000101000000000000000000F03F000000000000F03F
drop table t1;
# End of 10.6 tests
#
# MDEV-35595 UBSAN: runtime error: load of value 3 for 'wkbByteOrder'
#
SELECT ST_GEOMFROMWKB (0x01060000000100000003020000000100000000000000000000000000000000000000) as g;
g
NULL
# End of 10.11 tests
8 changes: 8 additions & 0 deletions mysql-test/main/gis.test
Original file line number Diff line number Diff line change
Expand Up @@ -3542,3 +3542,11 @@ select hex(st_geomfromgeojson('{"type":"Point","coordinates":[1,1]}', 1, a)) x f
drop table t1;

--echo # End of 10.6 tests

--echo #
--echo # MDEV-35595 UBSAN: runtime error: load of value 3 for 'wkbByteOrder'
--echo #

SELECT ST_GEOMFROMWKB (0x01060000000100000003020000000100000000000000000000000000000000000000) as g;

--echo # End of 10.11 tests
12 changes: 7 additions & 5 deletions sql/spatial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer,
uint32 geom_type;
Geometry *geom;

if (len < WKB_HEADER_SIZE)
if (len < WKB_HEADER_SIZE || wkb[0] > wkb_ndr)
return NULL;
geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]);
if (!(geom= create_by_typeid(buffer, (int) geom_type)) ||
Expand Down Expand Up @@ -2898,8 +2898,9 @@ uint Gis_multi_polygon::init_from_wkb(const char *wkb, uint len,
Gis_polygon p;
int p_len;

if (len < WKB_HEADER_SIZE ||
res->reserve(WKB_HEADER_SIZE, 512))
if (len < WKB_HEADER_SIZE
|| wkb[0] > wkb_ndr
|| res->reserve(WKB_HEADER_SIZE, 512))
return 0;
res->q_append((char) wkb_ndr);
res->q_append((uint32) wkb_polygon);
Expand Down Expand Up @@ -3416,8 +3417,9 @@ uint Gis_geometry_collection::init_from_wkb(const char *wkb, uint len,
int g_len;
uint32 wkb_type;

if (len < WKB_HEADER_SIZE ||
res->reserve(WKB_HEADER_SIZE, 512))
if (len < WKB_HEADER_SIZE
|| wkb[0] > wkb_ndr
|| res->reserve(WKB_HEADER_SIZE, 512))
return 0;

res->q_append((char) wkb_ndr);
Expand Down