aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attach.c10
-rw-r--r--src/btree.c14
-rw-r--r--src/build.c18
-rw-r--r--src/date.c35
-rw-r--r--src/func.c6
-rw-r--r--src/insert.c13
-rw-r--r--src/legacy.c7
-rw-r--r--src/os_unix.c23
-rw-r--r--src/os_win.c2
-rw-r--r--src/pager.c10
-rw-r--r--src/select.c4
-rw-r--r--src/shell.c57
-rw-r--r--src/table.c5
-rw-r--r--src/tclsqlite.c27
-rw-r--r--src/util.c16
-rw-r--r--src/vdbe.c23
-rw-r--r--src/vdbeaux.c10
-rw-r--r--src/vdbeblob.c8
-rw-r--r--src/vtab.c6
-rw-r--r--src/where.c12
20 files changed, 174 insertions, 132 deletions
diff --git a/src/attach.c b/src/attach.c
index 41bf90b33..b25eed250 100644
--- a/src/attach.c
+++ b/src/attach.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the ATTACH and DETACH commands.
**
-** $Id: attach.c,v 1.57 2007/03/27 21:47:07 drh Exp $
+** $Id: attach.c,v 1.58 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
@@ -90,7 +90,8 @@ static void attachFunc(
goto attach_error;
}
if( !db->autoCommit ){
- strcpy(zErr, "cannot ATTACH database within transaction");
+ sqlite3_snprintf(sizeof(zErr), zErr,
+ "cannot ATTACH database within transaction");
goto attach_error;
}
for(i=0; i<db->nDb; i++){
@@ -130,7 +131,7 @@ static void attachFunc(
if( !aNew->pSchema ){
rc = SQLITE_NOMEM;
}else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){
- strcpy(zErr,
+ sqlite3_snprintf(sizeof(zErr), zErr,
"attached databases must use the same text encoding as main database");
goto attach_error;
}
@@ -246,7 +247,8 @@ static void detachFunc(
goto detach_error;
}
if( !db->autoCommit ){
- strcpy(zErr, "cannot DETACH database within transaction");
+ sqlite3_snprintf(sizeof(zErr), zErr,
+ "cannot DETACH database within transaction");
goto detach_error;
}
if( sqlite3BtreeIsInReadTrans(pDb->pBt) ){
diff --git a/src/btree.c b/src/btree.c
index 7a786602e..cfdb91813 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.372 2007/05/04 12:05:56 danielk1977 Exp $
+** $Id: btree.c,v 1.373 2007/05/04 13:15:56 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -6237,7 +6237,7 @@ static int btreePageDump(BtShared *pBt, int pgno, int recursive, MemPage *pParen
pCell = &data[addr];
parseCellPtr(pPage, pCell, &info);
sz = info.nSize;
- sprintf(range,"%d..%d", addr, addr+sz-1);
+ sqlite3_snprintf(sizeof(range),range,"%d..%d", addr, addr+sz-1);
if( pPage->leaf ){
child = 0;
}else{
@@ -6264,7 +6264,7 @@ static int btreePageDump(BtShared *pBt, int pgno, int recursive, MemPage *pParen
idx = get2byte(&data[hdr+1]);
while( idx>0 && idx<pPage->pBt->usableSize ){
int sz = get2byte(&data[idx+2]);
- sprintf(range,"%d..%d", idx, idx+sz-1);
+ sqlite3_snprintf(sizeof(range),range,"%d..%d", idx, idx+sz-1);
nFree += sz;
sqlite3DebugPrintf("freeblock %2d: i=%-10s size=%-4d total=%d\n",
i, range, sz, nFree);
@@ -6579,7 +6579,7 @@ static int checkTreePage(
char zContext[100];
char *hit;
- sprintf(zContext, "Page %d: ", iPage);
+ sqlite3_snprintf(sizeof(zContext), zContext, "Page %d: ", iPage);
/* Check that the page exists
*/
@@ -6608,7 +6608,8 @@ static int checkTreePage(
/* Check payload overflow pages
*/
- sprintf(zContext, "On tree page %d cell %d: ", iPage, i);
+ sqlite3_snprintf(sizeof(zContext), zContext,
+ "On tree page %d cell %d: ", iPage, i);
pCell = findCell(pPage,i);
parseCellPtr(pPage, pCell, &info);
sz = info.nData;
@@ -6643,7 +6644,8 @@ static int checkTreePage(
}
if( !pPage->leaf ){
pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);
- sprintf(zContext, "On page %d at right child: ", iPage);
+ sqlite3_snprintf(sizeof(zContext), zContext,
+ "On page %d at right child: ", iPage);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pBt->autoVacuum ){
checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, 0);
diff --git a/src/build.c b/src/build.c
index d3ecf4f67..11e01fbab 100644
--- a/src/build.c
+++ b/src/build.c
@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
-** $Id: build.c,v 1.422 2007/04/26 14:42:36 danielk1977 Exp $
+** $Id: build.c,v 1.423 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1322,22 +1322,24 @@ static char *createTableStmt(Table *p, int isTemp){
n += 35 + 6*p->nCol;
zStmt = sqliteMallocRaw( n );
if( zStmt==0 ) return 0;
- strcpy(zStmt, !OMIT_TEMPDB&&isTemp ? "CREATE TEMP TABLE ":"CREATE TABLE ");
+ sqlite3_snprintf(n, zStmt,
+ !OMIT_TEMPDB&&isTemp ? "CREATE TEMP TABLE ":"CREATE TABLE ");
k = strlen(zStmt);
identPut(zStmt, &k, p->zName);
zStmt[k++] = '(';
for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
- strcpy(&zStmt[k], zSep);
+ sqlite3_snprintf(n-k, &zStmt[k], zSep);
k += strlen(&zStmt[k]);
zSep = zSep2;
identPut(zStmt, &k, pCol->zName);
if( (z = pCol->zType)!=0 ){
zStmt[k++] = ' ';
- strcpy(&zStmt[k], z);
+ assert( strlen(z)+k+1<=n );
+ sqlite3_snprintf(n-k, &zStmt[k], "%s", z);
k += strlen(z);
}
}
- strcpy(&zStmt[k], zEnd);
+ sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
return zStmt;
}
@@ -2355,7 +2357,7 @@ void sqlite3CreateIndex(
int n;
Index *pLoop;
for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
- sprintf(zBuf,"_%d",n);
+ sqlite3_snprintf(sizeof(zBuf),zBuf,"_%d",n);
zName = 0;
sqlite3SetString(&zName, "sqlite_autoindex_", pTab->zName, zBuf, (char*)0);
if( zName==0 ) goto exit_create_index;
@@ -2420,7 +2422,7 @@ void sqlite3CreateIndex(
pIndex->aSortOrder = (u8 *)(&pIndex->aiRowEst[nCol+1]);
pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]);
zExtra = (char *)(&pIndex->zName[nName+1]);
- strcpy(pIndex->zName, zName);
+ memcpy(pIndex->zName, zName, nName+1);
pIndex->pTable = pTab;
pIndex->nColumn = pList->nExpr;
pIndex->onError = onError;
@@ -2463,7 +2465,7 @@ void sqlite3CreateIndex(
if( pListItem->pExpr ){
assert( pListItem->pExpr->pColl );
zColl = zExtra;
- strcpy(zExtra, pListItem->pExpr->pColl->zName);
+ sqlite3_snprintf(nExtra, zExtra, "%s", pListItem->pExpr->pColl->zName);
zExtra += (strlen(zColl) + 1);
}else{
zColl = pTab->aCol[j].zColl;
diff --git a/src/date.c b/src/date.c
index 5ff404589..0f0522604 100644
--- a/src/date.c
+++ b/src/date.c
@@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: date.c,v 1.63 2007/04/25 18:23:53 drh Exp $
+** $Id: date.c,v 1.64 2007/05/04 13:15:56 drh Exp $
**
** NOTES:
**
@@ -705,8 +705,8 @@ static void datetimeFunc(
if( isDate(argc, argv, &x)==0 ){
char zBuf[100];
computeYMD_HMS(&x);
- sprintf(zBuf, "%04d-%02d-%02d %02d:%02d:%02d",x.Y, x.M, x.D, x.h, x.m,
- (int)(x.s));
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
+ x.Y, x.M, x.D, x.h, x.m, (int)(x.s));
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
}
}
@@ -725,7 +725,7 @@ static void timeFunc(
if( isDate(argc, argv, &x)==0 ){
char zBuf[100];
computeHMS(&x);
- sprintf(zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
}
}
@@ -744,7 +744,7 @@ static void dateFunc(
if( isDate(argc, argv, &x)==0 ){
char zBuf[100];
computeYMD(&x);
- sprintf(zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
}
}
@@ -826,7 +826,7 @@ static void strftimeFunc(
}else{
i++;
switch( zFmt[i] ){
- case 'd': sprintf(&z[j],"%02d",x.D); j+=2; break;
+ case 'd': sqlite3_snprintf(3, &z[j],"%02d",x.D); j+=2; break;
case 'f': {
double s = x.s;
if( s>59.999 ) s = 59.999;
@@ -834,7 +834,7 @@ static void strftimeFunc(
j += strlen(&z[j]);
break;
}
- case 'H': sprintf(&z[j],"%02d",x.h); j+=2; break;
+ case 'H': sqlite3_snprintf(3, &z[j],"%02d",x.h); j+=2; break;
case 'W': /* Fall thru */
case 'j': {
int nDay; /* Number of days since 1st day of year */
@@ -847,25 +847,30 @@ static void strftimeFunc(
if( zFmt[i]=='W' ){
int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */
wd = ((int)(x.rJD+0.5)) % 7;
- sprintf(&z[j],"%02d",(nDay+7-wd)/7);
+ sqlite3_snprintf(3, &z[j],"%02d",(nDay+7-wd)/7);
j += 2;
}else{
- sprintf(&z[j],"%03d",nDay+1);
+ sqlite3_snprintf(4, &z[j],"%03d",nDay+1);
j += 3;
}
break;
}
- case 'J': sprintf(&z[j],"%.16g",x.rJD); j+=strlen(&z[j]); break;
- case 'm': sprintf(&z[j],"%02d",x.M); j+=2; break;
- case 'M': sprintf(&z[j],"%02d",x.m); j+=2; break;
+ case 'J': {
+ sqlite3_snprintf(20, &z[j],"%.16g",x.rJD);
+ j+=strlen(&z[j]);
+ break;
+ }
+ case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break;
+ case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break;
case 's': {
- sprintf(&z[j],"%d",(int)((x.rJD-2440587.5)*86400.0 + 0.5));
+ sqlite3_snprintf(30,&z[j],"%d",
+ (int)((x.rJD-2440587.5)*86400.0 + 0.5));
j += strlen(&z[j]);
break;
}
- case 'S': sprintf(&z[j],"%02d",(int)x.s); j+=2; break;
+ case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
case 'w': z[j++] = (((int)(x.rJD+1.5)) % 7) + '0'; break;
- case 'Y': sprintf(&z[j],"%04d",x.Y); j+=strlen(&z[j]); break;
+ case 'Y': sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=strlen(&z[j]);break;
case '%': z[j++] = '%'; break;
}
}
diff --git a/src/func.c b/src/func.c
index c3279b4fe..5e4b418d5 100644
--- a/src/func.c
+++ b/src/func.c
@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.144 2007/05/02 02:08:29 drh Exp $
+** $Id: func.c,v 1.145 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -222,7 +222,7 @@ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
if( z2 ){
z1 = sqlite3_malloc(n+1);
if( z1 ){
- strcpy(z1, z2);
+ memcpy(z1, z2, n+1);
for(i=0; z1[i]; i++){
z1[i] = toupper(z1[i]);
}
@@ -240,7 +240,7 @@ static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
if( z2 ){
z1 = sqlite3_malloc(n+1);
if( z1 ){
- strcpy(z1, z2);
+ memcpy(z1, z2, n+1);
for(i=0; z1[i]; i++){
z1[i] = tolower(z1[i]);
}
diff --git a/src/insert.c b/src/insert.c
index 2bb70fc0c..f18f55ceb 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.185 2007/04/18 14:24:33 danielk1977 Exp $
+** $Id: insert.c,v 1.186 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
@@ -1122,25 +1122,26 @@ void sqlite3GenerateConstraintChecks(
case OE_Fail: {
int j, n1, n2;
char zErrMsg[200];
- strcpy(zErrMsg, pIdx->nColumn>1 ? "columns " : "column ");
+ sqlite3_snprintf(sizeof(zErrMsg), zErrMsg,
+ pIdx->nColumn>1 ? "columns " : "column ");
n1 = strlen(zErrMsg);
for(j=0; j<pIdx->nColumn && n1<sizeof(zErrMsg)-30; j++){
char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
n2 = strlen(zCol);
if( j>0 ){
- strcpy(&zErrMsg[n1], ", ");
+ sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1], ", ");
n1 += 2;
}
if( n1+n2>sizeof(zErrMsg)-30 ){
- strcpy(&zErrMsg[n1], "...");
+ sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1], "...");
n1 += 3;
break;
}else{
- strcpy(&zErrMsg[n1], zCol);
+ sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1], "%s", zCol);
n1 += n2;
}
}
- strcpy(&zErrMsg[n1],
+ sqlite3_snprintf(sizeof(zErrMsg)-n1, &zErrMsg[n1],
pIdx->nColumn>1 ? " are not unique" : " is not unique");
sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError, zErrMsg, 0);
break;
diff --git a/src/legacy.c b/src/legacy.c
index a64166342..8d96b1e58 100644
--- a/src/legacy.c
+++ b/src/legacy.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: legacy.c,v 1.17 2007/04/25 11:28:17 drh Exp $
+** $Id: legacy.c,v 1.18 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
@@ -118,9 +118,10 @@ exec_out:
rc = sqlite3ApiExit(0, rc);
if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){
- *pzErrMsg = sqlite3_malloc(1+strlen(sqlite3_errmsg(db)));
+ int nErrMsg = 1 + strlen(sqlite3_errmsg(db));
+ *pzErrMsg = sqlite3_malloc(nErrMsg);
if( *pzErrMsg ){
- strcpy(*pzErrMsg, sqlite3_errmsg(db));
+ memcpy(*pzErrMsg, sqlite3_errmsg(db), nErrMsg);
}
}else if( pzErrMsg ){
*pzErrMsg = 0;
diff --git a/src/os_unix.c b/src/os_unix.c
index 281348b79..4d0b61798 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -959,7 +959,7 @@ int sqlite3UnixTempFileName(char *zBuf){
break;
}
do{
- sprintf(zBuf, "%s/"TEMP_FILE_PREFIX, zDir);
+ sqlite3_snprintf(SQLITE_TEMPNAME_SIZE, zBuf, "%s/"TEMP_FILE_PREFIX, zDir);
j = strlen(zBuf);
sqlite3Randomness(15, &zBuf[j]);
for(i=0; i<15; i++, j++){
@@ -2518,33 +2518,40 @@ static int allocateUnixFile(
}else{
*pNew = f;
switch(lockingStyle) {
- case afpLockingStyle:
+ case afpLockingStyle: {
/* afp locking uses the file path so it needs to be included in
** the afpLockingContext */
+ int nFilename;
pNew->pMethod = &sqlite3AFPLockingUnixIoMethod;
pNew->lockingContext =
sqlite3ThreadSafeMalloc(sizeof(afpLockingContext));
+ nFilename = strlen(zFilename)+1;
((afpLockingContext *)pNew->lockingContext)->filePath =
- sqlite3ThreadSafeMalloc(strlen(zFilename) + 1);
- strcpy(((afpLockingContext *)pNew->lockingContext)->filePath,
- zFilename);
+ sqlite3ThreadSafeMalloc(nFilename);
+ memcpy(((afpLockingContext *)pNew->lockingContext)->filePath,
+ zFilename, nFilename);
srandomdev();
break;
+ }
case flockLockingStyle:
/* flock locking doesn't need additional lockingContext information */
pNew->pMethod = &sqlite3FlockLockingUnixIoMethod;
break;
- case dotlockLockingStyle:
+ case dotlockLockingStyle: {
/* dotlock locking uses the file path so it needs to be included in
** the dotlockLockingContext */
+ int nFilename;
pNew->pMethod = &sqlite3DotlockLockingUnixIoMethod;
pNew->lockingContext = sqlite3ThreadSafeMalloc(
sizeof(dotlockLockingContext));
+ nFilename = strlen(zFilename) + 6;
((dotlockLockingContext *)pNew->lockingContext)->lockPath =
- sqlite3ThreadSafeMalloc(strlen(zFilename) + strlen(".lock") + 1);
- sprintf(((dotlockLockingContext *)pNew->lockingContext)->lockPath,
+ sqlite3ThreadSafeMalloc( nFilename );
+ sqlite3_snprintf(nFilename,
+ ((dotlockLockingContext *)pNew->lockingContext)->lockPath,
"%s.lock", zFilename);
break;
+ }
case posixLockingStyle:
/* posix locking doesn't need additional lockingContext information */
pNew->pMethod = &sqlite3UnixIoMethod;
diff --git a/src/os_win.c b/src/os_win.c
index b15de0334..a61b71a4d 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -946,7 +946,7 @@ int sqlite3WinTempFileName(char *zBuf){
for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
zTempPath[i] = 0;
for(;;){
- sprintf(zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath);
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath);
j = strlen(zBuf);
sqlite3Randomness(15, &zBuf[j]);
for(i=0; i<15; i++, j++){
diff --git a/src/pager.c b/src/pager.c
index eb9ccb458..e9c0f408f 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.334 2007/05/04 12:01:03 drh Exp $
+** @(#) $Id: pager.c,v 1.335 2007/05/04 13:15:56 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -1736,14 +1736,14 @@ int sqlite3PagerOpen(
pPager->zFilename = (char*)&pPager[1];
pPager->zDirectory = &pPager->zFilename[nameLen+1];
pPager->zJournal = &pPager->zDirectory[nameLen+1];
- strcpy(pPager->zFilename, zFullPathname);
- strcpy(pPager->zDirectory, zFullPathname);
+ memcpy(pPager->zFilename, zFullPathname, nameLen+1);
+ memcpy(pPager->zDirectory, zFullPathname, nameLen+1);
for(i=nameLen; i>0 && pPager->zDirectory[i-1]!='/'; i--){}
if( i>0 ) pPager->zDirectory[i-1] = 0;
- strcpy(pPager->zJournal, zFullPathname);
+ memcpy(pPager->zJournal, zFullPathname,nameLen);
sqliteFree(zFullPathname);
- strcpy(&pPager->zJournal[nameLen], "-journal");
+ memcpy(&pPager->zJournal[nameLen], "-journal",sizeof("-journal"));
pPager->fd = fd;
/* pPager->journalOpen = 0; */
pPager->useJournal = useJournal && !memDb;
diff --git a/src/select.c b/src/select.c
index ed524c2e7..6e962292e 100644
--- a/src/select.c
+++ b/src/select.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.339 2007/05/03 13:02:27 drh Exp $
+** $Id: select.c,v 1.340 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
@@ -1012,7 +1012,7 @@ static void generateColumnNames(
}else{
char zName[30];
assert( p->op!=TK_COLUMN || pTabList==0 );
- sprintf(zName, "column%d", i+1);
+ sqlite3_snprintf(sizeof(zName), zName, "column%d", i+1);
sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, 0);
}
}
diff --git a/src/shell.c b/src/shell.c
index 25f51d7bf..287022344 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
-** $Id: shell.c,v 1.161 2007/05/03 17:18:38 drh Exp $
+** $Id: shell.c,v 1.162 2007/05/04 13:15:56 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -833,7 +833,7 @@ static int run_schema_dump_query(
if( pzErrMsg ) sqlite3_free(*pzErrMsg);
zQ2 = malloc( len+100 );
if( zQ2==0 ) return rc;
- sprintf(zQ2, "%s ORDER BY rowid DESC", zQuery);
+ sqlite3_snprintf(sizeof(zQ2), zQ2, "%s ORDER BY rowid DESC", zQuery);
rc = sqlite3_exec(p->db, zQ2, dump_callback, p, pzErrMsg);
free(zQ2);
}
@@ -1302,10 +1302,10 @@ static int do_meta_command(char *zLine, struct callback_data *p){
p->mode = MODE_Tcl;
}else if( strncmp(azArg[1],"csv",n2)==0 ){
p->mode = MODE_Csv;
- strcpy(p->separator, ",");
+ sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
}else if( strncmp(azArg[1],"tabs",n2)==0 ){
p->mode = MODE_List;
- strcpy(p->separator, "\t");
+ sqlite3_snprintf(sizeof(p->separator), p->separator, "\t");
}else if( strncmp(azArg[1],"insert",n2)==0 ){
p->mode = MODE_Insert;
if( nArg>=3 ){
@@ -1320,7 +1320,8 @@ static int do_meta_command(char *zLine, struct callback_data *p){
}else
if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 && nArg==2 ) {
- sprintf(p->nullvalue, "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
+ sqlite3_snprintf(sizeof(p->nullvalue), p->nullvalue,
+ "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
}else
if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
@@ -1329,14 +1330,14 @@ static int do_meta_command(char *zLine, struct callback_data *p){
}
if( strcmp(azArg[1],"stdout")==0 ){
p->out = stdout;
- strcpy(p->outfile,"stdout");
+ sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
}else{
p->out = fopen(azArg[1], "wb");
if( p->out==0 ){
fprintf(stderr,"can't write to \"%s\"\n", azArg[1]);
p->out = stdout;
} else {
- strcpy(p->outfile,azArg[1]);
+ sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]);
}
}
}else
@@ -1428,7 +1429,8 @@ static int do_meta_command(char *zLine, struct callback_data *p){
}else
if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){
- sprintf(p->separator, "%.*s", (int)ArraySize(p->separator)-1, azArg[1]);
+ sqlite3_snprintf(sizeof(p->separator), p->separator,
+ "%.*s", (int)sizeof(p->separator)-1, azArg[1]);
}else
if( c=='s' && strncmp(azArg[0], "show", n)==0){
@@ -1621,7 +1623,7 @@ static int process_input(struct callback_data *p, FILE *in){
continue;
}
if( _is_command_terminator(zLine) ){
- strcpy(zLine,";");
+ memcpy(zLine,";",2);
}
if( zSql==0 ){
int i;
@@ -1633,7 +1635,7 @@ static int process_input(struct callback_data *p, FILE *in){
fprintf(stderr, "out of memory\n");
exit(1);
}
- strcpy(zSql, zLine);
+ memcpy(zSql, zLine, nSql+1);
startline = lineno;
}
}else{
@@ -1643,8 +1645,8 @@ static int process_input(struct callback_data *p, FILE *in){
fprintf(stderr,"%s: out of memory!\n", Argv0);
exit(1);
}
- strcpy(&zSql[nSql++], "\n");
- strcpy(&zSql[nSql], zLine);
+ zSql[nSql++] = '\n';
+ memcpy(&zSql[nSql], zLine, len+1);
nSql += len;
}
free(zLine);
@@ -1655,9 +1657,10 @@ static int process_input(struct callback_data *p, FILE *in){
if( rc || zErrMsg ){
char zPrefix[100];
if( in!=0 || !stdin_is_interactive ){
- sprintf(zPrefix, "SQL error near line %d:", startline);
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
+ "SQL error near line %d:", startline);
}else{
- sprintf(zPrefix, "SQL error:");
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "SQL error:");
}
if( zErrMsg!=0 ){
printf("%s %s\n", zPrefix, zErrMsg);
@@ -1730,8 +1733,9 @@ static char *find_home_dir(void){
#endif
if( home_dir ){
- char *z = malloc( strlen(home_dir)+1 );
- if( z ) strcpy(z, home_dir);
+ int n = strlen(home_dir) + 1;
+ char *z = malloc( n );
+ if( z ) memcpy(z, home_dir, n);
home_dir = z;
}
@@ -1762,7 +1766,7 @@ static void process_sqliterc(
fprintf(stderr,"%s: out of memory!\n", Argv0);
exit(1);
}
- sprintf(zBuf,"%s/.sqliterc",home_dir);
+ sqlite3_snprintf(sizeof(zBuf), zBuf,"%s/.sqliterc",home_dir);
free(home_dir);
sqliterc = (const char*)zBuf;
}
@@ -1816,10 +1820,10 @@ static void usage(int showDetail){
static void main_init(struct callback_data *data) {
memset(data, 0, sizeof(*data));
data->mode = MODE_List;
- strcpy(data->separator,"|");
+ memcpy(data->separator,"|", 2);
data->showHeader = 0;
- strcpy(mainPrompt,"sqlite> ");
- strcpy(continuePrompt," ...> ");
+ sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
+ sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
}
int main(int argc, char **argv){
@@ -1917,13 +1921,15 @@ int main(int argc, char **argv){
data.mode = MODE_Column;
}else if( strcmp(z,"-csv")==0 ){
data.mode = MODE_Csv;
- strcpy(data.separator,",");
+ memcpy(data.separator,",",2);
}else if( strcmp(z,"-separator")==0 ){
i++;
- sprintf(data.separator,"%.*s",(int)sizeof(data.separator)-1,argv[i]);
+ sqlite3_snprintf(sizeof(data.separator), data.separator,
+ "%.*s",(int)sizeof(data.separator)-1,argv[i]);
}else if( strcmp(z,"-nullvalue")==0 ){
i++;
- sprintf(data.nullvalue,"%.*s",(int)sizeof(data.nullvalue)-1,argv[i]);
+ sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
+ "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]);
}else if( strcmp(z,"-header")==0 ){
data.showHeader = 1;
}else if( strcmp(z,"-noheader")==0 ){
@@ -1969,14 +1975,15 @@ int main(int argc, char **argv){
if( stdin_is_interactive ){
char *zHome;
char *zHistory = 0;
+ int nHistory;
printf(
"SQLite version %s\n"
"Enter \".help\" for instructions\n",
sqlite3_libversion()
);
zHome = find_home_dir();
- if( zHome && (zHistory = malloc(strlen(zHome)+20))!=0 ){
- sprintf(zHistory,"%s/.sqlite_history", zHome);
+ if( zHome && (zHistory = malloc(nHistory = strlen(zHome)+20))!=0 ){
+ sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
}
#if defined(HAVE_READLINE) && HAVE_READLINE==1
if( zHistory ) read_history(zHistory);
diff --git a/src/table.c b/src/table.c
index 30c148489..d58fb3ced 100644
--- a/src/table.c
+++ b/src/table.c
@@ -92,9 +92,10 @@ static int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){
if( argv[i]==0 ){
z = 0;
}else{
- z = sqlite3_malloc( strlen(argv[i])+1 );
+ int n = strlen(argv[i])+1;
+ z = sqlite3_malloc( n );
if( z==0 ) goto malloc_failed;
- strcpy(z, argv[i]);
+ memcpy(z, argv[i], n);
}
p->azResult[p->nData++] = z;
}
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 79429cb16..7e6f32700 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.183 2007/05/04 12:05:56 danielk1977 Exp $
+** $Id: tclsqlite.c,v 1.184 2007/05/04 13:15:56 drh Exp $
*/
#include "tcl.h"
#include <errno.h>
@@ -329,7 +329,7 @@ static int createIncrblobChannel(
p->iSeek = 0;
p->pBlob = pBlob;
- sprintf(zChannel, "incrblob_%d", ++count);
+ sqlite3_snprintf(sizeof(zChannel), zChannel, "incrblob_%d", ++count);
p->channel = Tcl_CreateChannel(&IncrblobChannelType, zChannel, p, flags);
Tcl_RegisterChannel(interp, p->channel);
@@ -470,7 +470,7 @@ static int DbBusyHandler(void *cd, int nTries){
int rc;
char zVal[30];
- sprintf(zVal, "%d", nTries);
+ sqlite3_snprintf(sizeof(zVal), zVal, "%d", nTries);
rc = Tcl_VarEval(pDb->interp, pDb->zBusy, " ", zVal, (char*)0);
if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){
return 0;
@@ -979,7 +979,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zAuth = Tcl_GetStringFromObj(objv[2], &len);
if( zAuth && len>0 ){
pDb->zAuth = Tcl_Alloc( len + 1 );
- strcpy(pDb->zAuth, zAuth);
+ memcpy(pDb->zAuth, zAuth, len+1);
}else{
pDb->zAuth = 0;
}
@@ -1016,7 +1016,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zBusy = Tcl_GetStringFromObj(objv[2], &len);
if( zBusy && len>0 ){
pDb->zBusy = Tcl_Alloc( len + 1 );
- strcpy(pDb->zBusy, zBusy);
+ memcpy(pDb->zBusy, zBusy, len+1);
}else{
pDb->zBusy = 0;
}
@@ -1128,7 +1128,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
pCollate->pNext = pDb->pCollate;
pCollate->zScript = (char*)&pCollate[1];
pDb->pCollate = pCollate;
- strcpy(pCollate->zScript, zScript);
+ memcpy(pCollate->zScript, zScript, nScript+1);
if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8,
pCollate, tclSqlCollate) ){
Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE);
@@ -1181,7 +1181,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zCommit = Tcl_GetStringFromObj(objv[2], &len);
if( zCommit && len>0 ){
pDb->zCommit = Tcl_Alloc( len + 1 );
- strcpy(pDb->zCommit, zCommit);
+ memcpy(pDb->zCommit, zCommit, len+1);
}else{
pDb->zCommit = 0;
}
@@ -1359,9 +1359,10 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
}
if( i+1!=nCol ){
char *zErr;
- zErr = malloc(200 + strlen(zFile));
+ int nErr = strlen(zFile) + 200;
+ zErr = malloc(nErr);
if( zErr ){
- sprintf(zErr,
+ sqlite3_snprintf(nErr, zErr,
"Error: %s line %d: expected %d columns of data but found %d",
zFile, lineno, nCol, i+1);
Tcl_AppendResult(interp, zErr, 0);
@@ -1399,7 +1400,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
rc = TCL_OK;
}else{
/* failure, append lineno where failed */
- sprintf(zLineNum,"%d",lineno);
+ sqlite3_snprintf(sizeof(zLineNum), zLineNum,"%d",lineno);
Tcl_AppendResult(interp,", failed while processing line: ",zLineNum,0);
rc = TCL_ERROR;
}
@@ -1979,7 +1980,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zProgress = Tcl_GetStringFromObj(objv[3], &len);
if( zProgress && len>0 ){
pDb->zProgress = Tcl_Alloc( len + 1 );
- strcpy(pDb->zProgress, zProgress);
+ memcpy(pDb->zProgress, zProgress, len+1);
}else{
pDb->zProgress = 0;
}
@@ -2021,7 +2022,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zProfile = Tcl_GetStringFromObj(objv[2], &len);
if( zProfile && len>0 ){
pDb->zProfile = Tcl_Alloc( len + 1 );
- strcpy(pDb->zProfile, zProfile);
+ memcpy(pDb->zProfile, zProfile, len+1);
}else{
pDb->zProfile = 0;
}
@@ -2116,7 +2117,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
zTrace = Tcl_GetStringFromObj(objv[2], &len);
if( zTrace && len>0 ){
pDb->zTrace = Tcl_Alloc( len + 1 );
- strcpy(pDb->zTrace, zTrace);
+ memcpy(pDb->zTrace, zTrace, len+1);
}else{
pDb->zTrace = 0;
}
diff --git a/src/util.c b/src/util.c
index b83fd9472..190832908 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.199 2007/04/06 02:32:34 drh Exp $
+** $Id: util.c,v 1.200 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -424,7 +424,7 @@ int sqlite3OutstandingMallocs(Tcl_Interp *interp){
z = &zAlloc[TESTALLOC_OFFSET_STACK(p)];
for(i=0; i<TESTALLOC_STACKFRAMES; i++){
char zHex[128];
- sprintf(zHex, "%p", ((void **)z)[i]);
+ sqlite3_snprintf(sizeof(zHex), zHex, "%p", ((void **)z)[i]);
Tcl_ListObjAppendElement(0, pStack, Tcl_NewStringObj(zHex, -1));
}
@@ -722,9 +722,11 @@ int sqlite3AllocSize(void *p){
*/
char *sqlite3StrDup(const char *z){
char *zNew;
+ int n;
if( z==0 ) return 0;
- zNew = sqlite3MallocRaw(strlen(z)+1, 1);
- if( zNew ) strcpy(zNew, z);
+ n = strlen(z)+1;
+ zNew = sqlite3MallocRaw(n, 1);
+ if( zNew ) memcpy(zNew, z, n);
return zNew;
}
char *sqlite3StrNDup(const char *z, int n){
@@ -766,9 +768,11 @@ void sqlite3SetString(char **pz, ...){
*zResult = 0;
va_start(ap, pz);
while( (z = va_arg(ap, const char*))!=0 ){
- strcpy(zResult, z);
- zResult += strlen(zResult);
+ int n = strlen(z);
+ memcpy(zResult, z, n);
+ zResult += n;
}
+ zResult[0] = 0;
va_end(ap);
}
diff --git a/src/vdbe.c b/src/vdbe.c
index 12aedc51b..83197c426 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.605 2007/05/02 16:51:59 drh Exp $
+** $Id: vdbe.c,v 1.606 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -319,10 +319,13 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
c = 's';
}
- zCsr += sprintf(zCsr, "%c", c);
- zCsr += sprintf(zCsr, "%d[", pMem->n);
+ sqlite3_snprintf(100, zCsr, "%c", c);
+ zCsr += strlen(zCsr);
+ sqlite3_snprintf(100, zCsr, "%d[", pMem->n);
+ zCsr += strlen(zCsr);
for(i=0; i<16 && i<pMem->n; i++){
- zCsr += sprintf(zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
+ sqlite3_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
+ zCsr += strlen(zCsr);
}
for(i=0; i<16 && i<pMem->n; i++){
char z = pMem->z[i];
@@ -330,9 +333,11 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
else *zCsr++ = z;
}
- zCsr += sprintf(zCsr, "]");
+ sqlite3_snprintf(100, zCsr, "]");
+ zCsr += strlen(zCsr);
if( f & MEM_Zero ){
- zCsr += sprintf(zCsr,"+%lldz",pMem->u.i);
+ sqlite3_snprintf(100, zCsr,"+%lldz",pMem->u.i);
+ zCsr += strlen(zCsr);
}
*zCsr = '\0';
}else if( f & MEM_Str ){
@@ -351,7 +356,8 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
zBuf[1] = 's';
}
k = 2;
- k += sprintf(&zBuf[k], "%d", pMem->n);
+ sqlite3_snprintf(100, &zBuf[k], "%d", pMem->n);
+ k += strlen(&zBuf[k]);
zBuf[k++] = '[';
for(j=0; j<15 && j<pMem->n; j++){
u8 c = pMem->z[j];
@@ -362,7 +368,8 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
}
}
zBuf[k++] = ']';
- k += sprintf(&zBuf[k], encnames[pMem->enc]);
+ sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);
+ k += strlen(&zBuf[k]);
zBuf[k++] = 0;
}
}
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 7cc44306e..113465518 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -589,24 +589,24 @@ static char *displayP3(Op *pOp, char *zTemp, int nTemp){
case P3_KEYINFO: {
int i, j;
KeyInfo *pKeyInfo = (KeyInfo*)pOp->p3;
- sprintf(zTemp, "keyinfo(%d", pKeyInfo->nField);
+ sqlite3_snprintf(nTemp, zTemp, "keyinfo(%d", pKeyInfo->nField);
i = strlen(zTemp);
for(j=0; j<pKeyInfo->nField; j++){
CollSeq *pColl = pKeyInfo->aColl[j];
if( pColl ){
int n = strlen(pColl->zName);
if( i+n>nTemp-6 ){
- strcpy(&zTemp[i],",...");
+ memcpy(&zTemp[i],",...",4);
break;
}
zTemp[i++] = ',';
if( pKeyInfo->aSortOrder && pKeyInfo->aSortOrder[j] ){
zTemp[i++] = '-';
}
- strcpy(&zTemp[i], pColl->zName);
+ memcpy(&zTemp[i], pColl->zName,n+1);
i += n;
}else if( i+4<nTemp-6 ){
- strcpy(&zTemp[i],",nil");
+ memcpy(&zTemp[i],",nil",4);
i += 4;
}
}
@@ -618,7 +618,7 @@ static char *displayP3(Op *pOp, char *zTemp, int nTemp){
}
case P3_COLLSEQ: {
CollSeq *pColl = (CollSeq*)pOp->p3;
- sprintf(zTemp, "collseq(%.20s)", pColl->zName);
+ sqlite3_snprintf(nTemp, zTemp, "collseq(%.20s)", pColl->zName);
zP3 = zTemp;
break;
}
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index 9fbdca71a..22e6d2da1 100644
--- a/src/vdbeblob.c
+++ b/src/vdbeblob.c
@@ -10,7 +10,7 @@
**
*************************************************************************
**
-** $Id: vdbeblob.c,v 1.6 2007/05/04 12:05:56 danielk1977 Exp $
+** $Id: vdbeblob.c,v 1.7 2007/05/04 13:15:57 drh Exp $
*/
#include "sqliteInt.h"
@@ -83,8 +83,9 @@ int sqlite3_blob_open(
Vdbe *v = 0;
int rc = SQLITE_OK;
- char zErr[128] = {0};
+ char zErr[128];
+ zErr[0] = 0;
do {
Parse sParse;
Table *pTab;
@@ -131,7 +132,8 @@ int sqlite3_blob_open(
int j;
for(j=0; j<pIdx->nColumn; j++){
if( pIdx->aiColumn[j]==iCol ){
- strcpy(zErr, "cannot open indexed column for writing");
+ sqlite3_snprintf(sizeof(zErr), zErr,
+ "cannot open indexed column for writing");
rc = SQLITE_ERROR;
sqlite3SafetyOff(db);
goto blob_open_out;
diff --git a/src/vtab.c b/src/vtab.c
index 4b885b624..940c86e30 100644
--- a/src/vtab.c
+++ b/src/vtab.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to help implement virtual tables.
**
-** $Id: vtab.c,v 1.45 2007/04/19 14:48:37 danielk1977 Exp $
+** $Id: vtab.c,v 1.46 2007/05/04 13:15:57 drh Exp $
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE
#include "sqliteInt.h"
@@ -29,7 +29,7 @@ int sqlite3_create_module(
Module *pMod = (Module *)sqliteMallocRaw(sizeof(Module) + nName + 1);
if( pMod ){
char *zCopy = (char *)(&pMod[1]);
- strcpy(zCopy, zName);
+ memcpy(zCopy, zName, nName+1);
pMod->zName = zCopy;
pMod->pModule = pModule;
pMod->pAux = pAux;
@@ -705,7 +705,7 @@ FuncDef *sqlite3VtabOverloadFunction(
return pDef;
}
*pNew = *pDef;
- strcpy(pNew->zName, pDef->zName);
+ memcpy(pNew->zName, pDef->zName, strlen(pDef->zName)+1);
pNew->xFunc = xFunc;
pNew->pUserData = pArg;
pNew->flags |= SQLITE_FUNC_EPHEM;
diff --git a/src/where.c b/src/where.c
index 2737b150a..dabce68b5 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.247 2007/04/20 12:22:02 drh Exp $
+** $Id: where.c,v 1.248 2007/05/04 13:15:57 drh Exp $
*/
#include "sqliteInt.h"
@@ -2605,24 +2605,24 @@ WhereInfo *sqlite3WhereBegin(
n = strlen(z);
if( n+nQPlan < sizeof(sqlite3_query_plan)-10 ){
if( pLevel->flags & WHERE_IDX_ONLY ){
- strcpy(&sqlite3_query_plan[nQPlan], "{}");
+ memcpy(&sqlite3_query_plan[nQPlan], "{}", 2);
nQPlan += 2;
}else{
- strcpy(&sqlite3_query_plan[nQPlan], z);
+ memcpy(&sqlite3_query_plan[nQPlan], z, n);
nQPlan += n;
}
sqlite3_query_plan[nQPlan++] = ' ';
}
if( pLevel->flags & (WHERE_ROWID_EQ|WHERE_ROWID_RANGE) ){
- strcpy(&sqlite3_query_plan[nQPlan], "* ");
+ memcpy(&sqlite3_query_plan[nQPlan], "* ", 2);
nQPlan += 2;
}else if( pLevel->pIdx==0 ){
- strcpy(&sqlite3_query_plan[nQPlan], "{} ");
+ memcpy(&sqlite3_query_plan[nQPlan], "{} ", 3);
nQPlan += 3;
}else{
n = strlen(pLevel->pIdx->zName);
if( n+nQPlan < sizeof(sqlite3_query_plan)-2 ){
- strcpy(&sqlite3_query_plan[nQPlan], pLevel->pIdx->zName);
+ memcpy(&sqlite3_query_plan[nQPlan], pLevel->pIdx->zName, n);
nQPlan += n;
sqlite3_query_plan[nQPlan++] = ' ';
}