diff options
author | drh <drh@noemail.net> | 2007-05-04 13:15:55 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-05-04 13:15:55 +0000 |
commit | 5bb3eb9b9ae6008a1e5ee6ffa9a75b1ef14d7f0f (patch) | |
tree | 95a6f87a3340c4292d0b03201c2512f567fc2cfd /src/insert.c | |
parent | 92d4d7a92e1a1e465a0d5fd3e9a42e90ddcbda4b (diff) | |
download | sqlite-5bb3eb9b9ae6008a1e5ee6ffa9a75b1ef14d7f0f.tar.gz sqlite-5bb3eb9b9ae6008a1e5ee6ffa9a75b1ef14d7f0f.zip |
Eliminate all uses of sprintf() and strcpy(). These were not being
misused. But getting rid of them removes a library dependency. And
it avoids warnings from the OpenBSD compiler. Ticket #2336. (CVS 3916)
FossilOrigin-Name: ba4845b32bdf38e623c4f7246e6e327715bbba4b
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 13 |
1 files changed, 7 insertions, 6 deletions
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; |