]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Create the "uptr" typedef (the same as uintptr_t when available) and use it
authordrh <drh@noemail.net>
Tue, 22 Mar 2016 14:37:59 +0000 (14:37 +0000)
committerdrh <drh@noemail.net>
Tue, 22 Mar 2016 14:37:59 +0000 (14:37 +0000)
to cast pointers before comparison.

FossilOrigin-Name: 2484cc0c3ffc8834a155f89af1581bd07d453a90

manifest
manifest.uuid
src/btree.c
src/sqliteInt.h

index d6d21ac7ef1d7b6ec3a593b8e8df1af964ba6d6c..6c9eb30c1e348a0a12c264582385d31f680839e3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Avoid\sthe\spossibility\sof\sinteger\soverflow\son\sa\spointer\scomparison\stest\sfor\ncorruption\sin\sthe\sdatabase\sfile.
-D 2016-03-22T14:10:45.052
+C Create\sthe\s"uptr"\stypedef\s(the\ssame\sas\suintptr_t\swhen\savailable)\sand\suse\sit\nto\scast\spointers\sbefore\scomparison.
+D 2016-03-22T14:37:59.457
 F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66
@@ -297,7 +297,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
 F src/backup.c f60f0aa55d25d853ffde53d0b0370a7bb7ee41ce
 F src/bitvec.c 3ee4c8b2c94ed3a7377256e18199e6ff5cf33f63
 F src/btmutex.c bc87dd3b062cc26edfe79918de2200ccb8d41e73
-F src/btree.c 5753da53071b5d5a8ace8fd9ea7a54cefeb8187b
+F src/btree.c 8a02b1fb98eb11b9ce50cb3ab6a031f852b69303
 F src/btree.h a5008b9afe56e8e54ade6c436a910f112defcca9
 F src/btreeInt.h c18b7d2a3494695133e4e60ee36061d37f45d9a5
 F src/build.c 213cbf84e99dd834e6ea46615633656d7ef79321
@@ -358,7 +358,7 @@ F src/shell.c 5e0ab1e708dc294330ccd8230536e1801f60822e
 F src/sqlite.h.in e877f141b15ef68ef28f84714e69d7234f9a071e
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h 98f72cbfe00169c39089115427d06ea05fe4b4a2
-F src/sqliteInt.h 47847a919790e2a30bb1dfb89ba0dc59fc6ed0be
+F src/sqliteInt.h cb02015eac6d642bd23d8cbd76cc116635c17540
 F src/sqliteLimit.h 7b28cf72cbd52f178bfc97ea266445e351f2cd24
 F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
@@ -1459,7 +1459,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 25d776e4523aefeec007943fe29aa17c23ccb301
-R 7b06b50bff5ae9500629c34b0d5509bb
+P ff1b1ac3313ba9d70414e928ef3dd82913298a1a
+R db2868426a9aae9f4cc9b8c065b04b6c
 U drh
-Z 3c0767287744fc9671f0ea1849fc5941
+Z 0cd59c36c28d6740a5e8b1f16f08075a
index bf5169d0f4cfdef00e09b579ddcb06d1eb2e3113..b4fc72f3922ad77a93f343218ae54c308ab7a159 100644 (file)
@@ -1 +1 @@
-ff1b1ac3313ba9d70414e928ef3dd82913298a1a
\ No newline at end of file
+2484cc0c3ffc8834a155f89af1581bd07d453a90
\ No newline at end of file
index 3e29f8469d1232481365a01210ad1f41c63325ce..1a82176f18110f2d8b204d2fe28ea42ac35b60cb 100644 (file)
@@ -2360,12 +2360,12 @@ int sqlite3BtreeOpen(
     for(i=0; i<db->nDb; i++){
       if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){
         while( pSib->pPrev ){ pSib = pSib->pPrev; }
-        if( p->pBt<pSib->pBt ){
+        if( (uptr)p->pBt<(uptr)pSib->pBt ){
           p->pNext = pSib;
           p->pPrev = 0;
           pSib->pPrev = p;
         }else{
-          while( pSib->pNext && pSib->pNext->pBt<p->pBt ){
+          while( pSib->pNext && (uptr)pSib->pNext->pBt<(uptr)p->pBt ){
             pSib = pSib->pNext;
           }
           p->pNext = pSib->pNext;
index 858f737356602d95a7b1d9e5fc87d398dad76c97..d256262b05886b8d29beb5072d5e782bb4a0848f 100644 (file)
 # define SQLITE_PTR_TO_INT(X)  ((int)(X))
 #endif
 
-/*
-** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
-** something between S (inclusive) and E (exclusive).
-**
-** In other words, S is a buffer and E is a pointer to the first byte after
-** the end of buffer S.  This macro returns true if P points to something
-** contained within the buffer S.
-*/
-#if defined(HAVE_STDINT_H)
-# define SQLITE_WITHIN(P,S,E) \
-    ((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
-#else
-# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
-#endif
-
 /*
 ** A macro to hint to the compiler that a function should not be
 ** inlined.
@@ -717,6 +702,27 @@ typedef INT16_TYPE LogEst;
 # endif
 #endif
 
+/* The uptr type is an unsigned integer large enough to hold a pointer
+*/
+#if defined(HAVE_STDINT_H)
+  typedef uintptr_t uptr;
+#elif SQLITE_PTRSIZE==4
+  typedef u32 uptr;
+#else
+  typedef u64 uptr;
+#endif
+
+/*
+** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
+** something between S (inclusive) and E (exclusive).
+**
+** In other words, S is a buffer and E is a pointer to the first byte after
+** the end of buffer S.  This macro returns true if P points to something
+** contained within the buffer S.
+*/
+#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
+
+
 /*
 ** Macros to determine whether the machine is big or little endian,
 ** and whether or not that determination is run-time or compile-time.