]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Ensure that the value returned by xSectorSize() is reasonable (currently defined...
authordan <dan@noemail.net>
Mon, 1 Oct 2012 06:50:55 +0000 (06:50 +0000)
committerdan <dan@noemail.net>
Mon, 1 Oct 2012 06:50:55 +0000 (06:50 +0000)
FossilOrigin-Name: 6b4ff83bff07d427af585c9fd03be90abf2fc82f

manifest
manifest.uuid
src/pager.c
src/pager.h
src/wal.c

index 9f30517df5b7a5a4f7f31b182d79df71d6528ee3..07b54cc849f6b04a6ccd3c3e078df5d031b30e1d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Improved\sORDER\sBY\soptimization\swhen\souter\sloops\sof\sa\sjoin\sreturn\sa\ssingle\srow.
-D 2012-09-29T19:10:29.355
+C Ensure\sthat\sthe\svalue\sreturned\sby\sxSectorSize()\sis\sreasonable\s(currently\sdefined\sas\sbetween\s2^5\sand\s2^16\sbytes)\sbefore\susing\sit\sto\scalculate\sthe\samount\sof\spadding\sto\sadd\sto\sa\swal\sfile.
+D 2012-10-01T06:50:55.576
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -162,8 +162,8 @@ F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_unix.c 69b2fe66316524eebf5f1ce85c1fdfe2952307e9
 F src/os_win.c 90c7a1fe2698867555ba4266f5bd436c85d0d1dc
-F src/pager.c 9c59818c480261c1c5a4772532e0df92a27745a1
-F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5
+F src/pager.c 9f5f2823594cc2848e151510f726af02896485b5
+F src/pager.h bdbc379557eb2e233dfec10986b3086877e72db7
 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099
 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
@@ -246,7 +246,7 @@ F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74
 F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b
 F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835
 F src/vtab.c d8020c0a0e8ccc490ca449d7e665311b6e9f3ba9
-F src/wal.c 5acb3e7bbd31f10ba39acad9ce6b399055337a9d
+F src/wal.c e1fe8f92a0ea0fef8faa87ec43a127a478589d22
 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6
 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b
 F src/where.c acc2ec5f6879721f332223da393777438ea5a606
@@ -1018,7 +1018,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9
-P d869eddaf208c4bf03f6bd1848f510392f9dba49
-R 13af348b1bf68a7c36428c6258d6aba5
-U drh
-Z 7bbfe622f493f625120e8c012f0943a5
+P 62225b4a4c4bfe1820ef54cb202edf2cd866429f
+R 09d3e5b05c9dfd1b20715f593e6818b6
+U dan
+Z 07828d460d32254f1342208677faf52f
index 2aa22ae8714a732ab8843a137bab6ad52db021f7..19bd1d6a9722d75b1bb3e8b595c088cbba6c7d1e 100644 (file)
@@ -1 +1 @@
-62225b4a4c4bfe1820ef54cb202edf2cd866429f
\ No newline at end of file
+6b4ff83bff07d427af585c9fd03be90abf2fc82f
\ No newline at end of file
index a094e0da20e02e647aa4f93fbd77ad35cbb4d275..28f6546301b0bbf65576f38427ccdac1157e48b5 100644 (file)
@@ -2509,6 +2509,21 @@ static int pager_truncate(Pager *pPager, Pgno nPage){
   return rc;
 }
 
+/*
+** Return a sanitized version of the sector-size of OS file pFile. The
+** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.
+*/
+int sqlite3SectorSize(sqlite3_file *pFile){
+  int iRet = sqlite3OsSectorSize(pFile);
+  if( iRet<32 ){
+    iRet = 512;
+  }else if( iRet>MAX_SECTOR_SIZE ){
+    assert( MAX_SECTOR_SIZE>=512 );
+    iRet = MAX_SECTOR_SIZE;
+  }
+  return iRet;
+}
+
 /*
 ** Set the value of the Pager.sectorSize variable for the given
 ** pager based on the value returned by the xSectorSize method
@@ -2544,14 +2559,7 @@ static void setSectorSize(Pager *pPager){
     ** call will segfault. */
     pPager->sectorSize = 512;
   }else{
-    pPager->sectorSize = sqlite3OsSectorSize(pPager->fd);
-    if( pPager->sectorSize<32 ){
-      pPager->sectorSize = 512;
-    }
-    if( pPager->sectorSize>MAX_SECTOR_SIZE ){
-      assert( MAX_SECTOR_SIZE>=512 );
-      pPager->sectorSize = MAX_SECTOR_SIZE;
-    }
+    pPager->sectorSize = sqlite3SectorSize(pPager->fd);
   }
 }
 
index 2b60e058dad495e56ea90a052b221dfa6692f5ee..5fb0f0133f14d895632c5b738e4235a543bb41f5 100644 (file)
@@ -160,6 +160,7 @@ void *sqlite3PagerTempSpace(Pager*);
 int sqlite3PagerIsMemdb(Pager*);
 void sqlite3PagerCacheStat(Pager *, int, int, int *);
 void sqlite3PagerClearCache(Pager *);
+int sqlite3SectorSize(sqlite3_file *);
 
 /* Functions used to truncate the database file. */
 void sqlite3PagerTruncateImage(Pager*,Pgno);
index cc166ba43030b7024bfed65b55639a4672fbae81..8394bfa29f2712e386ca09a243365050aa319a47 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -2828,7 +2828,7 @@ int sqlite3WalFrames(
   */
   if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){
     if( pWal->padToSectorBoundary ){
-      int sectorSize = sqlite3OsSectorSize(pWal->pWalFd);
+      int sectorSize = sqlite3SectorSize(pWal->pWalFd);
       w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;
       while( iOffset<w.iSyncPoint ){
         rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);