diff options
author | drh <drh@noemail.net> | 2008-11-07 00:24:53 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-11-07 00:24:53 +0000 |
commit | 98c58356aebe4447a43d3c4c17beabbd300b0fdc (patch) | |
tree | 6fff23a399af5c9119f29fc8b3a77715ae32c5f0 /src/pager.c | |
parent | 4c17c3fb115c10c744b710c91177f7090ae2ecb9 (diff) | |
download | sqlite-98c58356aebe4447a43d3c4c17beabbd300b0fdc.tar.gz sqlite-98c58356aebe4447a43d3c4c17beabbd300b0fdc.zip |
Prevent a rollback from crashing if the sector-size field of the
rollback journal is corrupted. (CVS 5868)
FossilOrigin-Name: cf9d1d933f6b6713018928d9a7680ae63e8edcd0
Diffstat (limited to 'src/pager.c')
-rw-r--r-- | src/pager.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/pager.c b/src/pager.c index ca4716e6e..4d24a36ea 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.501 2008/11/03 20:55:07 drh Exp $ +** @(#) $Id: pager.c,v 1.502 2008/11/07 00:24:54 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -203,7 +203,7 @@ struct Pager { i64 stmtHdrOff; /* First journal header written this statement */ i64 stmtCksum; /* cksumInit when statement was started */ i64 stmtJSize; /* Size of journal at stmt_begin() */ - int sectorSize; /* Assumed sector size during rollback */ + u32 sectorSize; /* Assumed sector size during rollback */ #ifdef SQLITE_TEST int nHit, nMiss; /* Cache hits and missing */ int nRead, nWrite; /* Database pages read/written */ @@ -756,8 +756,12 @@ static int readJournalHdr( ** is being called from within pager_playback(). The local value ** of Pager.sectorSize is restored at the end of that routine. */ - rc = read32bits(pPager->jfd, jrnlOff+12, (u32 *)&pPager->sectorSize); + rc = read32bits(pPager->jfd, jrnlOff+12, &pPager->sectorSize); if( rc ) return rc; + if( (pPager->sectorSize & (pPager->sectorSize-1))!=0 + || pPager->sectorSize>0x1000000 ){ + return SQLITE_DONE; + } pPager->journalOff += JOURNAL_HDR_SZ(pPager); return SQLITE_OK; |