1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Return an error when parsing "?NNN" if NNN is so large it cannot be stored as a 32-bit int.

FossilOrigin-Name: fc9014be0f00d046e7ba830a644f9ce93eca5db8
This commit is contained in:
dan
2010-08-17 19:34:13 +00:00
parent 0028486b73
commit c8d735aed3
3 changed files with 11 additions and 20 deletions

View File

@@ -554,13 +554,14 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
}else if( z[0]=='?' ){
/* Wildcard of the form "?nnn". Convert "nnn" to an integer and
** use it as the variable number */
int i = atoi((char*)&z[1]);
i64 i;
int bOk = sqlite3Atoi64(&z[1], &i);
pExpr->iColumn = (ynVar)i;
testcase( i==0 );
testcase( i==1 );
testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );
testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );
if( i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
}