1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
# Description: fix denial of service via PolyFromWKB() function and improper data.
3
# Origin: upstream, http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/revision/3452.1.42
4
# Bug: http://bugs.mysql.com/bug.php?id=51875
7
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mysql-dfsg-5.1-5.1.41~/mysql-test/r/gis.result mysql-dfsg-5.1-5.1.41/mysql-test/r/gis.result
8
--- mysql-dfsg-5.1-5.1.41~/mysql-test/r/gis.result 2009-11-04 14:01:11.000000000 -0500
9
+++ mysql-dfsg-5.1-5.1.41/mysql-test/r/gis.result 2010-11-08 13:03:38.000000000 -0500
10
@@ -1044,4 +1044,11 @@
11
SELECT Polygon(12345123,'');
15
+# BUG#51875: crash when loading data into geometry function polyfromwkb
17
+SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
18
+SET @a=POLYFROMWKB(@a);
19
+SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
20
+SET @a=POLYFROMWKB(@a);
22
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mysql-dfsg-5.1-5.1.41~/mysql-test/t/gis.test mysql-dfsg-5.1-5.1.41/mysql-test/t/gis.test
23
--- mysql-dfsg-5.1-5.1.41~/mysql-test/t/gis.test 2009-11-04 14:00:43.000000000 -0500
24
+++ mysql-dfsg-5.1-5.1.41/mysql-test/t/gis.test 2010-11-08 13:03:38.000000000 -0500
26
SELECT Polygon(1234512,'');
27
SELECT Polygon(12345123,'');
31
+--echo # BUG#51875: crash when loading data into geometry function polyfromwkb
33
+SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
34
+SET @a=POLYFROMWKB(@a);
35
+SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440;
36
+SET @a=POLYFROMWKB(@a);
39
--echo End of 5.1 tests
40
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' mysql-dfsg-5.1-5.1.41~/sql/spatial.cc mysql-dfsg-5.1-5.1.41/sql/spatial.cc
41
--- mysql-dfsg-5.1-5.1.41~/sql/spatial.cc 2009-11-04 13:31:03.000000000 -0500
42
+++ mysql-dfsg-5.1-5.1.41/sql/spatial.cc 2010-11-08 13:03:38.000000000 -0500
44
n_points= wkb_get_uint(wkb, bo);
45
proper_length= 4 + n_points * POINT_DATA_SIZE;
47
- if (len < proper_length || res->reserve(proper_length))
48
+ if (!n_points || len < proper_length || res->reserve(proper_length))
51
res->q_append(n_points);
56
- n_linear_rings= wkb_get_uint(wkb, bo);
57
+ if (!(n_linear_rings= wkb_get_uint(wkb, bo)))
60
if (res->reserve(4, 512))