From 4e1ddde370721ed43495a292f6d5d68c8fb1b6a3 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Tue, 25 Mar 2008 16:16:29 +0000 Subject: [PATCH] Test string values passed to bind_text() and result_text() for a nul-terminator. (CVS 4915) FossilOrigin-Name: 24c3ebc0c5c53c234516d16dce761d713fb29578 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/tclsqlite.c | 4 ++-- src/vdbemem.c | 8 ++++++++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1537585781..1afbe0a693 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Have\seach\s{quote:\sBtShared}\sstructure\shang\son\sto\sa\sbuffer\sof\sjust\sunder\spage-size\sbytes\sfor\stemporary\suse.\sThis\sreduces\sthe\snumber\sof\scalls\sto\smalloc().\s(CVS\s4914) -D 2008-03-25T14:24:57 +C Test\sstring\svalues\spassed\sto\sbind_text()\sand\sresult_text()\sfor\sa\snul-terminator.\s(CVS\s4915) +D 2008-03-25T16:16:29 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -143,7 +143,7 @@ F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3 F src/sqliteInt.h 07b472437b2d7297c300f8b7cea5205984fa64d1 F src/sqliteLimit.h eecbc288b410ae5565e71aaa4a439aae57bb0707 F src/table.c 2c48c575dd59b3a6c5c306bc55f51a9402cf429a -F src/tclsqlite.c d42912617d4734b8f9195416badf5b27e512ded2 +F src/tclsqlite.c 1367762764772a233643524c3585b4711a9adcda F src/test1.c 342a2628310fa709074d979e695a28a3bb570834 F src/test2.c f0808cc643528b9620e4059ca9bda8346f526121 F src/test3.c 31027a4a190d2f3c1e479ea2d750e696160bbf04 @@ -181,7 +181,7 @@ F src/vdbeapi.c b9e9d7a58690c1e1ae66de7232edccf4793ad817 F src/vdbeaux.c c071014d81c1d4b2c381247c16a3e86182951e51 F src/vdbeblob.c cc713c142c3d4952b380c98ee035f850830ddbdb F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736 -F src/vdbemem.c 67662aac917b627356262f9501591206db2a8845 +F src/vdbemem.c d48a71d66a7afd564b6537ab7e7442f7729fa5af F src/vtab.c 00cd16317b29495c185ff40e4b227917d5a371b2 F src/where.c f18bac2f87c965811727be1be05deeaf5229fcd0 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 @@ -617,7 +617,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P ef0e40e814b3d3a00721f8ca39bac0db1be24347 -R d58ce8f374758d218509d77eae1fa411 +P fe1bc0f3b7cd87cd65f7d03b91095b59788a6f8d +R 033bb4545035899c2c5396ecb143bb5f U danielk1977 -Z 6b876eb9851a975cdfed8252be002c4a +Z 09f5af34fae3a95557976f8d7d3936e3 diff --git a/manifest.uuid b/manifest.uuid index 95e12400e5..8bf67601ed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fe1bc0f3b7cd87cd65f7d03b91095b59788a6f8d \ No newline at end of file +24c3ebc0c5c53c234516d16dce761d713fb29578 \ No newline at end of file diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 0d88727e15..9e49d039ea 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -12,7 +12,7 @@ ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** -** $Id: tclsqlite.c,v 1.211 2008/03/19 19:01:22 drh Exp $ +** $Id: tclsqlite.c,v 1.212 2008/03/25 16:16:29 danielk1977 Exp $ */ #include "tcl.h" #include @@ -1671,7 +1671,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ sqlite3_bind_int64(pStmt, i, v); }else{ data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n); - sqlite3_bind_text(pStmt, i, (char *)data, n, SQLITE_STATIC); + sqlite3_bind_text(pStmt, i, (char *)data, n+1, SQLITE_STATIC); Tcl_IncrRefCount(pVar); apParm[nParm++] = pVar; } diff --git a/src/vdbemem.c b/src/vdbemem.c index bd34c65ed0..8e9d061efa 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -636,6 +636,14 @@ int sqlite3VdbeMemSetStr( for(nByte=0; z[nByte] | z[nByte+1]; nByte+=2){} } flags |= MEM_Term; + }else if( enc==SQLITE_UTF8 && nByte>0 && z[nByte-1]=='\0' ){ + nByte--; + flags |= MEM_Term; +#ifndef SQLITE_OMIT_UTF16 + }else if( enc && nByte>1 && z[nByte-1]=='\0' && z[nByte-2]=='\0' ){ + nByte -= 2; + flags |= MEM_Term; +#endif } /* The following block sets the new values of Mem.z and Mem.xDel. It