/ Check-in [c5256b59]
Login

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

Overview
Comment:Avoid 32-bit overflow when calculating the byte offset of an overflow page in SQLITE_DIRECT_OVERFLOW_READ code. Fix for [ac0ff496b7].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c5256b59ad70104c1e181b9f49d1d712cf4cc9f6
User & Date: dan 2011-12-21 17:00:16
References
2011-12-21
23:38
Cherry-pick the SQLITE_DIRECT_OVERFLOW_READ fix for ticket [ac0ff496b7e] of changes [c5256b59ad] and [c723e3e18a] into the nx-devkit branch. check-in: 42f31f19 user: drh tags: nx-devkit
Context
2011-12-21
18:04
Fix other problems where 32-bit integer overflow may cause a problem. Two that require an improbably large sub-journal and two in test harness code. Ticket [ac0ff496b7e2] check-in: c723e3e1 user: dan tags: trunk
17:00
Avoid 32-bit overflow when calculating the byte offset of an overflow page in SQLITE_DIRECT_OVERFLOW_READ code. Fix for [ac0ff496b7]. check-in: c5256b59 user: dan tags: trunk
2011-12-20
13:13
Assert that the isCommit parameter to sqlite3WalFrames() is zero if and only if the nTruncate parameter is zero. check-in: 979daf92 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  3975   3975            && pBt->inTransaction==TRANS_READ                     /* (4) */
  3976   3976            && (fd = sqlite3PagerFile(pBt->pPager))->pMethods     /* (3) */
  3977   3977            && pBt->pPage1->aData[19]==0x01                       /* (5) */
  3978   3978           ){
  3979   3979             u8 aSave[4];
  3980   3980             u8 *aWrite = &pBuf[-4];
  3981   3981             memcpy(aSave, aWrite, 4);
  3982         -          rc = sqlite3OsRead(fd, aWrite, a+4, pBt->pageSize * (nextPage-1));
         3982  +          rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
  3983   3983             nextPage = get4byte(aWrite);
  3984   3984             memcpy(aWrite, aSave, 4);
  3985   3985           }else
  3986   3986   #endif
  3987   3987   
  3988   3988           {
  3989   3989             DbPage *pDbPage;

Added test/bigfile2.test.

            1  +# 2011 December 20
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script testing the ability of SQLite to handle database
           13  +# files larger than 4GB.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +set testprefix bigfile2
           19  +
           20  +# Create a small database.
           21  +#
           22  +do_execsql_test 1.1 {
           23  +  CREATE TABLE t1(a, b);
           24  +  INSERT INTO t1 VALUES(1, 2);
           25  +}
           26  +
           27  +# Pad the file out to 4GB in size. Then clear the file-size field in the
           28  +# db header. This will cause SQLite to assume that the first 4GB of pages
           29  +# are actually in use and new pages will be appended to the file.
           30  +#
           31  +db close
           32  +if {[catch {fake_big_file 4096 [pwd]/test.db} msg]} {
           33  +  puts "**** Unable to create a file larger than 4096 MB. *****"
           34  +  finish_test
           35  +  return
           36  +}
           37  +hexio_write test.db 28 00000000
           38  +
           39  +do_test 1.2 {
           40  +  file size test.db
           41  +} [expr 14 + 4096 * (1<<20)]
           42  +
           43  +# Now insert a large row. The overflow pages will be located past the 4GB
           44  +# boundary. Then, after opening and closing the database, test that the row
           45  +# can be read back in. 
           46  +# 
           47  +set str [string repeat k 30000]
           48  +do_test 1.3 {
           49  +  sqlite3 db test.db
           50  +  execsql { INSERT INTO t1 VALUES(3, $str) }
           51  +  db close
           52  +  sqlite3 db test.db
           53  +  db one { SELECT b FROM t1 WHERE a = 3 }
           54  +} $str
           55  +
           56  +db close
           57  +file delete test.db
           58  +
           59  +finish_test