Browse Source

privkeys[] overflow

etomic
jl777 7 years ago
parent
commit
54a7c61f2f
  1. 68
      iguana/exchanges/LP_cache.c
  2. 5
      iguana/exchanges/LP_include.h
  3. 2
      iguana/exchanges/LP_tradebots.c
  4. 2
      iguana/exchanges/LP_transaction.c

68
iguana/exchanges/LP_cache.c

@ -60,18 +60,72 @@ cJSON *LP_cache_transaction(struct iguana_info *coin,bits256 txid,uint8_t *seria
return(txobj);
}
struct LP_transaction
{
UT_hash_handle hh;
bits256 txid;
int32_t height,numvouts,numvins,len,SPV;
uint8_t *serialized;
struct LP_outpoint outpoints[];
};
int32_t LP_cacheitem(uint8_t *ptr,long remains)
{
}
void *LP_cacheptr(FILE **wfp,long *fsizep,struct iguana_info *coin)
{
char fname[1024]; long n,len = 0; uint8_t *ptr = 0;
sprintf(fname,"%s/UNSPENTS/%s.SPV",GLOBAL_DBDIR,coin->symbol), OS_portable_path(fname);
if ( ((*wfp)= OS_appendfile(fname)) != 0 )
{
ptr = OS_portable_mapfile(fname,fsizep,0);
while ( len < *fsizep )
{
if ( (n= LP_cacheitem(coin,&ptr[len],*fsizep - len)) < 0 )
{
printf("cacheitem error at %s offset.%ld when fsize.%ld\n",coin->symbol,len,*fsizep);
fseek(*wfp,len,SEEK_SET);
break;
}
len += n;
}
}
return(ptr);
}
int32_t LP_SPV_load(struct iguana_info *coin,bits256 txid,int32_t height)
{
struct LP_transaction *tp;
HASH_FIND(hh,coin->SPVcache,&txid,sizeof(txid),cp)
return(-1);
}
struct LP_transaction
{
UT_hash_handle hh;
bits256 txid;
int32_t height,numvouts,numvins,len,SPV;
uint8_t *serialized;
struct LP_outpoint outpoints[];
};
void LP_SPV_store(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t height)
{
struct LP_transaction *tx = 0;
if ( strcmp(coin->smartaddr,coinaddr) == 0 && (tx= LP_transactionfind(coin,txid)) != 0 && tx->serialized != 0 )
struct LP_transaction TX; struct LP_transaction *tx = 0;
if ( coin->cachefp != 0 && (tx= LP_transactionfind(coin,txid)) != 0 && tx->serialized != 0 && tx->len > 0 ) //strcmp(coin->smartaddr,coinaddr) == 0 &&
{
//char str[65]; printf("store %s %s.[%d]\n",coin->symbol,bits256_str(str,txid),tx->len);
} //else printf("skip SPV store for (%s) tx.%p\n",coinaddr,tx);
char str[65]; printf("store %s %s.[%d]\n",coin->symbol,bits256_str(str,txid),tx->len);
TX = *tx;
memset(&TX.hh,0,sizeof(TX.hh));
TX.serialized = 0;
fwrite(&TX,1,sizeof(TX),coin->cachefp);
if ( tx->numvouts > 0 )
fwrite(TX.outpoints,tx->numvouts,sizeof(*TX.outpoints),coin->cachefp);
fwrite(tx->serialized,1,tx->len,coin->cachefp);
fflush(coin->cachefp);
}
}
bits256 iguana_merkle(bits256 *tree,int32_t txn_count)
@ -144,9 +198,9 @@ bits256 LP_merkleroot(struct iguana_info *coin,struct electrum_info *ep,int32_t
int32_t LP_merkleproof(struct iguana_info *coin,char *coinaddr,struct electrum_info *ep,bits256 txid,int32_t height)
{
cJSON *merkobj,*merkles; bits256 roothash,merkleroot; int32_t retval,m,SPV = 0;
if ( strcmp(coin->smartaddr,coinaddr) == 0 && (retval= LP_SPV_load(coin,txid,height)) > 0 )
return(retval);
struct LP_transaction *tx; cJSON *merkobj,*merkles; bits256 roothash,merkleroot; int32_t retval,m,SPV = 0;
if ( (tx= LP_transactionfind(coin,txid)) != 0 && tx->height == height && tx->SPV > 0 )
return(tx->SPV);
if ( (merkobj= electrum_getmerkle(coin->symbol,ep,&merkobj,txid,height)) != 0 )
{
char str[65],str2[65],str3[65];

5
iguana/exchanges/LP_include.h

@ -244,7 +244,8 @@ struct LP_outpoint { bits256 spendtxid; uint64_t value,interest; int32_t spendvi
struct LP_transaction
{
UT_hash_handle hh;
bits256 txid; int32_t height,numvouts,numvins,len; //uint32_t timestamp;
bits256 txid;
int32_t height,numvouts,numvins,len,SPV;
uint8_t *serialized;
struct LP_outpoint outpoints[];
};
@ -260,7 +261,7 @@ struct iguana_info
char symbol[16],smartaddr[64],userpass[1024],serverport[128];
// portfolio
double price_kmd,force,perc,goal,goalperc,relvolume,rate;
void *electrum; void *ctx;
void *electrum; void *ctx; FILE *cachefp;
uint64_t maxamount,kmd_equiv,balanceA,balanceB,valuesumA,valuesumB;
uint8_t pubkey33[33],zcash;
bits256 lastprivkey; uint32_t lastprivkeytime; int32_t privkeydepth;

2
iguana/exchanges/LP_tradebots.c

@ -99,7 +99,7 @@ void LP_tradebot_calcstats(struct LP_tradebot *bot)
}
//LP_tradebot_updatestats(bot,bot->trades[i]);
}
printf("completed.%d (%.8f / %.8f) pending.%d (%.8f / %.8f)\n",bot->completed,bot->basesum,bot->relsum,bot->numpending,bot->pendbasesum,bot->pendrelsum);
//printf("completed.%d (%.8f / %.8f) pending.%d (%.8f / %.8f)\n",bot->completed,bot->basesum,bot->relsum,bot->numpending,bot->pendbasesum,bot->pendrelsum);
}
double LP_pricevol_invert(double *basevolumep,double maxprice,double relvolume)

2
iguana/exchanges/LP_transaction.c

@ -475,7 +475,7 @@ int64_t iguana_lockval(int32_t finalized,int64_t locktime)
int32_t iguana_signrawtransaction(void *ctx,char *symbol,uint8_t wiftaddr,uint8_t taddr,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,int32_t height,struct iguana_msgtx *msgtx,char **signedtxp,bits256 *signedtxidp,struct vin_info *V,int32_t numinputs,char *rawtx,cJSON *vins,cJSON *privkeysjson,int32_t zcash)
{
uint8_t *serialized,*serialized2,*serialized3,*serialized4,*extraspace,pubkeys[64][33]; int32_t finalized,i,len,n,z,plen,maxsize,complete = 0,extralen = 100000; char *privkeystr,*signedtx = 0; bits256 privkeys[64],privkey,txid; cJSON *item; cJSON *txobj = 0;
uint8_t *serialized,*serialized2,*serialized3,*serialized4,*extraspace,pubkeys[64][33]; int32_t finalized,i,len,n,z,plen,maxsize,complete = 0,extralen = 100000; char *privkeystr,*signedtx = 0; bits256 privkeys[1024],privkey,txid; cJSON *item; cJSON *txobj = 0;
maxsize = 1000000;
memset(privkey.bytes,0,sizeof(privkey));
if ( rawtx != 0 && rawtx[0] != 0 && (len= (int32_t)strlen(rawtx)>>1) < maxsize )

Loading…
Cancel
Save