SQLite4
Check-in [f58fb32e42]
Not logged in

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

Overview
SHA1 Hash:f58fb32e42e2adefe7bbe0025bbdf35b21fc9f98
Date: 2012-11-22 16:14:29
User: dan
Comment:Fix some "unsafe" pointer casts in lsm_config().
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to lsm-test/lsmtest_tdb3.c

429 rc = uncompress((Bytef*)aOut, &n, (Bytef*)aIn, nIn); 429 rc = uncompress((Bytef*)aOut, &n, (Bytef*)aIn, nIn); 430 *pnOut = n; 430 *pnOut = n; 431 return (rc==Z_OK ? 0 : LSM_ERROR); 431 return (rc==Z_OK ? 0 : LSM_ERROR); 432 } 432 } 433 433 434 static int testConfigureCompression(lsm_db *pDb){ 434 static int testConfigureCompression(lsm_db *pDb){ 435 static lsm_compress zip = { 435 static lsm_compress zip = { 436 1, sizeof(lsm_compress), < 437 0, /* Context pointer (unused) */ 436 0, /* Context pointer (unused) */ > 437 1, /* Id value */ 438 testZipBound, /* xBound method */ 438 testZipBound, /* xBound method */ 439 testZipCompress, /* xCompress method */ 439 testZipCompress, /* xCompress method */ 440 testZipUncompress /* xUncompress method */ 440 testZipUncompress /* xUncompress method */ 441 }; 441 }; 442 return lsm_config(pDb, LSM_CONFIG_SET_COMPRESSION, &zip); 442 return lsm_config(pDb, LSM_CONFIG_SET_COMPRESSION, &zip); 443 } 443 } 444 #endif /* ifdef HAVE_ZLIB */ 444 #endif /* ifdef HAVE_ZLIB */

Changes to src/lsm_main.c

329 }else{ 329 }else{ 330 pDb->bMultiProc = *piVal = (*piVal!=0); 330 pDb->bMultiProc = *piVal = (*piVal!=0); 331 } 331 } 332 break; 332 break; 333 } 333 } 334 334 335 case LSM_CONFIG_SET_COMPRESSION: { 335 case LSM_CONFIG_SET_COMPRESSION: { 336 int *p = va_arg(ap, lsm_compress *); | 336 lsm_compress *p = va_arg(ap, lsm_compress *); 337 if( pDb->pDatabase ){ 337 if( pDb->pDatabase ){ 338 /* If lsm_open() has been called, this call is against the rules. */ 338 /* If lsm_open() has been called, this call is against the rules. */ 339 rc = LSM_MISUSE_BKPT; 339 rc = LSM_MISUSE_BKPT; 340 }else{ 340 }else{ 341 memcpy(&pDb->compress, p, sizeof(lsm_compress)); 341 memcpy(&pDb->compress, p, sizeof(lsm_compress)); 342 } 342 } 343 break; 343 break; 344 } 344 } 345 345 346 case LSM_CONFIG_GET_COMPRESSION: { 346 case LSM_CONFIG_GET_COMPRESSION: { 347 int *p = va_arg(ap, lsm_compress *); | 347 lsm_compress *p = va_arg(ap, lsm_compress *); 348 memcpy(p, &pDb->compress, sizeof(lsm_compress)); 348 memcpy(p, &pDb->compress, sizeof(lsm_compress)); 349 break; 349 break; 350 } 350 } 351 351 352 default: 352 default: 353 rc = LSM_MISUSE; 353 rc = LSM_MISUSE; 354 break; 354 break;