diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index c4247ff44..d594eb29c 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -78,7 +78,7 @@ uint8_t *get_dataptr(int32_t hdroffset,uint8_t **ptrp,int32_t *datalenp,uint8_t else return(data); } -uint8_t *basilisk_jsondata(uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag) +uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag) { char *sendstr,*hexstr; uint8_t *data; bits256 hash; int32_t i,datalen,hexlen=0,havehash=1; if ( jobj(sendjson,"coin") == 0 ) @@ -93,14 +93,14 @@ uint8_t *basilisk_jsondata(uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32 *ptrp = 0; sendstr = jprint(sendjson,0); datalen = (int32_t)strlen(sendstr) + 1; - if ( (datalen + BASILISK_HDROFFSET + hexlen + havehash*(sizeof(hash)+1)) <= spacesize ) + if ( (datalen + extraoffset + BASILISK_HDROFFSET + hexlen + havehash*(sizeof(hash)+1)) <= spacesize ) data = space; else { - data = calloc(1,datalen + BASILISK_HDROFFSET + hexlen + havehash*(sizeof(hash)+1)); + data = calloc(1,datalen + extraoffset + BASILISK_HDROFFSET + hexlen + havehash*(sizeof(hash)+1)); *ptrp = data; } - data += BASILISK_HDROFFSET; + data += extraoffset + BASILISK_HDROFFSET; memcpy(data,sendstr,datalen); free(sendstr); if ( havehash != 0 || hexlen != 0 ) @@ -313,7 +313,7 @@ void basilisk_sendback(struct supernet_info *myinfo,char *symbol,char *remoteadd { if ( (valsobj= cJSON_Parse(retstr)) != 0 ) { - data = basilisk_jsondata(&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); + data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); basilisk_sendcmd(myinfo,remoteaddr,"RET",&basilisktag,encryptflag,delaymillis,data,datalen,0,0); if ( allocptr != 0 ) free(allocptr); @@ -364,7 +364,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t } else { - data = basilisk_jsondata(&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); + data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); *numsentp = ptr->numsent = basilisk_sendcmd(myinfo,0,CMD,&ptr->basilisktag,encryptflag,delaymillis,data,datalen,1,ptr->nBits); if ( allocptr != 0 ) free(allocptr); diff --git a/basilisk/basilisk.h b/basilisk/basilisk.h index 20d761cc4..a5d145b52 100755 --- a/basilisk/basilisk.h +++ b/basilisk/basilisk.h @@ -50,7 +50,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ void basilisks_init(struct supernet_info *myinfo); void basilisk_p2p(void *myinfo,void *_addr,char *ipaddr,uint8_t *data,int32_t datalen,char *type,int32_t encrypted); -uint8_t *basilisk_jsondata(uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag); +uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag); uint8_t *SuperNET_ciphercalc(void **ptrp,int32_t *cipherlenp,bits256 *privkeyp,bits256 *destpubkeyp,uint8_t *data,int32_t datalen,uint8_t *space2,int32_t space2size); void *SuperNET_deciphercalc(void **ptrp,int32_t *msglenp,bits256 privkey,bits256 srcpubkey,uint8_t *cipher,int32_t cipherlen,uint8_t *buf,int32_t bufsize); diff --git a/iguana/iguana_instantdex.c b/iguana/iguana_instantdex.c index 000a78470..20bc864cc 100755 --- a/iguana/iguana_instantdex.c +++ b/iguana/iguana_instantdex.c @@ -465,7 +465,7 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o jaddstr(sendjson,"cmd",cmdstr); jaddstr(sendjson,"handle",myinfo->handle); jaddbits256(sendjson,"traderpub",myinfo->myaddr.persistent); - data = basilisk_jsondata(&allocptr,space,sizeof(space),&datalen,swap->mine.offer.base,sendjson,basilisktag); + data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,swap->mine.offer.base,sendjson,basilisktag); basilisk_sendcmd(myinfo,addr->ipaddr,dir > 0 ? "BID" : "ASK",&basilisktag,encryptflag,delaymillis,data,datalen,1,BASILISK_DEFAULTDIFF); free_json(sendjson); if ( allocptr != 0 )