blob: 1b907b9d4dd105cde2a76bc2bfd5a55546bb2ba4 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001Running fts5 prefix queries inside a transaction could trigger a heap-based
2buffer over-read in fts5HashEntrySort in sqlite3.c, which may lead to an
3information leak.
4
5CVE: CVE-2019-9936
6Upstream-Status: Backport [https://sqlite.org/src/vpatch?from=45c73deb440496e8&to=b3fa58dd7403dbd4]
7Signed-off-by: Ross Burton <ross.burton@intel.com>
8---
9 sqlite3.c | 4 +++-
10 1 file changed, 3 insertions(+), 1 deletion(-)
11
12diff --git a/sqlite3.c b/sqlite3.c
13index 4729f45..65527d8 100644
14--- a/sqlite3.c
15+++ b/sqlite3.c
16@@ -207759,7 +207759,9 @@ static int fts5HashEntrySort(
17 for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
18 Fts5HashEntry *pIter;
19 for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
20- if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
21+ if( pTerm==0
22+ || (pIter->nKey+1>=nTerm && 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm))
23+ ){
24 Fts5HashEntry *pEntry = pIter;
25 pEntry->pScanNext = 0;
26 for(i=0; ap[i]; i++){
27--
282.20.1