1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-21 13:38:01 +03:00

Fix SQLITE_ENABLE_SETLK_TIMEOUT assert() statements in os_unix.c to avoid reading past the end of the unixShmNode.aMutex[] array.

FossilOrigin-Name: 029a05cd2928d43d81e4549cce5388c432e2c9e75e3fa0b2fe6e91021b2fb9ac
This commit is contained in:
dan
2023-12-20 19:33:41 +00:00
parent 95cf95841c
commit 0d7f0e49a4
3 changed files with 17 additions and 11 deletions

View File

@@ -4434,9 +4434,15 @@ static int unixShmSystemLock(
pShmNode = pFile->pInode->pShmNode;
/* Assert that the correct mutex or mutexes are held. */
if( pShmNode->nRef==0 ){
assert( ofst==UNIX_SHM_DMS && n==1 && unixMutexHeld() );
/* Assert that the parameters are within expected range and that the
** correct mutex or mutexes are held. */
assert( pShmNode->nRef>=0 );
assert( (ofst==UNIX_SHM_DMS && n==1)
|| (ofst>=UNIX_SHM_BASE && ofst+n<=(UNIX_SHM_BASE+SQLITE_SHM_NLOCK))
);
if( ofst==UNIX_SHM_DMS ){
assert( pShmNode->nRef>0 || unixMutexHeld() );
assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->pShmMutex) );
}else{
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
int ii;