/ Check-in [24c9cd46]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 Unified Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

342
343
344
345
346
347
348

349
350
351
352
353
354
355
....
1651
1652
1653
1654
1655
1656
1657
1658




1659
1660
1661
1662
1663
1664
1665
....
3722
3723
3724
3725
3726
3727
3728

3729
3730
3731
3732
3733
3734
3735

/*
** Value for the first field of every RtreeMatchArg object. The MATCH
** operator tests that the first field of a blob operand matches this
** value to avoid operating on invalid blobs (which could cause a segfault).
*/
#define RTREE_GEOMETRY_MAGIC 0x891245AB


/*
** An instance of this structure (in the form of a BLOB) is returned by
** the SQL functions that sqlite3_rtree_geometry_callback() and
** sqlite3_rtree_query_callback() create, and is read as the right-hand
** operand to the MATCH operator of an R-Tree.
*/
................................................................................
static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
  RtreeMatchArg *pBlob;              /* BLOB returned by geometry function */
  sqlite3_rtree_query_info *pInfo;   /* Callback information */
  int nBlob;                         /* Size of the geometry function blob */
  int nExpected;                     /* Expected size of the BLOB */

  /* Check that value is actually a blob. */
  if( sqlite3_value_type(pValue)!=SQLITE_BLOB ) return SQLITE_ERROR;





  /* Check that the blob is roughly the right size. */
  nBlob = sqlite3_value_bytes(pValue);
  if( nBlob<(int)sizeof(RtreeMatchArg) ){
    return SQLITE_ERROR;
  }

................................................................................
#endif
    }
    if( memErr ){
      sqlite3_result_error_nomem(ctx);
      rtreeMatchArgFree(pBlob);
    }else{
      sqlite3_result_blob(ctx, pBlob, nBlob, rtreeMatchArgFree);

    }
  }
}

/*
** Register a new geometry function for use with the r-tree MATCH operator.
*/







>







 







|
>
>
>
>







 







>







342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
....
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
....
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741

/*
** Value for the first field of every RtreeMatchArg object. The MATCH
** operator tests that the first field of a blob operand matches this
** value to avoid operating on invalid blobs (which could cause a segfault).
*/
#define RTREE_GEOMETRY_MAGIC 0x891245AB
#define RTREE_GEOMETRY_SUBTYPE 0x52

/*
** An instance of this structure (in the form of a BLOB) is returned by
** the SQL functions that sqlite3_rtree_geometry_callback() and
** sqlite3_rtree_query_callback() create, and is read as the right-hand
** operand to the MATCH operator of an R-Tree.
*/
................................................................................
static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
  RtreeMatchArg *pBlob;              /* BLOB returned by geometry function */
  sqlite3_rtree_query_info *pInfo;   /* Callback information */
  int nBlob;                         /* Size of the geometry function blob */
  int nExpected;                     /* Expected size of the BLOB */

  /* Check that value is actually a blob. */
  if( sqlite3_value_type(pValue)!=SQLITE_BLOB
   || sqlite3_value_subtype(pValue)!=RTREE_GEOMETRY_SUBTYPE
  ){
    return SQLITE_ERROR;
  }

  /* Check that the blob is roughly the right size. */
  nBlob = sqlite3_value_bytes(pValue);
  if( nBlob<(int)sizeof(RtreeMatchArg) ){
    return SQLITE_ERROR;
  }

................................................................................
#endif
    }
    if( memErr ){
      sqlite3_result_error_nomem(ctx);
      rtreeMatchArgFree(pBlob);
    }else{
      sqlite3_result_blob(ctx, pBlob, nBlob, rtreeMatchArgFree);
      sqlite3_result_subtype(ctx, RTREE_GEOMETRY_SUBTYPE);
    }
  }
}

/*
** Register a new geometry function for use with the r-tree MATCH operator.
*/