]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a bug in the btree code for reading varints greater than 2^32. (CVS 1349)
authordanielk1977 <danielk1977@noemail.net>
Tue, 11 May 2004 02:10:06 +0000 (02:10 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 11 May 2004 02:10:06 +0000 (02:10 +0000)
FossilOrigin-Name: 7bc4f5543fbfa9f3fe6e9479a1f85fbaf6c95af4

manifest
manifest.uuid
src/btree.c
src/test3.c
src/vdbe.c

index 2ef2879985ccf1502118df938c5971e521ce362b..666b01867dabda5688c8f511c5676e53dcf9ca19 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\sthe\smain.mk\smakefile\sso\sthat\sit\sbuilds\severything\sagain.\s(CVS\s1348)
-D 2004-05-11T01:18:25
+C Fix\sa\sbug\sin\sthe\sbtree\scode\sfor\sreading\svarints\sgreater\sthan\s2^32.\s(CVS\s1349)
+D 2004-05-11T02:10:07
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -23,7 +23,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
 F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
 F src/attach.c fa9a58234406d84eeb900517d0c0adc4b2da051a
 F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79
-F src/btree.c ac2de2cfaf183e15ae6e58e52530b37a7de02a0f
+F src/btree.c 4e9ed30d1239e077d94efe3d6b9a5ee205e2f979
 F src/btree.h 578dc465c801cf4e7666efbb0fa1c46a54758008
 F src/btree_rb.c 9d7973e266ee6f9c61ce592f68742ce9cd5b10e5
 F src/build.c 8d9965b3ce5dcc1bd4dac60bd0f14524fea269cb
@@ -54,7 +54,7 @@ F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
 F src/tclsqlite.c a38bf2263a097fcc9603e818c291151de1782c11
 F src/test1.c 79956f70dddd1a28f8577bbd61c8cf28e5875eb8
 F src/test2.c 6195a1ca2c8d0d2d93644e86da3289b403486872
-F src/test3.c e238a8ded4d7842cb369a7e03ab1fd0bcee5f15a
+F src/test3.c 1b3ac2199169fb331685c7bef15ad54721db278b
 F src/test4.c b3fab9aea7a8940a8a7386ce1c7e2157b09bd296
 F src/test5.c eb39aac8fed61bd930b92613cd705c145244074a
 F src/tokenize.c e7536dd31205d5afb76c1bdc832dea009c7a3847
@@ -63,7 +63,7 @@ F src/update.c 6ca82fc4a0fb4d7f134e961921c906f6f3c8bc74
 F src/utf.c fc799748d43fe1982d157b871e3e420a19c85d4f
 F src/util.c 74ee316594f68c41aed1884d737ab4085d479455
 F src/vacuum.c c134702e023db8778e6be59ac0ea7b02315b5476
-F src/vdbe.c c6c763868eec22a5d7b23357a89fa7792cc9575b
+F src/vdbe.c f2094463b65008ff5b21efb8fa9488166708415f
 F src/vdbe.h 2dc4d1161b64f5684faa6a2d292e318a185ecb2e
 F src/vdbeInt.h d5786e1c4f7dadac24e3baeed9847dbfed3016de
 F src/vdbeaux.c 7162f1390620257e25070da1ac2b4ec83e472752
@@ -188,7 +188,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P a675ac49882887dfcbf671e9092a29aca9eb694e
-R e4298f2dca6b4eb015412d2c78eef0b6
-U drh
-Z e408df7d35442709fba413b4e2b48938
+P e6e52fc2e62835712d6b92a19fdbd2ba15b2e9cd
+R eddbe501e85ee40d9b6f98dd3f3ed5da
+U danielk1977
+Z 09a8cec2758d5fe1ed56a8565010b716
index 3c7665da13d917a28848b65b7c985631446b3e6b..1da647e4fe14fd503f0466fcacf81a397a48c12a 100644 (file)
@@ -1 +1 @@
-e6e52fc2e62835712d6b92a19fdbd2ba15b2e9cd
\ No newline at end of file
+7bc4f5543fbfa9f3fe6e9479a1f85fbaf6c95af4
\ No newline at end of file
index 78bf7b2e051c3c75363556687c97152087e94c73..3e20e46ce52370f1dd28a055d975a4b0f7d13253 100644 (file)
@@ -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;
index 711857ce61e342f8332dfb4c8926b60942a7f170..a31b042d61945ebc01dd1b87b6aaf459bad8348f 100644 (file)
@@ -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]),
index cefd67c11a5f2ecdf0433f5820893f85b9535ae1..770706813ecc4755ac49806579a12470bfb7dca9 100644 (file)
@@ -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! */