Commit Graph

19960 Commits

Author SHA1 Message Date
dan 29e9af8848 Change the way a comparison used to detect corrupt databases in fts3 is done
to avoid potential pointer overflow in 32-bit builds.

FossilOrigin-Name: 95a9a39ff784b960b62dd6298e722a620ba3f9c8b76839a49bbef35d7bc84a8e
2018-12-24 13:34:36 +00:00
drh 85bcdce270 Split the code generation for the RHS of IN operators and for SELECT and
EXISTS expressions into two separate subroutines, because there is now little
commonality between those to functions. This is intended to help make the
code easier to read and maintain.

FossilOrigin-Name: 2b6494b1509f0d0189f98aa34c990eee99c775ff57826e79b2c5b0a12b4c97ad
2018-12-23 21:27:29 +00:00
dan 8d69a58119 Improve the coverage of wal.c provided by the "coverage-wal" test permutation.
FossilOrigin-Name: 6231485114eb07b258cd0e6e163ca05f7e9cf5664e071808fcb1329b33e4c4f5
2018-12-22 20:32:28 +00:00
dan 6a509d56bc Catch another case of a corrupted structure record in fts5.
FossilOrigin-Name: fb17fea4b9779fbd3adb6ff9500da83a6ca4fa7cba379aa70074e4328814a7f2
2018-12-22 19:54:17 +00:00
dan 862faf28bb Change a faulty assert() in fts5 that could fail on a corrupt db to an if() statement.
FossilOrigin-Name: 1daaba9fb46706af8ed0669a661c304df999a69cf639d29d93208f422c515d8c
2018-12-22 19:09:46 +00:00
drh 11d07ed643 Fix one more instance of excess whitespace in test result strings.
FossilOrigin-Name: c064964deb0b7220ba784f07ca9c603680f3c8bb936d56ab4eca1962beac1359
2018-12-22 16:14:45 +00:00
drh 3a07548b0d Remove unnecessary whitespace from testcase result strings.
FossilOrigin-Name: ad70f03ceda74163903d247a975666b35fae722a27c48dd3efd31c1164b5627e
2018-12-22 15:46:23 +00:00
dan b63d6070ee Fix an assert() in fts5 that could fail with a corrupt database.
FossilOrigin-Name: 83935b950619855fb3bf05486091804ac2a61fb993c6ec826c89f943264fabc3
2018-12-22 15:21:31 +00:00
dan 634ac14488 Fix a "jump or move depends on uninitialized value" valgrind error that could
occur in fts5 when dealing with a corrupt database.

FossilOrigin-Name: 3518c09b944c92974939b1de244401afd34de5d9aa75050e5ad55581a94e1e71
2018-12-22 13:34:52 +00:00
dan fb11bf8c91 Avoid a left-shift of a negative value (undefined behaviour) when dealing with a corrupt database in
fts3.

FossilOrigin-Name: b851d12474035328df8354c7da8d81bc78833c8c704153f9f573c19b47a8487e
2018-12-22 09:39:06 +00:00
dan 583521fbb0 Fix cut-and-paste error in test file fts4umlaut.test.
FossilOrigin-Name: cad5da1bf5f65ad87d97b72e9a84081fde455ba4085e79943fdf6c0144b1ef83
2018-12-22 07:16:42 +00:00
drh 9bfb079409 Do not all REPLACE to sneak a NULL value into a NOT NULL column. Detect that
situation and ABORT instead.  Fix for ticket [e6f1f2e34dceeb1ed61531c7e98].

FossilOrigin-Name: db8d1d12f5c1673404b2afb5426d5ea3afe3b69d01f8f2bc47ffdf70684fdf24
2018-12-22 01:13:25 +00:00
drh a42325e731 The OP_Eq and OP_Ne operators have a special P5 value SQLITE_NOTNULL that
asserts that the values are not null.  Except that is not always true for
a corrupt database.  Adjust the assert() and add a testcase() to make this
point clear.

FossilOrigin-Name: a3fdb2c78d23b94d68dc08126b22d03152ac6068496a42402cdfb336cd4a7e33
2018-12-22 00:34:30 +00:00
drh a86c8ce940 Update the dbtotxt utility program so that it does not output characters that
are special to TCL, thus making the output of dbtotxt easier to insert into
test scripts.

FossilOrigin-Name: 48438bb35b48955a1df83ef90f0ef6c9cfed0b16d2e938f36d74ad9d53b4b5b4
2018-12-21 22:11:37 +00:00
drh cde4bf8ba7 Improved detection of shadow table corruption in RTREE.
FossilOrigin-Name: b39bf4356e6bcf1d8442721d6cbbfe06caba01325104fb469da8fe69e1f623a2
2018-12-21 22:08:59 +00:00
dan 6ba81ef1bf Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for
preparing statements that are not allowed to use any virtual tables.
Use this to prevent circular references in triggers on virtual table
shadow tables from causing resource leaks.

FossilOrigin-Name: da587d18575ac06a6b65fec1d106f0cc65bc10f493ca6c6b99117a2162d15a52
2018-12-21 20:18:06 +00:00
dan deb201b866 Use SQLITE_PREPARE_NO_VTAB in rtree as well.
FossilOrigin-Name: 82a2ae7132964eab0dfad9a8314a399ffd3b72366b35e1767df6452125dd1d80
2018-12-21 19:55:20 +00:00
dan 38e3853240 Add tests for the use of SQLITE_PREPARE_NO_VTAB in fts5.
FossilOrigin-Name: 1999612010e310fc2430d1f00076f69fade0c66d202771dbb0f3d5597ac0a03c
2018-12-21 19:30:18 +00:00
dan 1ea0443c2d Add new sqlite3_prepare_v3() flag SQLITE_PREPARE_NO_VTAB, for preparing
statements that are not allowed to use any virtual tables. Use this to prevent
circular references in triggers on virtual table shadow tables from causing
resource leaks.

FossilOrigin-Name: 25666e3d03950caf753295cdb55df162e07dbcf6840b05875c6e0b127c469ecb
2018-12-21 19:29:11 +00:00
drh afdc9e23fc In FTS3, avoid calling memcpy() with a NULL source pointer, even if the
transfer amount is zero bytes.

FossilOrigin-Name: 1abb83d29a06308c96bea379311b390240347c5f81824749348d18ad75840c96
2018-12-21 18:51:27 +00:00
drh 8bcc686614 The fts4umlaut.test module requires FTS5, so do not try to run it without that
module.

FossilOrigin-Name: dee3ae900129d39d69aff3ec6187376be100803ee6170bbf39529f37b4253260
2018-12-21 18:50:43 +00:00
drh 687e20079c Fix the node hash function in RTREE to ensure that it always returns a
non-negative value.

FossilOrigin-Name: 0bf4c70a6849da74797e8616a4f3730492ad02882ae67a0fe0f3b3cc3f1043b4
2018-12-21 18:17:35 +00:00
drh 273e01b4c6 Fix a potential NULL-pointer deference in RTREE due to corrupt shadow tables.
FossilOrigin-Name: 1fdd3604eef880414682e9e6f74d714520fe1c63f267ec4da752d2dc1da6bf72
2018-12-21 17:51:30 +00:00
drh fb077f3c50 Prevent an infinite loop in rtree that can result from a corrupt shadow table.
FossilOrigin-Name: 085667180b230587abb82abfdd14da8859e23620994d5cf152236b64c756dd04
2018-12-21 16:53:58 +00:00
drh 1429eca9d4 Fix the RTree extension so that it correctly ignores constraints that it
does not understand, even if they are against a dimension column.

FossilOrigin-Name: ed8531e57596f0d5911a05a26d5ae61e1eccfaadee49219d7f6e212cac288238
2018-12-21 15:13:49 +00:00
drh 558ef11ad9 In RTREE, turn an assert() into an if() because the condition can
sometimes be false when dealing with a corrupt database.

FossilOrigin-Name: 99bce4358beb5dbaba47048ee2eec5c376dcd86e5b1462238a37ea4c5f3d77db
2018-12-21 13:30:34 +00:00
dan e1e28ec35c Remove an assert() that could fail on a corrupt db from fts3_write.c.
FossilOrigin-Name: 4cdcda408a4edcd2845584ddef64f0efdd2b4cc030afbc05fc2b8b555c69d3f6
2018-12-21 11:53:43 +00:00
drh 94f4f873b2 Do not set the Cursor.seekOp test variable in the OP_NotExists opcode.
This is a change to test logic only and does not affect deliverable builds.

FossilOrigin-Name: 98f343077887c4d3fc2ca3bbc7f20c80ec37b0e521d70af9c986ab80bb2c7903
2018-12-20 22:08:32 +00:00
dan e46201e264 Fix a bug in the code that detects self-referencing rows as part of foreign
key processing. Fix for [50d2a6c2].

FossilOrigin-Name: 16fff05347f42fe9fa0f3150290b98b59a9bb921e49dc07ca397aa1de7a7e17d
2018-12-20 17:32:33 +00:00
dan 16dd3985f0 Fix a segfault caused by using the RAISE function incorrectly (library now
returns an error instead of crashing).

FossilOrigin-Name: ddf06db702761d663119d508afe21d7dfebe963d576bb42fc2f2024205ab86f8
2018-12-20 15:04:38 +00:00
dan 397a78d4a1 In defensive mode, do not allow shadow tables to be renamed using ALTER TABLE.
FossilOrigin-Name: 23e200da5cfbde0798e67cd9e016e4a1cd73b67981e1af841493fcd123d8f547
2018-12-18 20:31:14 +00:00
mistachkin 99490934ae Move variable declaration to address compilation issue (C89).
FossilOrigin-Name: d64f248da3ce7762fe2c17fbc83f7bea9ffca73723bb3ad0982a85320839da90
2018-12-17 22:19:57 +00:00
dan bef06d2637 Fix errors in comments in fts5.h.
FossilOrigin-Name: 4002790d9418289f3e090c694f651a89d8f523119c8ce2f396999b0387148241
2018-12-15 07:12:34 +00:00
drh 3c2db5def6 Fix harmless compiler warnings.
FossilOrigin-Name: 27221c69901d2b4546167639c4a3c8f54b2e18820f1346870fa26b7c919027db
2018-12-14 18:11:02 +00:00
drh ae10474125 Fix possible integer overflow while running PRAGMA integrity_check on a
database file with a badly corrupted freelist.

FossilOrigin-Name: 395599116d801324f0763e59bc5e2fc8622aa5b7572e0c1c9a982efbb3cc8280
2018-12-14 17:57:01 +00:00
drh d7a5e49840 Back out the expansion of the temporary buffer size from
[32754ca6f86da816] and replace it with an explicit test for buffer
overreads.

FossilOrigin-Name: 8ba3d9f38090c4bbbcffba1930e5c26f69ff61f49b72a4a5a59253d37341380f
2018-12-14 16:20:54 +00:00
drh e7acce66b2 Avoid a buffer overread in ptrmapPutOvflPtr() that can occurs in a
corrupt database file that has large entries and uses autovacuum.

FossilOrigin-Name: f8b781cf41800e9f61a1c5376404a97e76a2bbbcaa17396d42be62f731363947
2018-12-14 16:00:38 +00:00
drh fa94d492c8 Fix a harmless compiler warning in Sessions.
FossilOrigin-Name: fc9791ea987352e3e1322fbb7f833c23b402432af8249f9d397c6f7456788637
2018-12-14 13:47:17 +00:00
drh d6401e869b Expand the size of the temporary page used during btree rebalancing by a
few bytes, to avoid problems with small buffer overreads that can occur
on corrupted database files.

