diff options
author | danielk1977 <danielk1977@noemail.net> | 2004-05-11 02:10:06 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2004-05-11 02:10:06 +0000 |
commit | 49f737d1247dd480b42f02307a2d25e866bd792d (patch) | |
tree | 908bc512e6e5332e2798c455a9c4c2eb2e87edd6 /src | |
parent | 1bbf5ee85c2e997fa62484ada5809ccdaa04a717 (diff) | |
download | sqlite-49f737d1247dd480b42f02307a2d25e866bd792d.tar.gz sqlite-49f737d1247dd480b42f02307a2d25e866bd792d.zip |
Fix a bug in the btree code for reading varints greater than 2^32. (CVS 1349)
FossilOrigin-Name: 7bc4f5543fbfa9f3fe6e9479a1f85fbaf6c95af4
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 4 | ||||
-rw-r--r-- | src/test3.c | 10 | ||||
-rw-r--r-- | src/vdbe.c | 5 |
3 files changed, 14 insertions, 5 deletions
diff --git a/src/btree.c b/src/btree.c index 78bf7b2e0..3e20e46ce 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.125 2004/05/11 00:58:56 drh Exp $ +** $Id: btree.c,v 1.126 2004/05/11 02:10:07 danielk1977 Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -309,7 +309,7 @@ static unsigned int getVarint(unsigned char *p, u64 *pResult){ u64 x = p[0] & 0x7f; int n = 0; while( (p[n++]&0x80)!=0 ){ - x |= (p[n]&0x7f)<<(n*7); + x |= ((u64)(p[n]&0x7f))<<(n*7); } *pResult = x; return n; diff --git a/src/test3.c b/src/test3.c index 711857ce6..a31b042d6 100644 --- a/src/test3.c +++ b/src/test3.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test3.c,v 1.35 2004/05/11 00:58:56 drh Exp $ +** $Id: test3.c,v 1.36 2004/05/11 02:10:07 danielk1977 Exp $ */ #include "sqliteInt.h" #include "pager.h" @@ -686,8 +686,16 @@ static int btree_insert( } if( Tcl_GetInt(interp, argv[1], (int*)&pCur) ) return TCL_ERROR; if( sqlite3BtreeFlags(pCur) & BTREE_INTKEY ){ +/* int iKey; if( Tcl_GetInt(interp, argv[2], &iKey) ) return TCL_ERROR; +*/ + i64 iKey; + Tcl_Obj *obj = Tcl_NewStringObj(argv[2], -1); + Tcl_IncrRefCount(obj); + if( Tcl_GetWideIntFromObj(interp, obj, &iKey) ) return TCL_ERROR; + Tcl_DecrRefCount(obj); + rc = sqlite3BtreeInsert(pCur, 0, iKey, argv[3], strlen(argv[3])); }else{ rc = sqlite3BtreeInsert(pCur, argv[2], strlen(argv[2]), diff --git a/src/vdbe.c b/src/vdbe.c index cefd67c11..770706813 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.275 2004/05/11 00:28:43 danielk1977 Exp $ +** $Id: vdbe.c,v 1.276 2004/05/11 02:10:07 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -3211,7 +3211,8 @@ case OP_PutStrKey: { ** the integer key, and zKey to NULL. */ if( pC->intKey ){ - nKey = pNos->i; + nKey = intToKey(pNos->i); + assert( keyToInt(nKey)==pNos->i ); zKey = 0; }else{ /* TODO: can this happen? zKey is not correctly byte-ordered here! */ |