Skip to content

Commit

Permalink
Merge branch 'profile' into 'master'
Browse files Browse the repository at this point in the history
Add some safeguard in Buteo for malformed profiles. Contributes to JB#47583

See merge request mer-core/buteo-syncfw!44
  • Loading branch information
pvuorela committed Jan 30, 2020
2 parents 1897a58 + 97a5b02 commit 5268fef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions libbuteosyncfw/profile/ProfileManager.cpp
Expand Up @@ -725,9 +725,12 @@ Profile* ProfileManager::profileFromXml(const QString &aProfileAsXml)
Profile *profile = NULL;
if(!aProfileAsXml.isEmpty()) {
QDomDocument doc;
if(doc.setContent(aProfileAsXml,true)) {
QString error;
if (doc.setContent(aProfileAsXml, true, &error)) {
ProfileFactory pf;
profile = pf.createProfile(doc.documentElement());
} else {
LOG_WARNING("Cannot parse profile: " + error);
}
}
return profile;
Expand All @@ -737,7 +740,13 @@ QString ProfileManager::updateProfile(const Profile &aProfile)
{
FUNCTION_CALL_TRACE;

// We must have a profile exiting before updating it...
// Don't save invalid profiles.
if (aProfile.name().isEmpty() || aProfile.type().isEmpty()) {
LOG_WARNING("Malformed profile, missing name or type.");
return QString();
}

// We must have a profile existing before updating it...

bool exists = d_ptr->profileExists(aProfile.name(),aProfile.type());

Expand Down
3 changes: 2 additions & 1 deletion msyncd/synchronizer.cpp
Expand Up @@ -482,7 +482,8 @@ bool Synchronizer::startSync(const QString &aProfileName, bool aScheduled)

session->setScheduled(aScheduled);

if (clientProfileActive(profile->clientProfile()->name())) {
if (profile->clientProfile()
&& clientProfileActive(profile->clientProfile()->name())) {
LOG_DEBUG( "Sync request of the same type in progress, adding request to the sync queue" );
iSyncQueue.enqueue(session);
emit syncStatus(aProfileName, Sync::SYNC_QUEUED, "", 0);
Expand Down

0 comments on commit 5268fef

Please sign in to comment.