File wolfi.patch of Package kdepim4-runtime

diff --git a/resources/imap/retrieveitemstask.cpp b/resources/imap/retrieveitemstask.cpp
index b29477b..0da8d3c 100644
--- a/resources/imap/retrieveitemstask.cpp
+++ b/resources/imap/retrieveitemstask.cpp
@@ -536,6 +536,7 @@ void RetrieveItemsTask::onRetrievalDone(KJob *job)
 
     // Fetch flags of all items that were not fetched by the fetchJob. After
     // that /all/ items in the folder are synced.
+qDebug() << "Wolfi: onRetrievalDone(KJob *job), calling listFlagsForImapSet(1," << alreadyFetchedBegin - 1 << ")";
     listFlagsForImapSet(KIMAP::ImapSet(1, alreadyFetchedBegin - 1));
 }
 
@@ -549,7 +549,7 @@ void RetrieveItemsTask::listFlagsForImapSet(const KIMAP::ImapSet& set)
   scope.mode = KIMAP::FetchJob::FetchScope::Flags;
   // Only use changeSince when doing incremental listings,
   // otherwise we would overwrite our local data with an incomplete dataset
-  if(m_incremental && serverSupportsCondstore()) {
+  if(m_incremental) {  if(!serverSupportsCondstore()) qDebug() << "Wolfi: pretending that the server supports CONDSTORE though it doesn't, can lead to missing flags retrieval!";
       scope.changedSince = m_highestModseq;
       if (!m_flagsChanged) {
           kDebug(5327)  << "No flag changes.";
@@ -558,6 +558,8 @@ void RetrieveItemsTask::listFlagsForImapSet(const KIMAP::ImapSet& set)
       }
   }
 
+qDebug() << "Wolfi: m_incremental =" << m_incremental << ", serverSupportsCondstore() =" << serverSupportsCondstore() << ", m_flagsChanged =" << m_flagsChanged << " => full flag retrieval!";
+qDebug() << "m_uidBasedFetch =" << m_uidBasedFetch << ", scope.changedSince =" << scope.changedSince << ", set.intervals().size() =" << set.intervals().size();
   m_batchFetcher = createBatchFetcher(resourceState()->messageHelper(), set, scope, 10 * batchSize(), m_session);
   m_batchFetcher->setUidBased(m_uidBasedFetch);
   if (m_uidBasedFetch && scope.changedSince == 0 && set.intervals().size() == 1) {
From cde208e6cb159a8c9e5896f5cc7fbc17f34e6170 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Vr=C3=A1til?= <dvratil@kde.org>
Date: Sat, 18 Apr 2020 19:30:23 +0200
Subject: IMAP: fix use-after free in ChangeItemTask

The attribute pointer lives only as long as the owning Collection lives.
Since the code here was taking the attribute from a temporary object,
the uidNext() getter called below would return a garbage number.
---
 resources/imap/changeitemtask.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/resources/imap/changeitemtask.cpp b/resources/imap/changeitemtask.cpp
index 5892878..cd96c19 100644
--- a/resources/imap/changeitemtask.cpp
+++ b/resources/imap/changeitemtask.cpp
@@ -204,7 +204,10 @@ void ChangeItemTask::triggerSearchJob()
   } else {
     search->addSearchCriteria( KIMAP::SearchJob::New );
 
-    UidNextAttribute *uidNext = item().parentCollection().attribute<UidNextAttribute>();
+    //const auto parent = item().parentCollection();
+    UidNextAttribute *uidNext = item().parentCollection().attribute<UidNextAttribute>();/*const UidNextAttribute *uidNext = parent.attribute<UidNextAttribute>();*/qDebug() << "Wolfi: ChangeItemTask::triggerSearchJob(), uidNext->uidNext() =" << (uidNext ? uidNext->uidNext() : -1);
+    const auto parent = item().parentCollection(); const UidNextAttribute *my_uidNext = parent.attribute<UidNextAttribute>();
+    qDebug() << "should be:" << (my_uidNext ? my_uidNext->uidNext() : -1);
     if ( !uidNext ) {
       kWarning() << "Failed to determine new uid.";
       cancelTask( i18n( "Could not determine the UID for the newly created message on the server" ) );
-- 
cgit v1.1
openSUSE Build Service is sponsored by