summaryrefslogtreecommitdiff
path: root/src/manager/sqlcipher/sqlcipher.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/manager/sqlcipher/sqlcipher.c')
-rw-r--r--src/manager/sqlcipher/sqlcipher.c101
1 files changed, 74 insertions, 27 deletions
diff --git a/src/manager/sqlcipher/sqlcipher.c b/src/manager/sqlcipher/sqlcipher.c
index f40a67e..92e26bc 100644
--- a/src/manager/sqlcipher/sqlcipher.c
+++ b/src/manager/sqlcipher/sqlcipher.c
@@ -13384,7 +13384,7 @@ int sqlcipher_codec_ctx_set_pass(codec_ctx *ctx, const void *zKey, int nKey, int
c_ctx->derive_key = 1;
if(for_ctx == 2)
- if((rc = sqlcipher_cipher_ctx_copy(ctx->read_ctx, c_ctx)) != SQLCIPHER_OK)
+ if((rc = sqlcipher_cipher_ctx_copy(ctx->read_ctx, c_ctx)) != SQLCIPHER_OK)
return rc;
return SQLCIPHER_OK;
@@ -13595,7 +13595,7 @@ int sqlcipher_page_hmac(cipher_ctx *ctx, Pgno pgno, unsigned char *in, int in_sz
int sqlcipher_page_cipher(codec_ctx *ctx, int for_ctx, Pgno pgno, int mode, int page_sz, unsigned char *in, unsigned char *out) {
cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;
unsigned char *iv_in, *iv_out, *hmac_in, *hmac_out, *out_start;
- int tmp_csz, csz, size;
+ int tmp_csz, csz, size, rc;
/* calculate some required positions into various buffers */
size = page_sz - c_ctx->reserve_sz; /* adjust size to useable size and memset reserve at end of page */
@@ -13642,13 +13642,15 @@ int sqlcipher_page_cipher(codec_ctx *ctx, int for_ctx, Pgno pgno, int mode, int
}
}
- EVP_CipherInit(&c_ctx->ectx, c_ctx->evp_cipher, NULL, NULL, mode);
+ rc = EVP_CipherInit(&c_ctx->ectx, c_ctx->evp_cipher, NULL, NULL, mode);
EVP_CIPHER_CTX_set_padding(&c_ctx->ectx, 0);
- EVP_CipherInit(&c_ctx->ectx, NULL, c_ctx->key, iv_out, mode);
- EVP_CipherUpdate(&c_ctx->ectx, out, &tmp_csz, in, size);
+ rc = EVP_CipherInit(&c_ctx->ectx, NULL, c_ctx->key, iv_out, mode);
+ rc = EVP_CipherUpdate(&c_ctx->ectx, out, &tmp_csz, in, size);
csz = tmp_csz;
out += tmp_csz;
- EVP_CipherFinal(&c_ctx->ectx, out, &tmp_csz);
+ rc = EVP_CipherFinal(&c_ctx->ectx, out, &tmp_csz);
+ // patch to fix unchecked return value warning from prevent
+ (void) rc;
csz += tmp_csz;
EVP_CIPHER_CTX_cleanup(&c_ctx->ectx);
assert(size == csz);
@@ -20302,7 +20304,10 @@ SQLCIPHER_API sqlcipher3_int64 sqlcipher3_soft_heap_limit64(sqlcipher3_int64 n){
sqlcipher3_int64 priorLimit;
sqlcipher3_int64 excess;
#ifndef SQLCIPHER_OMIT_AUTOINIT
- sqlcipher3_initialize();
+ // patch to fix unchecked return value warning from prevent
+ // sqlcipher3_initialize();
+ int rc = sqlcipher3_initialize();
+ (void) rc;
#endif
sqlcipher3_mutex_enter(mem0.mutex);
priorLimit = mem0.alarmThreshold;
@@ -28548,7 +28553,10 @@ static int dotlockLock(sqlcipher3_file *id, int eFileLock) {
#ifdef HAVE_UTIME
utime(zLockFile, NULL);
#else
- utimes(zLockFile, NULL);
+ // patch to fix unchecked return value warning from prevent
+ // 0 on success, -1 on error. But it doesn't affect on any feature on program.
+ int rcTimeUpdate = utimes(zLockFile, NULL);
+ (void) rcTimeUpdate;
#endif
return SQLCIPHER_OK;
}
@@ -28627,13 +28635,16 @@ static int dotlockUnlock(sqlcipher3_file *id, int eFileLock) {
** Close a file. Make sure the lock has been released before closing.
*/
static int dotlockClose(sqlcipher3_file *id) {
- int rc;
+ int rc = SQLCIPHER_INTERNAL;
if( id ){
unixFile *pFile = (unixFile*)id;
dotlockUnlock(id, NO_LOCK);
sqlcipher3_free(pFile->lockingContext);
+
+ // patch to fix dereference pointer without null checking
+ rc = closeUnixFile(id);
}
- rc = closeUnixFile(id);
+ // rc = closeUnixFile(id);
return rc;
}
/****************** End of the dot-file lock implementation *******************
@@ -30595,9 +30606,8 @@ static int unixShmMap(
void *pMem;
if( pShmNode->h>=0 ){
pMem = mmap(0, szRegion,
- pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
- MAP_SHARED, pShmNode->h, ((off_t)(pShmNode->nRegion))*szRegion
- );
+ pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
+ MAP_SHARED, pShmNode->h, ((off_t)(pShmNode->nRegion))*szRegion);
if( pMem==MAP_FAILED ){
rc = unixLogError(SQLCIPHER_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
goto shmpage_out;
@@ -31894,7 +31904,12 @@ static void unixDlError(sqlcipher3_vfs *NotUsed, int nBuf, char *zBufOut){
const char *zErr;
UNUSED_PARAMETER(NotUsed);
unixEnterMutex();
- zErr = dlerror();
+ /*
+ * Tizen patch. disable dlerror because of prevent defect.
+ * zErr = dlerror();
+ * fix error code for dlerror case.
+ */
+ zErr = "[Tizen] dlfcn function error occured";
if( zErr ){
sqlcipher3_snprintf(nBuf, zBufOut, "%s", zErr);
}
@@ -42588,7 +42603,7 @@ static int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){
*/
if( pSavepoint ){
u32 ii; /* Loop counter */
- i64 offset = ((i64)(pSavepoint->iSubRec))*(4+pPager->pageSize);
+ i64 offset = pSavepoint->iSubRec*((i64)(4+pPager->pageSize));
if( pagerUseWal(pPager) ){
rc = sqlcipher3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);
@@ -43435,7 +43450,7 @@ static int subjournalPage(PgHdr *pPg){
** write the journal record into the file. */
if( rc==SQLCIPHER_OK ){
void *pData = pPg->pData;
- i64 offset = ((i64)(pPager->nSubRec))*(4+pPager->pageSize);
+ i64 offset = pPager->nSubRec*((i64)(4+pPager->pageSize));
char *pData2;
CODEC2(pPager, pData, pPg->pgno, 7, return SQLCIPHER_NOMEM, pData2);
@@ -62333,7 +62348,7 @@ SQLCIPHER_PRIVATE u32 sqlcipher3VdbeSerialGet(
return 3;
}
case 4: { /* 4-byte signed integer */
- pMem->u.i = (((signed char)buf[0])<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
+ pMem->u.i = (i64)(buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
pMem->flags = MEM_Int;
return 4;
}
@@ -63387,7 +63402,10 @@ SQLCIPHER_API void *sqlcipher3_aggregate_context(sqlcipher3_context *p, int nByt
pMem->flags = MEM_Null;
pMem->z = 0;
}else{
- sqlcipher3VdbeMemGrow(pMem, nByte, 0);
+ // patch to fix unchecked return value warning from prevent
+ int rc = sqlcipher3VdbeMemGrow(pMem, nByte, 0);
+ (void) rc;
+
pMem->flags = MEM_Agg;
pMem->u.pDef = p->pFunc;
if( pMem->z ){
@@ -73596,6 +73614,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
const char *zId; /* The function name. */
FuncDef *pDef; /* Information about the function */
u8 enc = ENC(pParse->db); /* The database encoding */
+ int rc; // patch to fix unchecked return value warning from prevent
testcase( pExpr->op==TK_CONST_FUNC );
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
@@ -73643,7 +73662,9 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
pNC->hasAgg = 1;
}
if( is_agg ) pNC->allowAgg = 0;
- sqlcipher3WalkExprList(pWalker, pList);
+ // patch to fix unchecked return value warning from prevent
+ rc = sqlcipher3WalkExprList(pWalker, pList);
+ (void) rc;
if( is_agg ) pNC->allowAgg = 1;
/* FIX ME: Compute pExpr->affinity based on the expected return
** type of the function
@@ -82497,6 +82518,7 @@ SQLCIPHER_PRIVATE void sqlcipher3CreateView(
DbFixer sFix;
Token *pName = 0;
int iDb;
+ int rc; // patch to fix unchecked return value warning from prevent
sqlcipher3 *db = pParse->db;
if( pParse->nVar>0 ){
@@ -82510,7 +82532,10 @@ SQLCIPHER_PRIVATE void sqlcipher3CreateView(
sqlcipher3SelectDelete(db, pSelect);
return;
}
- sqlcipher3TwoPartName(pParse, pName1, pName2, &pName);
+ rc = sqlcipher3TwoPartName(pParse, pName1, pName2, &pName);
+ // patch to fix unchecked return value warning from prevent
+ (void) rc;
+
iDb = sqlcipher3SchemaToIndex(db, p->pSchema);
if( sqlcipher3FixInit(&sFix, pParse, iDb, "view", pName)
&& sqlcipher3FixSelect(&sFix, pSelect)
@@ -87848,6 +87873,7 @@ static void fkScanChildren(
NameContext sNameContext; /* Context used to resolve WHERE clause */
WhereInfo *pWInfo; /* Context used by sqlcipher3WhereXXX() */
int iFkIfZero = 0; /* Address of OP_FkIfZero */
+ int rc; // patch to fix unchecked return value warning from prevent
Vdbe *v = sqlcipher3GetVdbe(pParse);
assert( !pIdx || pIdx->pTable==pTab );
@@ -87920,7 +87946,9 @@ static void fkScanChildren(
memset(&sNameContext, 0, sizeof(NameContext));
sNameContext.pSrcList = pSrc;
sNameContext.pParse = pParse;
- sqlcipher3ResolveExprNames(&sNameContext, pWhere);
+ rc = sqlcipher3ResolveExprNames(&sNameContext, pWhere);
+ // patch to fix unchecked return value warning from prevent
+ (void) rc;
/* Create VDBE to loop through the entries in pSrc that match the WHERE
** clause. If the constraint is not deferred, throw an exception for
@@ -93219,12 +93247,12 @@ SQLCIPHER_PRIVATE void sqlcipher3Pragma(
#if defined(SQLCIPHER_HAS_CODEC) || defined(SQLCIPHER_ENABLE_CEROD)
if( sqlcipher3StrICmp(zLeft, "activate_extensions")==0 ){
#ifdef SQLCIPHER_HAS_CODEC
- if( sqlcipher3StrNICmp(zRight, "see-", 4)==0 ){
+ if( zRight && sqlcipher3StrNICmp(zRight, "see-", 4)==0 ){
sqlcipher3_activate_see(&zRight[4]);
}
#endif
#ifdef SQLCIPHER_ENABLE_CEROD
- if( sqlcipher3StrNICmp(zRight, "cerod-", 6)==0 ){
+ if( zRight && sqlcipher3StrNICmp(zRight, "cerod-", 6)==0 ){
sqlcipher3_activate_cerod(&zRight[6]);
}
#endif
@@ -93330,15 +93358,17 @@ SQLCIPHER_PRIVATE int sqlcipher3InitCallback(void *pInit, int argc, char **argv,
*/
int rc;
sqlcipher3_stmt *pStmt;
- TESTONLY(int rcp); /* Return code from sqlcipher3_prepare() */
+ int rcp; /* Return code from sqlcipher3_prepare() */
assert( db->init.busy );
db->init.iDb = iDb;
db->init.newTnum = sqlcipher3Atoi(argv[1]);
db->init.orphanTrigger = 0;
- TESTONLY(rcp = ) sqlcipher3_prepare(db, argv[2], -1, &pStmt, 0);
+ rcp = sqlcipher3_prepare(db, argv[2], -1, &pStmt, 0);
rc = db->errCode;
assert( (rc&0xFF)==(rcp&0xFF) );
+ (void) rcp;
+
db->init.iDb = 0;
if( SQLCIPHER_OK!=rc ){
if( db->init.orphanTrigger ){
@@ -96946,7 +96976,12 @@ static int flattenSubquery(
/* Authorize the subquery */
pParse->zAuthContext = pSubitem->zName;
- sqlcipher3AuthCheck(pParse, SQLCIPHER_SELECT, 0, 0, 0);
+
+ // patch for unchecked return value warning from prevent
+ // sqlcipher3AuthCheck(pParse, SQLCIPHER_SELECT, 0, 0, 0);
+ int authResult = sqlcipher3AuthCheck(pParse, SQLCIPHER_SELECT, 0, 0, 0);
+ (void) authResult;
+
pParse->zAuthContext = zSavedAuthContext;
/* If the sub-query is a compound SELECT statement, then (by restrictions
@@ -101357,8 +101392,10 @@ SQLCIPHER_PRIVATE void sqlcipher3VtabBeginParse(
** The second call, to obtain permission to create the table, is made now.
*/
if( pTable->azModuleArg ){
- sqlcipher3AuthCheck(pParse, SQLCIPHER_CREATE_VTABLE, pTable->zName,
+ int rc = sqlcipher3AuthCheck(pParse, SQLCIPHER_CREATE_VTABLE, pTable->zName,
pTable->azModuleArg[0], pParse->db->aDb[iDb].zName);
+ // patch to fix unchecked return value warning from prevent
+ (void) rc;
}
#endif
}
@@ -104288,7 +104325,12 @@ static sqlcipher3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator==WO_IN );
testcase( pTerm->eOperator==WO_ISNULL );
if( pTerm->eOperator & (WO_IN|WO_ISNULL) ) continue;
+
+ // patch to fix dead code warning from prevent
+ // TERM_VNULL is always 0 if SQLCIPHER_ENABLE_STAT3 feature is not defined.
+#ifdef SQLCIPHER_ENABLE_STAT3
if( pTerm->wtFlags & TERM_VNULL ) continue;
+#endif
nTerm++;
}
@@ -104339,7 +104381,12 @@ static sqlcipher3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator==WO_IN );
testcase( pTerm->eOperator==WO_ISNULL );
if( pTerm->eOperator & (WO_IN|WO_ISNULL) ) continue;
+
+ // patch to fix dead code warning from prevent
+ // TERM_VNULL is always 0 if SQLCIPHER_ENABLE_STAT3 feature is not defined.
+#ifdef SQLCIPHER_ENABLE_STAT3
if( pTerm->wtFlags & TERM_VNULL ) continue;
+#endif
pIdxCons[j].iColumn = pTerm->u.leftColumn;
pIdxCons[j].iTermOffset = i;
pIdxCons[j].op = (u8)pTerm->eOperator;