/ Check-in [b352f159]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid integer overflow when computing the array of a bounding box with the rtree_i32 virtual table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b352f1590d20a574b0681e011ececcf4f41fa5b157503d330e03939404aca0e9
User & Date: drh 2019-01-18 18:52:17
Context
2019-01-18
19:26
Fix problems causing undefined left-shift operations in the fts3 snippet() function. check-in: b90dbaed user: dan tags: trunk
18:52
Avoid integer overflow when computing the array of a bounding box with the rtree_i32 virtual table. check-in: b352f159 user: drh tags: trunk
17:53
Handle oversize floating point values carefully when converting to integers for the '%' binary operator. check-in: 048add13 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

  1995   1995         case 2:  area *= p->aCoord[3].f - p->aCoord[2].f;
  1996   1996         default: area *= p->aCoord[1].f - p->aCoord[0].f;
  1997   1997       }
  1998   1998     }else
  1999   1999   #endif
  2000   2000     {
  2001   2001       switch( pRtree->nDim ){
  2002         -      case 5:  area  = p->aCoord[9].i - p->aCoord[8].i;
  2003         -      case 4:  area *= p->aCoord[7].i - p->aCoord[6].i;
  2004         -      case 3:  area *= p->aCoord[5].i - p->aCoord[4].i;
  2005         -      case 2:  area *= p->aCoord[3].i - p->aCoord[2].i;
  2006         -      default: area *= p->aCoord[1].i - p->aCoord[0].i;
         2002  +      case 5:  area  = (i64)p->aCoord[9].i - (i64)p->aCoord[8].i;
         2003  +      case 4:  area *= (i64)p->aCoord[7].i - (i64)p->aCoord[6].i;
         2004  +      case 3:  area *= (i64)p->aCoord[5].i - (i64)p->aCoord[4].i;
         2005  +      case 2:  area *= (i64)p->aCoord[3].i - (i64)p->aCoord[2].i;
         2006  +      default: area *= (i64)p->aCoord[1].i - (i64)p->aCoord[0].i;
  2007   2007       }
  2008   2008     }
  2009   2009     return area;
  2010   2010   }
  2011   2011   
  2012   2012   /*
  2013   2013   ** Return the margin length of cell p. The margin length is the sum