summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/sqlite/files/CVE-2023-7104.patch
blob: 01ff29ff5e2487808cc56e736860f1a0c31f16f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From eab426c5fba69d2c77023939f72b4ad446834e3c Mon Sep 17 00:00:00 2001
From: dan <Dan Kennedy>
Date: Thu, 7 Sep 2023 13:53:09 +0000
Subject: [PATCH] Fix a buffer overread in the sessions extension that could occur when processing a corrupt changeset.

Upstream-Status: Backport [https://sqlite.org/src/info/0e4e7a05c4204b47]
CVE: CVE-2023-7104
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
---
 sqlite3.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/sqlite3.c b/sqlite3.c
index 972ef18..c645ac8 100644
--- a/sqlite3.c
+++ b/sqlite3.c
@@ -203301,15 +203301,19 @@ static int sessionReadRecord(
         }
       }
       if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
-        sqlite3_int64 v = sessionGetI64(aVal);
-        if( eType==SQLITE_INTEGER ){
-          sqlite3VdbeMemSetInt64(apOut[i], v);
+	if( (pIn->nData-pIn->iNext)<8 ){
+	  rc = SQLITE_CORRUPT_BKPT;
         }else{
-          double d;
-          memcpy(&d, &v, 8);
-          sqlite3VdbeMemSetDouble(apOut[i], d);
+	  sqlite3_int64 v = sessionGetI64(aVal);
+	  if( eType==SQLITE_INTEGER ){
+	    sqlite3VdbeMemSetInt64(apOut[i], v);
+	  }else{
+	    double d;
+	    memcpy(&d, &v, 8);
+	    sqlite3VdbeMemSetDouble(apOut[i], d);
+	  }
+	  pIn->iNext += 8;
         }
-        pIn->iNext += 8;
       }
     }
   }
-- 
2.25.1