Merge pull request #2115 from csoler/v0.6-BugFixing_2

Bug fixing for 0.6.6
This commit is contained in:
csoler 2020-11-18 19:57:48 +01:00 committed by GitHub
commit 11c71d16ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 27 deletions

View File

@ -417,11 +417,22 @@ bool GxsSecurity::validateNxsMsg(const RsNxsMsg& msg, const RsTlvKeySignature& s
// /********************* check signature *******************/ // /********************* check signature *******************/
/* check signature timeperiod */ /* check signature timeperiod */
if ((msgMeta.mPublishTs < key.startTS) || (key.endTS != 0 && msgMeta.mPublishTs > key.endTS)) if(msgMeta.mPublishTs < key.startTS)
{
RsWarn() << __PRETTY_FUNCTION__ << " GxsSecurity::validateNxsMsg() TS out of range for key " << msgMeta.mAuthorId
<< " The signed message has an inconsistent msg publish time of " << msgMeta.mPublishTs
<< " whereas the signing key was created later at TS " << key.startTS
<< ". Validation rejected for security. If you see this, something irregular is going on." << std::endl;
return false;
}
if(key.endTS != 0 && msgMeta.mPublishTs > key.endTS)
{ {
RsWarn() << __PRETTY_FUNCTION__ << " GxsSecurity::validateNxsMsg() TS out of range for key " << msgMeta.mAuthorId RsWarn() << __PRETTY_FUNCTION__ << " GxsSecurity::validateNxsMsg() TS out of range for key " << msgMeta.mAuthorId
<< " usage is limited to TS=[" << key.startTS << "," << key.endTS << "] and msg publish time is " << msgMeta.mPublishTs << std::endl; << " usage is limited to TS=[" << key.startTS << "," << key.endTS << "] and msg publish time is " << msgMeta.mPublishTs
return false; << " The validation still passes, but that key should be renewed." << std::endl;
// no return here. We still proceed checking the signature.
} }
/* decode key */ /* decode key */
@ -1053,14 +1064,22 @@ bool GxsSecurity::validateNxsGrp(const RsNxsGrp& grp, const RsTlvKeySignature& s
/********************* check signature *******************/ /********************* check signature *******************/
/* check signature timeperiod */ /* check signature timeperiod */
if ((grpMeta.mPublishTs < key.startTS) || (key.endTS != 0 && grpMeta.mPublishTs > key.endTS)) if (grpMeta.mPublishTs < key.startTS)
{ {
#ifdef GXS_SECURITY_DEBUG RsWarn() << __PRETTY_FUNCTION__ << " GxsSecurity::validateNxsGrp() TS out of range for admin/publish key of group " << grpMeta.mGroupId
std::cerr << " GxsSecurity::validateNxsMsg() TS out of range"; << " The signed group has an inconsistent creation/modification time of " << grpMeta.mPublishTs
std::cerr << std::endl; << " whereas the key was created later at TS " << key.startTS
#endif << ". Validation rejected for security. If you see this, something irregular is going on." << std::endl;
return false; return false;
} }
if (key.endTS != 0 && grpMeta.mPublishTs > key.endTS)
{
RsWarn() << __PRETTY_FUNCTION__ << " GxsSecurity::validateNxsMsg() TS out of range for admin/publish key for group " << grpMeta.mGroupId
<< " usage is limited to TS=[" << key.startTS << "," << key.endTS << "] and msg publish time is " << grpMeta.mPublishTs
<< " The validation still passes, but that key should be renewed." << std::endl;
// no return. Still proceed checking signature.
}
/* decode key */ /* decode key */
const unsigned char *keyptr = (const unsigned char *) key.keyData.bin_data; const unsigned char *keyptr = (const unsigned char *) key.keyData.bin_data;

View File

@ -597,6 +597,10 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true); mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true);
// Disable sorting while updating which avoids calling sortChildren() in child(i), causing heavy loads when adding
// many items to a tree.
ui->treeWidget_membership->setSortingEnabled(false);
std::vector<bool> expanded_top_level_items; std::vector<bool> expanded_top_level_items;
std::set<RsGxsCircleId> expanded_circle_items; std::set<RsGxsCircleId> expanded_circle_items;
saveExpandedCircleItems(expanded_top_level_items,expanded_circle_items); saveExpandedCircleItems(expanded_top_level_items,expanded_circle_items);
@ -730,6 +734,15 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
for(auto index:to_delete) for(auto index:to_delete)
delete item->takeChild(index); // delete items starting from the largest index, because otherwise the count changes while deleting... delete item->takeChild(index); // delete items starting from the largest index, because otherwise the count changes while deleting...
// Now make a list of items to add, but only add them at once at the end of the loop, to avoid a quadratic cost.
QList<QTreeWidgetItem*> new_sub_items;
// ...and make a map of which index each item has, to make the search logarithmic
std::map<QString,uint32_t> subitem_indices;
for(uint32_t k=0; k < (uint32_t)item->childCount(); ++k)
subitem_indices[item->child(k)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString()] = k;
for(std::map<RsGxsId,uint32_t>::const_iterator it(details.mSubscriptionFlags.begin());it!=details.mSubscriptionFlags.end();++it) for(std::map<RsGxsId,uint32_t>::const_iterator it(details.mSubscriptionFlags.begin());it!=details.mSubscriptionFlags.end();++it)
{ {
#ifdef ID_DEBUG #ifdef ID_DEBUG
@ -745,15 +758,11 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
int subitem_index = -1; int subitem_index = -1;
// see if the item already exists // see if the item already exists
for(uint32_t k=0; k < (uint32_t)item->childCount(); ++k)
if(item->child(k)->data(CIRCLEGROUP_CIRCLE_COL_GROUPID,Qt::UserRole).toString().toStdString() == it->first.toStdString()) auto itt = subitem_indices.find(QString::fromStdString(it->first.toStdString()));
{
subitem_index = k; if(itt != subitem_indices.end())
#ifdef ID_DEBUG subitem_index = itt->second;
std::cerr << " found existing sub item." << std::endl;
#endif
break ;
}
if(!(invited || subscrb)) if(!(invited || subscrb))
{ {
@ -819,7 +828,7 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
//subitem->setIcon(RSID_COL_NICKNAME, QIcon(pixmap)); //subitem->setIcon(RSID_COL_NICKNAME, QIcon(pixmap));
item->addChild(subitem) ; new_sub_items.push_back(subitem);
} }
else else
subitem = item->child(subitem_index); subitem = item->child(subitem_index);
@ -851,6 +860,9 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
} }
} }
// add all items
item->addChildren(new_sub_items);
// The bullet colors below are for the *Membership*. This is independent from admin rights, which cannot be shown as a color. // The bullet colors below are for the *Membership*. This is independent from admin rights, which cannot be shown as a color.
// Admin/non admin is shows using Bold font. // Admin/non admin is shows using Bold font.
@ -861,6 +873,8 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
else else
item->setIcon(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,FilesDefs::getIconFromQtResourcePath(IMAGE_UNKNOWN)) ; item->setIcon(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,FilesDefs::getIconFromQtResourcePath(IMAGE_UNKNOWN)) ;
} }
ui->treeWidget_membership->setSortingEnabled(true);
restoreExpandedCircleItems(expanded_top_level_items,expanded_circle_items); restoreExpandedCircleItems(expanded_top_level_items,expanded_circle_items);
} }

