mirror of
https://github.com/sqlite/sqlite.git
synced 2026-10-23 21:49:02 +03:00
Prevent a corrupt database from causing a CPU stack overflow in PRAGMA
integrity_check. Report the excess btree depth instead. [bugs:/info/2026-08-18T10:33:10Z|Bug 2026-08-18T10:33:10Z]. FossilOrigin-Name: afd9f401c4dd99be3df2bb5681d8e5c73f9268282392185a2b40c91407732788
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Use\sa\stypecast\sto\sfix\sa\spossible\sinteger\soverflow\sin\sthe\s\n(unsupported)\sext/misc/compress.c\sextension.\n[bugs:/info/2026-08-18T09:33:57Z|Bug\s2026-08-18T09:33:57Z].
|
||||
D 2026-08-18T10:33:46.805
|
||||
C Prevent\sa\scorrupt\sdatabase\sfrom\scausing\sa\sCPU\sstack\soverflow\sin\sPRAGMA\nintegrity_check.\s\sReport\sthe\sexcess\sbtree\sdepth\sinstead.\n[bugs:/info/2026-08-18T10:33:10Z|Bug\s2026-08-18T10:33:10Z].
|
||||
D 2026-08-18T13:07:33.751
|
||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
@@ -683,9 +683,9 @@ F src/auth.c b5ece4e1edccad082c0332fa0087df225473bae0feea9269f824312201377185
|
||||
F src/backup.c f6a1490f4ef86cca51f0f93158bbc140b5822406e0c50ec61731e3fcdc1242a2
|
||||
F src/bitvec.c e242d4496774dfc88fa278177dd23b607dce369ccafb3f61b41638eea2c9b399
|
||||
F src/btmutex.c 30dada73a819a1ef5b7583786370dce1842e12e1ad941e4d05ac29695528daea
|
||||
F src/btree.c c99c5e3758ee506de6ae60c12e14ba3ab1ed0336b80a7795b60c7d807dd8189c
|
||||
F src/btree.c b95c69c7057f652ef654c421cdafdc9a847aeed56af153e5e86cf115ad3d9552
|
||||
F src/btree.h 2ee0ddfdf4f8530ad1d46afffd7da21a0e243bfab10973011ac6f6b7fb4109a1
|
||||
F src/btreeInt.h 1e4a7d04e809e98abc39654b6089c60d749a724598041ff553b392a3277e9b98
|
||||
F src/btreeInt.h df956bca48cd49d2a38886bc3b02045c039e8a16353f86fccd116c6487f79d82
|
||||
F src/build.c 6d55fcda11273ae382e1bcf9695468ca0c05547a2e2f6f09d64f30cb64f4400e
|
||||
F src/callback.c 3605bbf02bd7ed46c79cd48346db4a32fc51d67624400539c0532f4eead804ad
|
||||
F src/carray.c 22879bbd9e14fc4868f223b0d49bcdbbda4616c89f1519ec6a5e64b98a4137b1
|
||||
@@ -2219,8 +2219,8 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
|
||||
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
|
||||
P 003ed951d85416da97f5cabf96d89b974279bd8ef2433ae1987bdedad38a4b90
|
||||
R 6b4b0611ce6cfddda2c13339b3012cc7
|
||||
P d0f1f683b94f90ba111509ec1c108a73388579c870aa740379b28cbb00a2827b
|
||||
R 078fdc6847a45d090bf8ffdf7137931c
|
||||
U drh
|
||||
Z 9d95fe9ae223fd37fc65c0468d36d136
|
||||
Z e4c435b7060d23716d96d9531cadefbf
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
@@ -1 +1 @@
|
||||
d0f1f683b94f90ba111509ec1c108a73388579c870aa740379b28cbb00a2827b
|
||||
afd9f401c4dd99be3df2bb5681d8e5c73f9268282392185a2b40c91407732788
|
||||
|
||||
10
src/btree.c
10
src/btree.c
@@ -10919,19 +10919,24 @@ static int checkTreePage(
|
||||
/* Check that the page exists
|
||||
*/
|
||||
checkProgress(pCheck);
|
||||
if( pCheck->mxErr==0 ) goto end_of_check;
|
||||
if( pCheck->mxErr==0 ) return 0;
|
||||
pBt = pCheck->pBt;
|
||||
usableSize = pBt->usableSize;
|
||||
if( iPage==0 ) return 0;
|
||||
if( checkRef(pCheck, iPage) ) return 0;
|
||||
pCheck->zPfx = "Tree %u page %u: ";
|
||||
pCheck->v1 = iPage;
|
||||
pCheck->nAbove++;
|
||||
if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){
|
||||
checkAppendMsg(pCheck,
|
||||
"unable to get the page. error code=%d", rc);
|
||||
if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM;
|
||||
goto end_of_check;
|
||||
}
|
||||
if( pCheck->nAbove > BTCURSOR_MAX_DEPTH ){
|
||||
checkAppendMsg(pCheck,"btree depth exceeds %d",BTCURSOR_MAX_DEPTH);
|
||||
goto end_of_check;
|
||||
}
|
||||
|
||||
/* Clear MemPage.isInit to make sure the corruption detection code in
|
||||
** btreeInitPage() is executed. */
|
||||
@@ -11151,6 +11156,7 @@ end_of_check:
|
||||
pCheck->zPfx = saved_zPfx;
|
||||
pCheck->v1 = saved_v1;
|
||||
pCheck->v2 = saved_v2;
|
||||
pCheck->nAbove--;
|
||||
return depth+1;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
|
||||
@@ -11283,7 +11289,9 @@ int sqlite3BtreeIntegrityCheck(
|
||||
}
|
||||
#endif
|
||||
sCheck.v0 = aRoot[i];
|
||||
assert( sCheck.nAbove==0 );
|
||||
checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64);
|
||||
assert( sCheck.nAbove==0 );
|
||||
}
|
||||
sqlite3MemSetArrayInt64(aCnt, i, sCheck.nRow);
|
||||
}
|
||||
|
||||
@@ -709,6 +709,7 @@ struct IntegrityCk {
|
||||
int nErr; /* Number of messages written to zErrMsg so far */
|
||||
int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */
|
||||
u32 nStep; /* Number of steps into the integrity_check process */
|
||||
u8 nAbove; /* Current btree recursion depth */
|
||||
const char *zPfx; /* Error message prefix */
|
||||
Pgno v0; /* Value for first %u substitution in zPfx (root page) */
|
||||
Pgno v1; /* Value for second %u substitution in zPfx (current pg) */
|
||||
|
||||
Reference in New Issue
Block a user