From: drh Date: Tue, 1 Jun 2010 12:58:41 +0000 (+0000) Subject: Fix an off-by-one boundary-value issue in walCleanupHash(). X-Git-Tag: version-3.7.2~328^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c1564779e367e501e425342eee6eb57a1804d4c;p=thirdparty%2Fsqlite.git Fix an off-by-one boundary-value issue in walCleanupHash(). FossilOrigin-Name: f039552e6330b6a04281748f985b41937f534bd0 --- diff --git a/manifest b/manifest index e7ae6774aa..c429dfe94f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Do\snot\shold\sthe\sshared-memory\smutex\sin\sos_unix.c\sif\sreturning\sNULL. -D 2010-06-01T11:08:57 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\san\soff-by-one\sboundary-value\sissue\sin\swalCleanupHash(). +D 2010-06-01T12:58:41 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -224,7 +227,7 @@ F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda -F src/wal.c a18a20596b8b9ea09ed9c8741f9193e165f0cb6f +F src/wal.c 2a122212dcf4c3955f0c481423d1229f2de243c5 F src/wal.h 1c1c9feb629b7f4afcbe0b47f80f47c5551d3a02 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356 @@ -815,7 +818,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 9e95e35728cf69a0ae50e774d7f6c71a41b17d97 -R 67ccfc3b179b63c3e3b80e2b7e1142bd -U dan -Z 560dece5b4a16dc5e0eff482c3f02a96 +P 9622dd468c8914262e9d8bd8dbca9e22ec6ee75c +R 2027cf2e3628664b2b4aeae9063b73e6 +U drh +Z 6523cefeaece12ca468a422414c222b4 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFMBQQFoxKgR168RlERArWrAJkB9UGjRw3tmehhDr5P1HYBMojm4gCfca8+ +OpbJgYgS2VEE4rPB1ieyWGg= +=X2Kt +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 82274c2ee1..0d9463041f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9622dd468c8914262e9d8bd8dbca9e22ec6ee75c \ No newline at end of file +f039552e6330b6a04281748f985b41937f534bd0 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 49becd0e0a..48b9c04b5f 100644 --- a/src/wal.c +++ b/src/wal.c @@ -822,11 +822,16 @@ static void walCleanupHash(Wal *pWal){ int iLimit; /* Zero values greater than this */ assert( pWal->writeLock ); - walHashFind(pWal, pWal->hdr.mxFrame+1, &aHash, &aPgno, &iZero); - iLimit = pWal->hdr.mxFrame - iZero; - if( iLimit>0 ){ + testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE-1 ); + testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE ); + testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE+1 ); + if( (pWal->hdr.mxFrame % HASHTABLE_NPAGE)>0 ){ int nByte; /* Number of bytes to zero in aPgno[] */ int i; /* Used to iterate through aHash[] */ + + walHashFind(pWal, pWal->hdr.mxFrame+1, &aHash, &aPgno, &iZero); + iLimit = pWal->hdr.mxFrame - iZero; + assert( iLimit>0 ); for(i=0; iiLimit ){ aHash[i] = 0;