mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed abug i introduced, copy of grp icon data made in p3distrib
- it was previously corrupting group keys added dynamics size to grps created - previously limited to 16000 bytes git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2928 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7cd6103ff7
commit
105e617596
@ -124,13 +124,12 @@ bool p3Blogs::getBlogInfo(std::string cId, BlogInfo &ci)
|
||||
ci.pop = gi->sources.size();
|
||||
ci.lastPost = gi->lastPost;
|
||||
|
||||
if(gi->grpIcon.image_type == RSTLV_IMAGE_TYPE_PNG){
|
||||
ci.pngChanImage = (unsigned char*) gi->grpIcon.binData.bin_data;
|
||||
ci.pngImageLen = gi->grpIcon.binData.bin_len;
|
||||
}else{
|
||||
ci.pngChanImage = NULL;
|
||||
ci.pngChanImage = gi->grpIcon.pngImageData;
|
||||
|
||||
if(ci.pngChanImage != NULL)
|
||||
ci.pngImageLen = gi->grpIcon.imageSize;
|
||||
else
|
||||
ci.pngImageLen = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -119,15 +119,12 @@ bool p3Channels::getChannelInfo(std::string cId, ChannelInfo &ci)
|
||||
ci.pop = gi->sources.size();
|
||||
ci.lastPost = gi->lastPost;
|
||||
|
||||
if(gi->grpIcon.image_type == RSTLV_IMAGE_TYPE_PNG){
|
||||
ci.pngChanImage = gi->grpIcon.pngImageData;
|
||||
|
||||
ci.pngChanImage = (unsigned char*) gi->grpIcon.binData.bin_data;
|
||||
ci.pngImageLen = gi->grpIcon.binData.bin_len;
|
||||
}else{
|
||||
|
||||
ci.pngChanImage = NULL;
|
||||
if(ci.pngChanImage != NULL)
|
||||
ci.pngImageLen = gi->grpIcon.imageSize;
|
||||
else
|
||||
ci.pngImageLen = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -675,7 +672,7 @@ void p3Channels::cleanUpOldFiles(){
|
||||
}
|
||||
|
||||
// clean up local caches
|
||||
clear_local_caches(now); //how about remote caches, remember its hardwired
|
||||
//. clear_local_caches(now); //how about remote caches, remember its hardwired
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ void setRSAPublicKey(RsTlvSecurityKey &key, RSA *rsa_pub);
|
||||
void setRSAPrivateKey(RsTlvSecurityKey &key, RSA *rsa_priv);
|
||||
|
||||
|
||||
|
||||
p3GroupDistrib::p3GroupDistrib(uint16_t subtype,
|
||||
CacheStrapper *cs, CacheTransfer *cft,
|
||||
std::string sourcedir, std::string storedir,
|
||||
@ -1516,10 +1517,22 @@ std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, ui
|
||||
newGrp->grpControlFlags = 0;
|
||||
|
||||
// explicit member wise copy for grp image
|
||||
newGrp->grpPixmap.binData.bin_data = pngImageData;
|
||||
if((pngImageData != NULL) && (imageSize > 0)){
|
||||
newGrp->grpPixmap.binData.bin_data = new unsigned char[imageSize];
|
||||
|
||||
memcpy(newGrp->grpPixmap.binData.bin_data, pngImageData,
|
||||
imageSize*sizeof(unsigned char));
|
||||
newGrp->grpPixmap.binData.bin_len = imageSize;
|
||||
newGrp->grpPixmap.image_type = RSTLV_IMAGE_TYPE_PNG;
|
||||
|
||||
}else{
|
||||
newGrp->grpPixmap.binData.bin_data = NULL;
|
||||
newGrp->grpPixmap.binData.bin_len = 0;
|
||||
newGrp->grpPixmap.image_type = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* set keys */
|
||||
setRSAPublicKey(newGrp->adminKey, rsa_admin_pub);
|
||||
newGrp->adminKey.keyFlags = RSTLV_KEY_TYPE_PUBLIC_ONLY | RSTLV_KEY_DISTRIB_ADMIN;
|
||||
@ -1591,8 +1604,8 @@ std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, ui
|
||||
|
||||
RsSerialType *serialType = new RsDistribSerialiser();
|
||||
|
||||
char data[16000];
|
||||
uint32_t size = 16000;
|
||||
uint32_t size = serialType->size(newGrp);
|
||||
char* data = new char[size];
|
||||
|
||||
serialType->serialise(newGrp, data, &size);
|
||||
|
||||
@ -1642,8 +1655,7 @@ std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, ui
|
||||
|
||||
delete adKey;
|
||||
delete pubKey;
|
||||
|
||||
|
||||
delete[] data;
|
||||
return grpId;
|
||||
}
|
||||
|
||||
@ -1665,6 +1677,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||
|
||||
/* ensure Group exists */
|
||||
{ /* STACK MUTEX */
|
||||
|
||||
RsStackMutex stack(distribMtx); /************* STACK MUTEX ************/
|
||||
GroupInfo *gi = locked_getGroupInfo(grpId);
|
||||
if (!gi)
|
||||
@ -1711,7 +1724,6 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||
RsSerialType *serialType = createSerialiser();
|
||||
uint32_t size = serialType->size(msg);
|
||||
void *data = malloc(size);
|
||||
|
||||
serialType->serialise(msg, data, &size);
|
||||
signedMsg->packet.setBinData(data, size);
|
||||
|
||||
@ -1746,6 +1758,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||
/* clean up */
|
||||
delete serialType;
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
delete[] data;
|
||||
|
||||
} /* END STACK MUTEX */
|
||||
|
||||
@ -1772,6 +1785,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||
* If we pretend it is coming from an alternative source
|
||||
* it'll automatically get published with other msgs
|
||||
*/
|
||||
|
||||
signedMsg->PeerId(mOwnId);
|
||||
loadMsg(signedMsg, mOwnId, false);
|
||||
|
||||
@ -1794,8 +1808,7 @@ bool p3GroupDistrib::validateDistribGrp(RsDistribGrp *newGrp)
|
||||
/* check signature */
|
||||
RsSerialType *serialType = new RsDistribSerialiser();
|
||||
|
||||
char data[16000];
|
||||
uint32_t size = 16000;
|
||||
|
||||
|
||||
/* copy out signature (shallow copy) */
|
||||
RsTlvKeySignature tmpSign = newGrp->adminSignature;
|
||||
@ -1805,6 +1818,9 @@ bool p3GroupDistrib::validateDistribGrp(RsDistribGrp *newGrp)
|
||||
/* clear signature */
|
||||
newGrp->adminSignature.ShallowClear();
|
||||
|
||||
uint32_t size = serialType->size(newGrp);
|
||||
char* data = new char[size];
|
||||
|
||||
serialType->serialise(newGrp, data, &size);
|
||||
|
||||
|
||||
@ -1833,7 +1849,7 @@ bool p3GroupDistrib::validateDistribGrp(RsDistribGrp *newGrp)
|
||||
EVP_PKEY_free(key);
|
||||
delete serialType;
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
|
||||
delete[] data;
|
||||
|
||||
if (ans == 1)
|
||||
return true;
|
||||
@ -1879,6 +1895,7 @@ bool p3GroupDistrib::locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGr
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* otherwise validate it */
|
||||
return validateDistribGrp(newGrp);
|
||||
}
|
||||
@ -1903,6 +1920,11 @@ bool p3GroupDistrib::locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newG
|
||||
delete info.distribGroup;
|
||||
}
|
||||
|
||||
if (info.grpIcon.pngImageData != NULL){
|
||||
delete[] info.grpIcon.pngImageData;
|
||||
info.grpIcon.imageSize = 0;
|
||||
}
|
||||
|
||||
info.distribGroup = newGrp;
|
||||
|
||||
/* copy details */
|
||||
@ -1910,9 +1932,18 @@ bool p3GroupDistrib::locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newG
|
||||
info.grpDesc = newGrp->grpDesc;
|
||||
info.grpCategory = newGrp->grpCategory;
|
||||
info.grpFlags = newGrp->grpFlags;
|
||||
info.grpIcon.binData.bin_data = newGrp->grpPixmap.binData.bin_data;
|
||||
info.grpIcon.binData.bin_len = newGrp->grpPixmap.binData.bin_len;
|
||||
info.grpIcon.image_type = newGrp->grpPixmap.image_type;
|
||||
|
||||
if((newGrp->grpPixmap.binData.bin_data != NULL) && (newGrp->grpPixmap.binData.bin_len > 0)){
|
||||
info.grpIcon.pngImageData = new unsigned char[newGrp->grpPixmap.binData.bin_len];
|
||||
|
||||
memcpy(info.grpIcon.pngImageData, newGrp->grpPixmap.binData.bin_data,
|
||||
newGrp->grpPixmap.binData.bin_len*sizeof(unsigned char));
|
||||
|
||||
info.grpIcon.imageSize = newGrp->grpPixmap.binData.bin_len;
|
||||
}else{
|
||||
info.grpIcon.pngImageData = NULL;
|
||||
info.grpIcon.imageSize = 0;
|
||||
}
|
||||
|
||||
/* pop already calculated */
|
||||
/* last post handled seperately */
|
||||
|
@ -107,6 +107,24 @@ class GroupKey
|
||||
EVP_PKEY *key; /// public key
|
||||
};
|
||||
|
||||
class GroupIcon{
|
||||
public:
|
||||
GroupIcon(): pngImageData(NULL), imageSize(0) {
|
||||
return;
|
||||
}
|
||||
|
||||
~GroupIcon(){
|
||||
|
||||
if((pngImageData != NULL) && (imageSize > 0))
|
||||
delete[] pngImageData;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char* pngImageData;
|
||||
int imageSize;
|
||||
};
|
||||
|
||||
//! aggregates various information on group activities (i.e. messages, posts, etc)
|
||||
/*!
|
||||
* The aim is to use this to keep track of group changes, so client can respond (get messages, post etc)
|
||||
@ -150,7 +168,7 @@ class GroupInfo
|
||||
|
||||
/* NOT USED YET */
|
||||
|
||||
RsTlvImage grpIcon;
|
||||
GroupIcon grpIcon;
|
||||
|
||||
bool publisher, allowAnon, allowUnknown;
|
||||
bool subscribed, listener;
|
||||
@ -162,6 +180,7 @@ class GroupInfo
|
||||
};
|
||||
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const GroupInfo &info);
|
||||
|
||||
//! information on what cache stores group info
|
||||
|
Loading…
Reference in New Issue
Block a user