From: drh Date: Mon, 24 May 2010 13:28:36 +0000 (+0000) Subject: Make sure a WAL frame of all zeros is detected as an invalid frame. X-Git-Tag: version-3.7.2~345 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c81791573a603cc9b6bbb311f92b5cb556c62338;p=thirdparty%2Fsqlite.git Make sure a WAL frame of all zeros is detected as an invalid frame. FossilOrigin-Name: 02d99ad4b51065c67cc7689916130774be1c4c87 --- diff --git a/manifest b/manifest index c56961a9a6..95e347bb41 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Fix\sup\stest_osinst.c\sto\swork\swith\sSQLITE_OMIT_VIRTUALTABLE. -D 2010-05-24T12:34:15 +C Make\ssure\sa\sWAL\sframe\sof\sall\szeros\sis\sdetected\sas\san\sinvalid\sframe. +D 2010-05-24T13:28:36 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -227,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 93e13dfc60e036091eec8c90da4ff9595e97e932 +F src/wal.c e8c58e529bcc50c0fb3797bc39750e802cbace78 F src/wal.h 434f76f51225bb614e43ccb6bd2341541ba6a06e F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356 @@ -817,14 +817,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 65ba804dd1d31d1eef6ae3f40a3ade344a410b84 -R 0975a148083609eb5447373024159739 +P 51fd38152b92db637d1d346fca35ec2d3e4d4f57 +R 3ae8439c7818113b3e55b5c33ec15fc6 U drh -Z 8f7b7419862e6cd292f6daada9d7ada1 +Z 157804aa9c723c5bf0d5892d1297d942 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFL+nJKoxKgR168RlERAjScAJ4/8ZhDAE/GBBAXcCDhuFrHs7q9jACeJ+Ai -97pW8OvIMPU2UcYdSr30juc= -=5VIs +iD8DBQFL+n8IoxKgR168RlERAjqiAJ93cfWX1aiOOxPNMQnGl5zdjLHO3ACfQbUq +4XUL8oGpoSF35Q/+0pQNofc= +=ktcp -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 4bbc2d30b0..ab6b56274d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -51fd38152b92db637d1d346fca35ec2d3e4d4f57 \ No newline at end of file +02d99ad4b51065c67cc7689916130774be1c4c87 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 1d71b20379..0d1cb96249 100644 --- a/src/wal.c +++ b/src/wal.c @@ -451,6 +451,7 @@ static int walDecodeFrame( u8 *aFrame /* Frame data */ ){ int nativeCksum; /* True for native byte-order checksums */ + u32 pgno; /* Page number of the frame */ u32 aCksum[2]; assert( WAL_FRAME_HDRSIZE==24 ); @@ -461,6 +462,13 @@ static int walDecodeFrame( return 0; } + /* A frame is only valid if the page number is creater than zero. + */ + pgno = sqlite3Get4byte(&aFrame[0]); + if( pgno==0 ){ + return 0; + } + /* A frame is only valid if a checksum of the first 16 bytes ** of the frame-header, and the frame-data matches ** the checksum in the last 8 bytes of the frame-header. @@ -478,7 +486,7 @@ static int walDecodeFrame( /* If we reach this point, the frame is valid. Return the page number ** and the new database size. */ - *piPage = sqlite3Get4byte(&aFrame[0]); + *piPage = pgno; *pnTruncate = sqlite3Get4byte(&aFrame[4]); return 1; }