View File

@ -64,21 +64,21 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
if(e) if(e)
switch(e->mChannelEventCode) switch(e->mChannelEventCode)
{ {
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]]; case RsChannelEventCode::STATISTICS_CHANGED: // [[fallthrough]];
updateDisplay(true); // no breaks, on purpose!
case RsChannelEventCode::NEW_MESSAGE: // [[fallthrough]];
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]]; case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
case RsChannelEventCode::READ_STATUS_CHANGED: // [[fallthrough]]; case RsChannelEventCode::READ_STATUS_CHANGED: // [[fallthrough]];
updateGroupStatisticsReal(e->mChannelGroupId); // update the list immediately updateGroupStatisticsReal(e->mChannelGroupId);// update the list immediately
break; break;
case RsChannelEventCode::NEW_CHANNEL: // [[fallthrough]]; case RsChannelEventCode::RECEIVED_PUBLISH_KEY: // [[fallthrough]];
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: case RsChannelEventCode::NEW_CHANNEL: // [[fallthrough]];
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED:// reloads group summary (calling GxsGroupFrameDialog parent method)
updateDisplay(true); updateDisplay(true);
break; break;
case RsChannelEventCode::STATISTICS_CHANGED:
updateGroupStatistics(e->mChannelGroupId);
break;
default: default:
break; break;
} }