From 6fc1969b951a00259cf74741b928cb48f8a61e3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 25 Apr 2017 18:07:32 +0300 Subject: [PATCH] Investigate kv crash --- src/komodo_kv.h | 5 +++++ src/wallet/wallet.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 4d2163941..3e03ca3af 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -104,6 +104,11 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) iguana_rwnum(0,&opretbuf[5],sizeof(height),&height); iguana_rwnum(0,&opretbuf[9],sizeof(flags),&flags); key = &opretbuf[13]; + if ( keylen+13 > opretlen ) + { + printf("komodo_kvupdate: keylen.%d + 13 > opretlen.%d\n",keylen,opretlen); + retrurn; + } valueptr = &key[keylen]; fee = komodo_kvfee(flags,opretlen,keylen); //printf("fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b1f543d5d..d1b007805 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2764,7 +2764,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt if ( KOMODO_EXCHANGEWALLET != 0 ) { //fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN); - interest = 0; + interest = 0; // interest2 also } CAmount nChange = (nValueIn - nValue + interest2); fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest %.8f interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)interest/COIN,(double)nTotalValue/COIN);