Completely rework the sqlite3SetString() primitive so that it honors the
SQLITE_LIMIT_LENGTH and avoids the use of strlen(). (CVS 5374) FossilOrigin-Name: 8ed04b1e26a55306e4baf3e93fb084514134d603
This commit is contained in:
+8
-8
@@ -5,7 +5,7 @@
|
||||
** an historical reference. Most of the "enhancements" have been backed
|
||||
** out so that the functionality is now the same as standard printf().
|
||||
**
|
||||
** $Id: printf.c,v 1.87 2008/06/16 20:51:16 drh Exp $
|
||||
** $Id: printf.c,v 1.88 2008/07/08 19:34:07 drh Exp $
|
||||
**
|
||||
**************************************************************************
|
||||
**
|
||||
@@ -221,7 +221,7 @@ static void appendSpace(StrAccum *pAccum, int N){
|
||||
** seems to make a big difference in determining how fast this beast
|
||||
** will run.
|
||||
*/
|
||||
static void vxprintf(
|
||||
void sqlite3VXPrintf(
|
||||
StrAccum *pAccum, /* Accumulate results here */
|
||||
int useExtended, /* Allow extended %-conversions */
|
||||
const char *fmt, /* Format string */
|
||||
@@ -794,14 +794,14 @@ char *sqlite3StrAccumFinish(StrAccum *p){
|
||||
void sqlite3StrAccumReset(StrAccum *p){
|
||||
if( p->zText!=p->zBase ){
|
||||
sqlite3_free(p->zText);
|
||||
p->zText = 0;
|
||||
}
|
||||
p->zText = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize a string accumulator
|
||||
*/
|
||||
static void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
|
||||
void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
|
||||
p->zText = p->zBase = zBase;
|
||||
p->nChar = 0;
|
||||
p->nAlloc = n;
|
||||
@@ -821,7 +821,7 @@ char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
|
||||
StrAccum acc;
|
||||
sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
|
||||
db ? db->aLimit[SQLITE_LIMIT_LENGTH] : SQLITE_MAX_LENGTH);
|
||||
vxprintf(&acc, 1, zFormat, ap);
|
||||
sqlite3VXPrintf(&acc, 1, zFormat, ap);
|
||||
z = sqlite3StrAccumFinish(&acc);
|
||||
if( acc.mallocFailed && db ){
|
||||
db->mallocFailed = 1;
|
||||
@@ -852,7 +852,7 @@ char *sqlite3_vmprintf(const char *zFormat, va_list ap){
|
||||
StrAccum acc;
|
||||
sqlite3_initialize();
|
||||
sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
|
||||
vxprintf(&acc, 0, zFormat, ap);
|
||||
sqlite3VXPrintf(&acc, 0, zFormat, ap);
|
||||
z = sqlite3StrAccumFinish(&acc);
|
||||
return z;
|
||||
}
|
||||
@@ -888,7 +888,7 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
|
||||
sqlite3StrAccumInit(&acc, zBuf, n, 0);
|
||||
acc.useMalloc = 0;
|
||||
va_start(ap,zFormat);
|
||||
vxprintf(&acc, 0, zFormat, ap);
|
||||
sqlite3VXPrintf(&acc, 0, zFormat, ap);
|
||||
va_end(ap);
|
||||
z = sqlite3StrAccumFinish(&acc);
|
||||
return z;
|
||||
@@ -907,7 +907,7 @@ void sqlite3DebugPrintf(const char *zFormat, ...){
|
||||
sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
|
||||
acc.useMalloc = 0;
|
||||
va_start(ap,zFormat);
|
||||
vxprintf(&acc, 0, zFormat, ap);
|
||||
sqlite3VXPrintf(&acc, 0, zFormat, ap);
|
||||
va_end(ap);
|
||||
sqlite3StrAccumFinish(&acc);
|
||||
fprintf(stdout,"%s", zBuf);
|
||||
|
||||
Reference in New Issue
Block a user