mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 22:52:54 -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
4 changed files with 154 additions and 108 deletions
|
@ -124,13 +124,12 @@ bool p3Blogs::getBlogInfo(std::string cId, BlogInfo &ci)
|
||||||
ci.pop = gi->sources.size();
|
ci.pop = gi->sources.size();
|
||||||
ci.lastPost = gi->lastPost;
|
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;
|
if(ci.pngChanImage != NULL)
|
||||||
}else{
|
ci.pngImageLen = gi->grpIcon.imageSize;
|
||||||
ci.pngChanImage = NULL;
|
else
|
||||||
ci.pngImageLen = 0;
|
ci.pngImageLen = 0;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,15 +119,12 @@ bool p3Channels::getChannelInfo(std::string cId, ChannelInfo &ci)
|
||||||
ci.pop = gi->sources.size();
|
ci.pop = gi->sources.size();
|
||||||
ci.lastPost = gi->lastPost;
|
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;
|
if(ci.pngChanImage != NULL)
|
||||||
ci.pngImageLen = gi->grpIcon.binData.bin_len;
|
ci.pngImageLen = gi->grpIcon.imageSize;
|
||||||
}else{
|
else
|
||||||
|
|
||||||
ci.pngChanImage = NULL;
|
|
||||||
ci.pngImageLen = 0;
|
ci.pngImageLen = 0;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -675,7 +672,7 @@ void p3Channels::cleanUpOldFiles(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up local caches
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ void setRSAPublicKey(RsTlvSecurityKey &key, RSA *rsa_pub);
|
||||||
void setRSAPrivateKey(RsTlvSecurityKey &key, RSA *rsa_priv);
|
void setRSAPrivateKey(RsTlvSecurityKey &key, RSA *rsa_priv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
p3GroupDistrib::p3GroupDistrib(uint16_t subtype,
|
p3GroupDistrib::p3GroupDistrib(uint16_t subtype,
|
||||||
CacheStrapper *cs, CacheTransfer *cft,
|
CacheStrapper *cs, CacheTransfer *cft,
|
||||||
std::string sourcedir, std::string storedir,
|
std::string sourcedir, std::string storedir,
|
||||||
|
@ -1516,10 +1517,22 @@ std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, ui
|
||||||
newGrp->grpControlFlags = 0;
|
newGrp->grpControlFlags = 0;
|
||||||
|
|
||||||
// explicit member wise copy for grp image
|
// 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.binData.bin_len = imageSize;
|
||||||
newGrp->grpPixmap.image_type = RSTLV_IMAGE_TYPE_PNG;
|
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 */
|
/* set keys */
|
||||||
setRSAPublicKey(newGrp->adminKey, rsa_admin_pub);
|
setRSAPublicKey(newGrp->adminKey, rsa_admin_pub);
|
||||||
newGrp->adminKey.keyFlags = RSTLV_KEY_TYPE_PUBLIC_ONLY | RSTLV_KEY_DISTRIB_ADMIN;
|
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();
|
RsSerialType *serialType = new RsDistribSerialiser();
|
||||||
|
|
||||||
char data[16000];
|
uint32_t size = serialType->size(newGrp);
|
||||||
uint32_t size = 16000;
|
char* data = new char[size];
|
||||||
|
|
||||||
serialType->serialise(newGrp, data, &size);
|
serialType->serialise(newGrp, data, &size);
|
||||||
|
|
||||||
|
@ -1642,8 +1655,7 @@ std::string p3GroupDistrib::createGroup(std::wstring name, std::wstring desc, ui
|
||||||
|
|
||||||
delete adKey;
|
delete adKey;
|
||||||
delete pubKey;
|
delete pubKey;
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
return grpId;
|
return grpId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1665,6 +1677,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||||
|
|
||||||
/* ensure Group exists */
|
/* ensure Group exists */
|
||||||
{ /* STACK MUTEX */
|
{ /* STACK MUTEX */
|
||||||
|
|
||||||
RsStackMutex stack(distribMtx); /************* STACK MUTEX ************/
|
RsStackMutex stack(distribMtx); /************* STACK MUTEX ************/
|
||||||
GroupInfo *gi = locked_getGroupInfo(grpId);
|
GroupInfo *gi = locked_getGroupInfo(grpId);
|
||||||
if (!gi)
|
if (!gi)
|
||||||
|
@ -1711,7 +1724,6 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||||
RsSerialType *serialType = createSerialiser();
|
RsSerialType *serialType = createSerialiser();
|
||||||
uint32_t size = serialType->size(msg);
|
uint32_t size = serialType->size(msg);
|
||||||
void *data = malloc(size);
|
void *data = malloc(size);
|
||||||
|
|
||||||
serialType->serialise(msg, data, &size);
|
serialType->serialise(msg, data, &size);
|
||||||
signedMsg->packet.setBinData(data, size);
|
signedMsg->packet.setBinData(data, size);
|
||||||
|
|
||||||
|
@ -1746,6 +1758,7 @@ std::string p3GroupDistrib::publishMsg(RsDistribMsg *msg, bool personalSign)
|
||||||
/* clean up */
|
/* clean up */
|
||||||
delete serialType;
|
delete serialType;
|
||||||
EVP_MD_CTX_destroy(mdctx);
|
EVP_MD_CTX_destroy(mdctx);
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
} /* END STACK MUTEX */
|
} /* 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
|
* If we pretend it is coming from an alternative source
|
||||||
* it'll automatically get published with other msgs
|
* it'll automatically get published with other msgs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
signedMsg->PeerId(mOwnId);
|
signedMsg->PeerId(mOwnId);
|
||||||
loadMsg(signedMsg, mOwnId, false);
|
loadMsg(signedMsg, mOwnId, false);
|
||||||
|
|
||||||
|
@ -1794,8 +1808,7 @@ bool p3GroupDistrib::validateDistribGrp(RsDistribGrp *newGrp)
|
||||||
/* check signature */
|
/* check signature */
|
||||||
RsSerialType *serialType = new RsDistribSerialiser();
|
RsSerialType *serialType = new RsDistribSerialiser();
|
||||||
|
|
||||||
char data[16000];
|
|
||||||
uint32_t size = 16000;
|
|
||||||
|
|
||||||
/* copy out signature (shallow copy) */
|
/* copy out signature (shallow copy) */
|
||||||
RsTlvKeySignature tmpSign = newGrp->adminSignature;
|
RsTlvKeySignature tmpSign = newGrp->adminSignature;
|
||||||
|
@ -1805,6 +1818,9 @@ bool p3GroupDistrib::validateDistribGrp(RsDistribGrp *newGrp)
|
||||||
/* clear signature */
|
/* clear signature */
|
||||||
newGrp->adminSignature.ShallowClear();
|
newGrp->adminSignature.ShallowClear();
|
||||||
|
|
||||||
|
uint32_t size = serialType->size(newGrp);
|
||||||
|
char* data = new char[size];
|
||||||
|
|
||||||
serialType->serialise(newGrp, data, &size);
|
serialType->serialise(newGrp, data, &size);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1833,7 +1849,7 @@ bool p3GroupDistrib::validateDistribGrp(RsDistribGrp *newGrp)
|
||||||
EVP_PKEY_free(key);
|
EVP_PKEY_free(key);
|
||||||
delete serialType;
|
delete serialType;
|
||||||
EVP_MD_CTX_destroy(mdctx);
|
EVP_MD_CTX_destroy(mdctx);
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
if (ans == 1)
|
if (ans == 1)
|
||||||
return true;
|
return true;
|
||||||
|
@ -1879,6 +1895,7 @@ bool p3GroupDistrib::locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGr
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* otherwise validate it */
|
/* otherwise validate it */
|
||||||
return validateDistribGrp(newGrp);
|
return validateDistribGrp(newGrp);
|
||||||
}
|
}
|
||||||
|
@ -1903,6 +1920,11 @@ bool p3GroupDistrib::locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newG
|
||||||
delete info.distribGroup;
|
delete info.distribGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.grpIcon.pngImageData != NULL){
|
||||||
|
delete[] info.grpIcon.pngImageData;
|
||||||
|
info.grpIcon.imageSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
info.distribGroup = newGrp;
|
info.distribGroup = newGrp;
|
||||||
|
|
||||||
/* copy details */
|
/* copy details */
|
||||||
|
@ -1910,9 +1932,18 @@ bool p3GroupDistrib::locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newG
|
||||||
info.grpDesc = newGrp->grpDesc;
|
info.grpDesc = newGrp->grpDesc;
|
||||||
info.grpCategory = newGrp->grpCategory;
|
info.grpCategory = newGrp->grpCategory;
|
||||||
info.grpFlags = newGrp->grpFlags;
|
info.grpFlags = newGrp->grpFlags;
|
||||||
info.grpIcon.binData.bin_data = newGrp->grpPixmap.binData.bin_data;
|
|
||||||
info.grpIcon.binData.bin_len = newGrp->grpPixmap.binData.bin_len;
|
if((newGrp->grpPixmap.binData.bin_data != NULL) && (newGrp->grpPixmap.binData.bin_len > 0)){
|
||||||
info.grpIcon.image_type = newGrp->grpPixmap.image_type;
|
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 */
|
/* pop already calculated */
|
||||||
/* last post handled seperately */
|
/* last post handled seperately */
|
||||||
|
|
|
@ -107,6 +107,24 @@ class GroupKey
|
||||||
EVP_PKEY *key; /// public key
|
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)
|
//! 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)
|
* 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 */
|
/* NOT USED YET */
|
||||||
|
|
||||||
RsTlvImage grpIcon;
|
GroupIcon grpIcon;
|
||||||
|
|
||||||
bool publisher, allowAnon, allowUnknown;
|
bool publisher, allowAnon, allowUnknown;
|
||||||
bool subscribed, listener;
|
bool subscribed, listener;
|
||||||
|
@ -162,6 +180,7 @@ class GroupInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const GroupInfo &info);
|
std::ostream &operator<<(std::ostream &out, const GroupInfo &info);
|
||||||
|
|
||||||
//! information on what cache stores group info
|
//! information on what cache stores group info
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue