Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: third_party/sqlite/src/test/corruptG.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/corruptF.test ('k') | third_party/sqlite/src/test/corruptH.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/corruptG.test
diff --git a/third_party/sqlite/src/test/corruptG.test b/third_party/sqlite/src/test/corruptG.test
new file mode 100644
index 0000000000000000000000000000000000000000..af920edf41858ebadc3b81dff821ea6e8e1625d4
--- /dev/null
+++ b/third_party/sqlite/src/test/corruptG.test
@@ -0,0 +1,76 @@
+# 2013-08-01
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix corruptG
+
+# Do not use a codec for tests in this file, as the database file is
+# manipulated directly using tcl scripts (using the [hexio_write] command).
+#
+do_not_use_codec
+
+# These tests deal with corrupt database files
+#
+database_may_be_corrupt
+
+# Create a simple database with a single entry. Then corrupt the
+# header-size varint on the index payload so that it maps into a
+# negative number. Try to use the database.
+#
+
+do_execsql_test 1.1 {
+ PRAGMA page_size=512;
+ CREATE TABLE t1(a,b,c);
+ INSERT INTO t1(rowid,a,b,c) VALUES(52,'abc','xyz','123');
+ CREATE INDEX t1abc ON t1(a,b,c);
+}
+
+set idxroot [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1abc'}]
+
+# Corrupt the file
+db close
+hexio_write test.db [expr {$idxroot*512 - 15}] 888080807f
+sqlite3 db test.db
+
+# Try to use the file.
+do_test 1.2 {
+ catchsql {
+ SELECT c FROM t1 WHERE a>'abc';
+ }
+} {1 {database disk image is malformed}}
+do_test 1.3 {
+ catchsql {
+ PRAGMA integrity_check
+ }
+} {1 {database disk image is malformed}}
+do_test 1.4 {
+ catchsql {
+ SELECT c FROM t1 ORDER BY a;
+ }
+} {1 {database disk image is malformed}}
+
+# Corrupt the same file in a slightly different way. Make the record header
+# sane, but corrupt one of the serial_type value to indicate a huge payload
+# such that the payload begins in allocated space but overflows the buffer.
+#
+db close
+hexio_write test.db [expr {$idxroot*512-15}] 0513ff7f01
+sqlite3 db test.db
+
+do_test 2.1 {
+ catchsql {
+ SELECT rowid FROM t1 WHERE a='abc' and b='xyz123456789XYZ';
+ }
+} {1 {database disk image is malformed}}
+
+finish_test
« no previous file with comments | « third_party/sqlite/src/test/corruptF.test ('k') | third_party/sqlite/src/test/corruptH.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698