Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tests to double-check that nothing within SQLite ever tries to allocate amounts of memory that are close to the maximum signed integer, leading to an integer overflow within malloc(). This is not currently a problem. The extra tests just insure it never becomes a problem. (CVS 6298) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f6ba7bb9152cffc9f67dfa7de12e36a3 |
User & Date: | drh 2009-02-17 18:37:29.000 |
Context
2009-02-18
| ||
00:00 | Version 3.6.11 (CVS 6299) (check-in: 6abd630c87 user: drh tags: trunk, release) | |
2009-02-17
| ||
18:37 | Add tests to double-check that nothing within SQLite ever tries to allocate amounts of memory that are close to the maximum signed integer, leading to an integer overflow within malloc(). This is not currently a problem. The extra tests just insure it never becomes a problem. (CVS 6298) (check-in: f6ba7bb915 user: drh tags: trunk) | |
17:56 | Initialize an uninitialized buffer to silence a valgrind warning during a VACUUM operation. (CVS 6297) (check-in: 8c61968b33 user: danielk1977 tags: trunk) | |
Changes
Changes to src/malloc.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** Memory allocation functions used throughout sqlite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** Memory allocation functions used throughout sqlite. ** ** $Id: malloc.c,v 1.56 2009/02/17 18:37:29 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> /* ** This routine runs when the memory allocator sees that the ** total memory allocation is about to exceed the soft heap |
︙ | ︙ | |||
262 263 264 265 266 267 268 | /* ** Allocate memory. This routine is like sqlite3_malloc() except that it ** assumes the memory subsystem has already been initialized. */ void *sqlite3Malloc(int n){ void *p; | | > > > > > > > > | 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | /* ** Allocate memory. This routine is like sqlite3_malloc() except that it ** assumes the memory subsystem has already been initialized. */ void *sqlite3Malloc(int n){ void *p; if( n<=0 || NEVER(n>=0x7fffff00) ){ /* The NEVER(n>=0x7fffff00) term is added out of paranoia. We want to make ** absolutely sure that there is nothing within SQLite that can cause a ** memory allocation of a number of bytes which is near the maximum signed ** integer value and thus cause an integer overflow inside of the xMalloc() ** implementation. The n>=0x7fffff00 gives us 255 bytes of headroom. The ** test should never be true because SQLITE_MAX_LENGTH should be much ** less than 0x7fffff00 and it should catch large memory allocations ** before they reach this point. */ p = 0; }else if( sqlite3GlobalConfig.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); mallocWithAlarm(n, &p); sqlite3_mutex_leave(mem0.mutex); }else{ p = sqlite3GlobalConfig.m.xMalloc(n); |
︙ | ︙ | |||
551 552 553 554 555 556 557 | */ void *sqlite3Realloc(void *pOld, int nBytes){ int nOld, nNew; void *pNew; if( pOld==0 ){ return sqlite3Malloc(nBytes); } | | > | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | */ void *sqlite3Realloc(void *pOld, int nBytes){ int nOld, nNew; void *pNew; if( pOld==0 ){ return sqlite3Malloc(nBytes); } if( nBytes<=0 || NEVER(nBytes>=0x7fffff00) ){ /* The NEVER(...) term is explained in comments on sqlite3Malloc() */ sqlite3_free(pOld); return 0; } nOld = sqlite3MallocSize(pOld); if( sqlite3GlobalConfig.bMemstat ){ sqlite3_mutex_enter(mem0.mutex); sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes); |
︙ | ︙ |