]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Prevent code in test6.c from reading the 512 byte locking region (the PENDING_BYTE...
authordanielk1977 <danielk1977@noemail.net>
Tue, 10 Feb 2009 14:28:57 +0000 (14:28 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 10 Feb 2009 14:28:57 +0000 (14:28 +0000)
FossilOrigin-Name: 2a6a43169220fab5a15a786e2a464b90cb893179

manifest
manifest.uuid
src/test6.c

index 03cd42727b42ee8eb6b0d89fc4008c93c8f5976a..dc3b2caab752b6bb5dcf7cc0751180ff80d151b0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Create\slinks\sfrom\sbackup\sAPI\sdocumentation\sto\sthe\sbackup\sapplication\snote.\nComment\schanges\sonly\s-\sno\schanges\sto\scode.\s(CVS\s6275)
-D 2009-02-10T13:41:42
+C Prevent\scode\sin\stest6.c\sfrom\sreading\sthe\s512\sbyte\slocking\sregion\s(the\sPENDING_BYTE\spage)\sof\sa\sdatabase\sfile.\sDoing\sso\striggers\san\sassert\sfailure\sin\sos_unix.c.\s(CVS\s6276)
+D 2009-02-10T14:28:57
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in c7a5a30fb6852bd7839b1024e1661da8549878ee
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -169,7 +169,7 @@ F src/test2.c 71c22e2974f8094fe0fd1eba8f27872dde9b2a39
 F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14
 F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c
 F src/test5.c 162a1cea2105a2c460a3f39fa6919617b562a288
-F src/test6.c 10025acfb5d978abc08b3ddbba8b2ce4dd6ca0c1
+F src/test6.c 86d7918ccc2ff92ceb71cb59c6a078105f8885d2
 F src/test7.c b94e68c2236de76889d82b8d7d8e00ad6a4d80b1
 F src/test8.c 3637439424d0d21ff2dcf9b015c30fcc1e7bcb24
 F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237
@@ -701,7 +701,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P f6590dac4612d0d05105fa820e8fcb80b5907a40
-R d5f0d03566bc83fb0de348a58289fd37
-U drh
-Z f36b4865f8619c82038b33c67badf672
+P 85de23fb4e63e5c71480c4c34efec331e774d7fb
+R fc9b62f8eb9d21f86b7120b417d5c337
+U danielk1977
+Z 7d5d948a1e8d6b7ef2fab1a57b236f9f
index a0ded13a0e4d5da0982f54d24e724ec7a76f9065..3a1fc0c83f90f127562e1b5df46774ef92447408 100644 (file)
@@ -1 +1 @@
-85de23fb4e63e5c71480c4c34efec331e774d7fb
\ No newline at end of file
+2a6a43169220fab5a15a786e2a464b90cb893179
\ No newline at end of file
index 6fc55b7ea63cae6db14f2e0d6349dbbe45516a15..cf6c2fcbde6e1f8be81ae5b081cc934e5e52a005 100644 (file)
@@ -14,7 +14,7 @@
 ** the effect on the database file of an OS crash or power failure.  This
 ** is used to test the ability of SQLite to recover from those situations.
 **
-** $Id: test6.c,v 1.41 2008/12/20 18:33:59 danielk1977 Exp $
+** $Id: test6.c,v 1.42 2009/02/10 14:28:57 danielk1977 Exp $
 */
 #if SQLITE_TEST          /* This file is used for testing only */
 #include "sqliteInt.h"
@@ -564,8 +564,23 @@ static int cfOpen(
     pWrapper->nData = (4096 + pWrapper->iSize);
     pWrapper->zData = crash_malloc(pWrapper->nData);
     if( pWrapper->zData ){
+      /* os_unix.c contains an assert() that fails if the caller attempts
+      ** to read data from the 512-byte locking region of a file opened
+      ** with the SQLITE_OPEN_MAIN_DB flag. This region of a database file
+      ** never contains valid data anyhow. So avoid doing such a read here.
+      */
+      const int isDb = (flags&SQLITE_OPEN_MAIN_DB);
+      i64 iChunk = pWrapper->iSize;
+      if( iChunk>PENDING_BYTE && isDb ){
+        iChunk = PENDING_BYTE;
+      }
       memset(pWrapper->zData, 0, pWrapper->nData);
-      rc = sqlite3OsRead(pReal, pWrapper->zData, pWrapper->iSize, 0); 
+      rc = sqlite3OsRead(pReal, pWrapper->zData, iChunk, 0); 
+      if( SQLITE_OK==rc && pWrapper->iSize>(PENDING_BYTE+512) && isDb ){
+        i64 iOff = PENDING_BYTE+512;
+        iChunk = pWrapper->iSize - iOff;
+        rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], iChunk, iOff);
+      }
     }else{
       rc = SQLITE_NOMEM;
     }