FossilOrigin-Name: 32754ca6f86da8165e274f98f35fc3df3aebd273e9da08387e2d0c3c89abda0f
2018-12-14 13:35:48 +00:00
dan fffaf23013 When saving the position of a cursor at the b-tree layer, allocate a few extra
bytes at the end of the buffer used to save the key. Otherwise, if the key is
corrupt, the code that restores the cursor position may overread the buffer by a
little.

FossilOrigin-Name: 160b1e31c0f27257c06c2987af9ec3a64abfacb2150325b72e8ccd3d217b5baa
2018-12-14 13:18:35 +00:00
drh 5a1ce4369f Fix a problem with bytecode generation when a query involves two or more
indexes on expressions connected by OR.
Ticket [d96eba87698a428c1ddd0790ea04]

FossilOrigin-Name: 7e4ed8b5c2047b69bbb037497111e56e465a4d9f8afca3b337f9ac744471dc4a
2018-12-14 11:16:52 +00:00
dan 7525b87b6c Posible fix for [d96eba87].
FossilOrigin-Name: 89a25abfcd069aebdf817890e5c27f46de3000fb858ae01029e4528f9d677567
2018-12-14 08:40:11 +00:00
drh d8cc8b30b4 Fix a bug in fuzzcheck that cause it to overlook a pointer-map bug that was
trigger by the fuzzcheck test data, and also fix the pointer-map bug.

FossilOrigin-Name: cc42dd15100db28a9796254f69a4e367ea5eae29f546be055017cf3e12aa66ba
2018-12-14 03:16:17 +00:00
drh 203b1ea0f5 Detect when an attempt is made to write to a pointer map page that is also
being used as a btree page and report corruption.

FossilOrigin-Name: 3036fd71ac7063359b04a0ed54a6c63a380eb7ff75cd29ed27486d4259066aee
2018-12-14 03:14:18 +00:00
drh e45985b595 Fix a bug in the custom in-memory VFS used by fuzzcheck. This bug masks
other bugs that should have caused some existing fuzzdata7.db entries to
fail, and so this fix is initially on a branch until those other bugs can
be repaired.

FossilOrigin-Name: e0994e99955cf11f23dba029b5ed7f150f467887558848d5f03510e2fb5855f9
2018-12-14 02:29:56 +00:00
drh f354e77f3d Fix the dbtotxt decoder in the CLI so that it ignores excess bytes.
FossilOrigin-Name: 18740bd448887d618fafee0b5a7c004aa2f2632244f7d29e2428772baa36b828
2018-12-13 22:58:52 +00:00
drh 6301c43f23 dbfuzz2 found a NEVER() that is sometimes true.
FossilOrigin-Name: 1201615cbbd3070158ea5fab3d2c8c95f41b25d6da096a44cb9257a7b7405efc
2018-12-13 21:52:18 +00:00
drh 8061ad8abd Add extra tests for database corruption inside the defragmentPage() routine,
as dbfuzz2 has found ways for corruption to leak into that point.  Add test
cases in fuzzdata7.db.

FossilOrigin-Name: 997b65117f8c12dba5fb85434fde9765cdb0d2a49cc3e31979abba3e21350086
2018-12-13 21:11:22 +00:00
drh 1641f11f4c Fix a problem in sqlite3BtreeDelete() in which deleting an entry from a
corrupt database can leave a btree page with zero cells.

FossilOrigin-Name: 682053d1e603c21b8085c39db618a39b23ec8d2c4d822fd19634db0e03038ea2
2018-12-13 21:05:45 +00:00
drh f7e74904cc Add the "decode_hexdb" TCL command to testfixture. Add the dbfuzz001.test
module to demonstration how to use decode_hexdb to deserialize a dbtotxt
database description for use in a corruption test.

FossilOrigin-Name: 1f583c53f3b7318c69f6e235934d97ef9493278feeab0837217076d7d071c35b
2018-12-13 20:49:43 +00:00