1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Make sure a WAL frame of all zeros is detected as an invalid frame.

FossilOrigin-Name: 02d99ad4b51065c67cc7689916130774be1c4c87
This commit is contained in:
drh
2010-05-24 13:28:36 +00:00
parent 00f699d57b
commit c81791573a
3 changed files with 19 additions and 11 deletions

View File

@@ -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;
}