/ Check-in [24c9cd46]
Login

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

Overview
Comment:Do now allow the geometry object in the right operand of a MATCH operator in the RTREE extension to be inpersonated by a BLOB literal.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.19
Files: files | file ages | folders
SHA3-256: 24c9cd460051781f7e6417b7e205274319258f061ae1191a6c5ff5af615439c9
User & Date: drh 2017-07-27 00:27:57
Context
2017-07-31
12:07
Increase the version number to 3.19.4 check-in: b77f297d user: drh tags: branch-3.19
2017-07-28
02:02
Backport of all batch-atomic-write changes through check-in [67bad7fb9b] check-in: def55027 user: drh tags: batch-atomic-write-3.19
2017-07-27
00:27
Do now allow the geometry object in the right operand of a MATCH operator in the RTREE extension to be inpersonated by a BLOB literal. check-in: 24c9cd46 user: drh tags: branch-3.19
2017-06-08
14:26
Version 3.19.3 check-in: 0ee482a1 user: drh tags: release, version-3.19.3, branch-3.19
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

   342    342   
   343    343   /*
   344    344   ** Value for the first field of every RtreeMatchArg object. The MATCH
   345    345   ** operator tests that the first field of a blob operand matches this
   346    346   ** value to avoid operating on invalid blobs (which could cause a segfault).
   347    347   */
   348    348   #define RTREE_GEOMETRY_MAGIC 0x891245AB
          349  +#define RTREE_GEOMETRY_SUBTYPE 0x52
   349    350   
   350    351   /*
   351    352   ** An instance of this structure (in the form of a BLOB) is returned by
   352    353   ** the SQL functions that sqlite3_rtree_geometry_callback() and
   353    354   ** sqlite3_rtree_query_callback() create, and is read as the right-hand
   354    355   ** operand to the MATCH operator of an R-Tree.
   355    356   */
................................................................................
  1651   1652   static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
  1652   1653     RtreeMatchArg *pBlob;              /* BLOB returned by geometry function */
  1653   1654     sqlite3_rtree_query_info *pInfo;   /* Callback information */
  1654   1655     int nBlob;                         /* Size of the geometry function blob */
  1655   1656     int nExpected;                     /* Expected size of the BLOB */
  1656   1657   
  1657   1658     /* Check that value is actually a blob. */
  1658         -  if( sqlite3_value_type(pValue)!=SQLITE_BLOB ) return SQLITE_ERROR;
         1659  +  if( sqlite3_value_type(pValue)!=SQLITE_BLOB
         1660  +   || sqlite3_value_subtype(pValue)!=RTREE_GEOMETRY_SUBTYPE
         1661  +  ){
         1662  +    return SQLITE_ERROR;
         1663  +  }
  1659   1664   
  1660   1665     /* Check that the blob is roughly the right size. */
  1661   1666     nBlob = sqlite3_value_bytes(pValue);
  1662   1667     if( nBlob<(int)sizeof(RtreeMatchArg) ){
  1663   1668       return SQLITE_ERROR;
  1664   1669     }
  1665   1670   
................................................................................
  3722   3727   #endif
  3723   3728       }
  3724   3729       if( memErr ){
  3725   3730         sqlite3_result_error_nomem(ctx);
  3726   3731         rtreeMatchArgFree(pBlob);
  3727   3732       }else{
  3728   3733         sqlite3_result_blob(ctx, pBlob, nBlob, rtreeMatchArgFree);
         3734  +      sqlite3_result_subtype(ctx, RTREE_GEOMETRY_SUBTYPE);
  3729   3735       }
  3730   3736     }
  3731   3737   }
  3732   3738   
  3733   3739   /*
  3734   3740   ** Register a new geometry function for use with the r-tree MATCH operator.
  3735   3741   */