Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/sqlite/patches/0015-fts3-Interior-node-corruption-detection.patch

Issue 885473002: [sql] Rewrite sqlite patching "system". (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 From 791a4ecc9e9f325c9eab9d6e6b478fe7533b3edd Mon Sep 17 00:00:00 2001
2 From: Scott Hess <shess@chromium.org>
3 Date: Tue, 23 Dec 2014 13:23:08 -0800
4 Subject: [PATCH 15/24] [fts3] Interior node corruption detection.
5
6 In auditing as part of a previous import, I noticed this case which
7 seemed to allow for buffer overrun. The nPrefix check was commented out
8 because nBuffer wasn't always initialized, and I never circled back to
9 resolve that.
10
11 It may be appropriate to just drop this patch, for now leaving it for
12 consistency.
13
14 BUG=84057, 83946
15 ---
16 third_party/sqlite/src/ext/fts3/fts3.c | 8 +++++++-
17 1 file changed, 7 insertions(+), 1 deletion(-)
18
19 diff --git a/third_party/sqlite/src/ext/fts3/fts3.c b/third_party/sqlite/src/ext /fts3/fts3.c
20 index da55f2a..d11572a 100644
21 --- a/third_party/sqlite/src/ext/fts3/fts3.c
22 +++ b/third_party/sqlite/src/ext/fts3/fts3.c
23 @@ -1230,7 +1230,13 @@ static int fts3ScanInteriorNode(
24 isFirstTerm = 0;
25 zCsr += sqlite3Fts3GetVarint32(zCsr, &nSuffix);
26
27 - if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){
28 + /* NOTE(shess): Previous code checked for negative nPrefix and
29 + ** nSuffix and suffix overrunning zEnd. Additionally corrupt if
30 + ** the prefix is longer than the previous term, or if the suffix
31 + ** causes overflow.
32 + */
33 + if( nPrefix<0 || nSuffix<0 /* || nPrefix>nBuffer */
34 + || &zCsr[nSuffix]<zCsr || &zCsr[nSuffix]>zEnd ){
35 rc = SQLITE_CORRUPT;
36 goto finish_scan;
37 }
38 --
39 2.2.1
40
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698