1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-22 22:13:04 +03:00

Add new APIs that take 64-bit length parameters: sqlite3_malloc64(),

sqlite3_realloc64(), sqlite3_bind_blob64(), sqlite3_bind_text64(),
sqlite3_result_blob64(), and sqlite3_result_text64().
Add the sqlite3_msize() interface.
Internal memory allocation routines now use 64-bit unsigned
length parameters for safety.
Fix the sqlite3_get_table() to use sqlite3_realloc64() to avoid
a integer overflow problem.

FossilOrigin-Name: 7e4978c003867d1b532b69221013dda75ca61953
This commit is contained in:
drh
2014-09-11 18:44:04 +00:00
12 changed files with 243 additions and 67 deletions

View File

@@ -325,13 +325,14 @@ static void substrFunc(
for(z2=z; *z2 && p2; p2--){
SQLITE_SKIP_UTF8(z2);
}
sqlite3_result_text(context, (char*)z, (int)(z2-z), SQLITE_TRANSIENT);
sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,
SQLITE_UTF8);
}else{
if( p1+p2>len ){
p2 = len-p1;
if( p2<0 ) p2 = 0;
}
sqlite3_result_blob(context, (char*)&z[p1], (int)p2, SQLITE_TRANSIENT);
sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);
}
}
@@ -390,7 +391,7 @@ static void *contextMalloc(sqlite3_context *context, i64 nByte){
sqlite3_result_error_toobig(context);
z = 0;
}else{
z = sqlite3Malloc((int)nByte);
z = sqlite3Malloc(nByte);
if( !z ){
sqlite3_result_error_nomem(context);
}
@@ -1041,7 +1042,7 @@ static void charFunc(
*zOut++ = 0x80 + (u8)(c & 0x3F);
} \
}
sqlite3_result_text(context, (char*)z, (int)(zOut-z), sqlite3_free);
sqlite3_result_text64(context, (char*)z, zOut-z, sqlite3_free, SQLITE_UTF8);
}
/*