SQLite

Check-in [a04f9e7959]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enforce the run-time sqlite3_limit() length limit on zeroblob(), not just the compile-time SQLITE_MAX_LENGTH limit. (CVS 6433)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a04f9e7959325da18f66a1aa4ead1c50993807cb
User & Date: drh 2009-04-02 09:07:13.000
Context
2009-04-02
10:16
In the built-in SQL function implementations, improve some comments, fix an off-by-one error in detecting over-size strings, and add testcase() macros to verify that boundary values have been tested. (CVS 6434) (check-in: 868a487f5f user: drh tags: trunk)
09:07
Enforce the run-time sqlite3_limit() length limit on zeroblob(), not just the compile-time SQLITE_MAX_LENGTH limit. (CVS 6433) (check-in: a04f9e7959 user: drh tags: trunk)
2009-04-01
23:49
Increase test coverage of bitvec.c slightly. Fix the line length on a comment in bitvec.c. (CVS 6432) (check-in: ca3aa3ba7d user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/func.c.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
** This file contains the C functions that implement various SQL
** functions of SQLite.  
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.226 2009/04/01 16:33:38 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
#include <assert.h>
#include "vdbeInt.h"

/*







|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
** This file contains the C functions that implement various SQL
** functions of SQLite.  
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.227 2009/04/02 09:07:13 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
#include <assert.h>
#include "vdbeInt.h"

/*
266
267
268
269
270
271
272

273
274
275
276
277
278
279
280
281
282
283
284
285
/*
** Allocate nByte bytes of space using sqlite3_malloc(). If the
** allocation fails, call sqlite3_result_error_nomem() to notify
** the database handle that malloc() has failed.
*/
static void *contextMalloc(sqlite3_context *context, i64 nByte){
  char *z;

  if( nByte>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
    sqlite3_result_error_toobig(context);
    z = 0;
  }else{
    z = sqlite3Malloc((int)nByte);
    if( !z && nByte>0 ){
      sqlite3_result_error_nomem(context);
    }
  }
  return z;
}

/*







>





|







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
** Allocate nByte bytes of space using sqlite3_malloc(). If the
** allocation fails, call sqlite3_result_error_nomem() to notify
** the database handle that malloc() has failed.
*/
static void *contextMalloc(sqlite3_context *context, i64 nByte){
  char *z;
  assert( nByte>0 );
  if( nByte>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
    sqlite3_result_error_toobig(context);
    z = 0;
  }else{
    z = sqlite3Malloc((int)nByte);
    if( !z ){
      sqlite3_result_error_nomem(context);
    }
  }
  return z;
}

/*
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
  int argc,
  sqlite3_value **argv
){
  i64 n;
  assert( argc==1 );
  UNUSED_PARAMETER(argc);
  n = sqlite3_value_int64(argv[0]);
  if( n>SQLITE_MAX_LENGTH ){
    sqlite3_result_error_toobig(context);
  }else{
    sqlite3_result_zeroblob(context, (int)n);
  }
}

/*







|







808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
  int argc,
  sqlite3_value **argv
){
  i64 n;
  assert( argc==1 );
  UNUSED_PARAMETER(argc);
  n = sqlite3_value_int64(argv[0]);
  if( n>sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH] ){
    sqlite3_result_error_toobig(context);
  }else{
    sqlite3_result_zeroblob(context, (int)n);
  }
}

/*