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

Use memmove() instead of memcpy() in a place where buffers might overlap

if the database file is badly corrupted, to prevent warnings
from ASAN and valgrind.

FossilOrigin-Name: 65ad6c55f1ba9bc2f75afffa3adaf19f145fad7ac9a00ccce6372e9a2cc4341b
This commit is contained in:
drh
2019-01-24 13:36:47 +00:00
parent 6a02f237e3
commit 55469bbafb
4 changed files with 13 additions and 9 deletions

View File

@@ -8351,7 +8351,11 @@ static int btreeOverwriteContent(
if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
int rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc ) return rc;
memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
/* In a corrupt database, it is possible for the source and destination
** buffers to overlap. This is harmless since the database is already
** corrupt but it does cause valgrind and ASAN warnings. So use
** memmove(). */
memmove(pDest, ((u8*)pX->pData) + iOffset, iAmt);
}
}
return SQLITE_OK;