Avoid a segfault that could occur when running the recover API on a database handle with memory-mapping enabled.

FossilOrigin-Name: e02c697281a777c33070168af784b2d291397e488244a217620897f40aed7158
This commit is contained in:
dan 2022-10-31 10:53:23 +00:00
parent 1e84e1e632
commit 549907fd67
4 changed files with 35 additions and 10 deletions

View File

@ -269,5 +269,14 @@ do_execsql_test 14.1 {
}
do_recover_test 14
#-------------------------------------------------------------------------
reset_db
do_execsql_test 15.1 {
PRAGMA journal_mode=OFF;
PRAGMA mmap_size=10;
CREATE TABLE t1(x);
} {off 10}
do_recover_test 15
finish_test

View File

@ -2161,6 +2161,8 @@ static int recoverVfsShmMap(sqlite3_file*, int, int, int, void volatile**);
static int recoverVfsShmLock(sqlite3_file*, int offset, int n, int flags);
static void recoverVfsShmBarrier(sqlite3_file*);
static int recoverVfsShmUnmap(sqlite3_file*, int deleteFlag);
static int recoverVfsFetch(sqlite3_file*, sqlite3_int64, int, void**);
static int recoverVfsUnfetch(sqlite3_file *pFd, sqlite3_int64 iOff, void *p);
static sqlite3_io_methods recover_methods = {
2, /* iVersion */
@ -2180,7 +2182,8 @@ static sqlite3_io_methods recover_methods = {
recoverVfsShmLock,
recoverVfsShmBarrier,
recoverVfsShmUnmap,
0, 0
recoverVfsFetch,
recoverVfsUnfetch
};
static int recoverVfsClose(sqlite3_file *pFd){
@ -2486,6 +2489,19 @@ static int recoverVfsShmUnmap(sqlite3_file *pFd, int deleteFlag){
);
}
static int recoverVfsFetch(
sqlite3_file *pFd,
sqlite3_int64 iOff,
int iAmt,
void **pp
){
*pp = 0;
return SQLITE_OK;
}
static int recoverVfsUnfetch(sqlite3_file *pFd, sqlite3_int64 iOff, void *p){
return SQLITE_OK;
}
/*
** Install the VFS wrapper around the file-descriptor open on the input
** database for recover handle p. Mutex RECOVER_MUTEX_ID must be held

View File

@ -1,5 +1,5 @@
C Extra\sOOM\scheck\sin\sshell_error_context()\sof\sthe\sCLI.\n[forum:/forumpost/5708841db0|forum\spost\s5708841db0].
D 2022-10-31T01:22:38.233
C Avoid\sa\ssegfault\sthat\scould\soccur\swhen\srunning\sthe\srecover\sAPI\son\sa\sdatabase\shandle\swith\smemory-mapping\senabled.
D 2022-10-31T10:53:23.735
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -386,7 +386,7 @@ F ext/rbu/sqlite3rbu.c 8737cabdfbee84bb25a7851ecef8b1312be332761238da9be6ddb10c6
F ext/rbu/sqlite3rbu.h 1dc88ab7bd32d0f15890ea08d23476c4198d3da3056985403991f8c9cd389812
F ext/rbu/test_rbu.c 03f6f177096a5f822d68d8e4069ad8907fe572c62ff2d19b141f59742821828a
F ext/recover/dbdata.c 3ae32f9b7f02a141889b9075beb87895a826d0fcf3b702b8251cbb0dd3c91a83
F ext/recover/recover1.test e08dc7a0513eab9de33e7b8e2260b9538bedb57c9bd6fbb278f328d29a102827
F ext/recover/recover1.test 522e2c3353734dbef9118f08e47209470e50308ba35ce818fed00b8e265aee44
F ext/recover/recover_common.tcl 6679af7dffc858e345053a91c9b0a897595b4a13007aceffafca75304ccb137c
F ext/recover/recoverclobber.test 294dcc894124ab4ca3a7b35766630742a3d25810fceac22220beb64f70a33a60
F ext/recover/recovercorrupt.test 6540aae95e17398dd70b44518367fd56588c44962cb276d2623a0fedba9efe9e
@ -398,7 +398,7 @@ F ext/recover/recoverpgsz.test 93e970eab05e4e89f8fd6b1bd23f9ec137ea09857e66ba0d4
F ext/recover/recoverrowid.test 1694a1a5526d825f71279f3d02ab02a1ee4c5265de18858bf54cb8ec54487ac8
F ext/recover/recoverslowidx.test f356bb9fba7ffd6fc50e045e419464f0129ac6e24decf6e919584f79c3493727
F ext/recover/recoversql.test f9872ff2114e13ffd8ee31e1de06919f62b9b48bc080191b5bd076d10becb60f
F ext/recover/sqlite3recover.c ec7b6cddae10476312ff22c0a59d97d550fefba3e85fce3750f722d3520350f5
F ext/recover/sqlite3recover.c 0b9962b4fb4f9af408e9a1a535bb77a0a89d871040e429909225d09c2285bc6a
F ext/recover/sqlite3recover.h f698ccc94bd4da38761035415ad08c4549a408491ff9fd5f52d34d2214f64e36
F ext/recover/test_recover.c 61ec931e47abca6b2210f46239cafd9f3060741605e3d3c45a7c7a53f63dd957
F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15
@ -2054,8 +2054,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 7660db2a2e9c4f3a6a9343d6929744ad0f4be6820976411f9080165491da59b7
R 39f668d8fe2469c4ce02b92540fc594e
U drh
Z ccf68645ddf326b444fdf39a1dc53fe4
P cb12ac5de17e677f089d7b0b46803efbd9a9178972ffb0454a8b557b06633658
R 46019e96ebee7f43e27063daa1a45bd1
U dan
Z 31c01b86489219dc9c143f294c0c509f
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
cb12ac5de17e677f089d7b0b46803efbd9a9178972ffb0454a8b557b06633658
e02c697281a777c33070168af784b2d291397e488244a217620897f40aed7158