File r884326-mail-loss-spam-filter-tmp-full.diff of Package kdepim4

Subject: Fix mail loss when filtering POP mail and /tmp is full
From: wstephenson@suse.de
Patch-Upstream: 884326
Index: kmail/kmfilteraction.cpp
===================================================================
--- kmail/kmfilteraction.cpp	(revision 884325)
+++ kmail/kmfilteraction.cpp	(revision 884326)
@@ -503,7 +503,8 @@
   // KProcess doesn't support a QProcess::launch() equivalent, so
   // we must use a temp file :-(
   KTemporaryFile * inFile = new KTemporaryFile;
-  inFile->open();
+  if ( !inFile->open() )
+    return ErrorButGoOn;
 
   QList<KTemporaryFile*> atmList;
   atmList.append( inFile );
@@ -526,8 +527,12 @@
 
   // write message to file
   QString tempFileName = inFile->fileName();
-  KPIMUtils::kByteArrayToFile( aMsg->asString(), tempFileName, //###
-                  false, false, false );
+  if ( !KPIMUtils::kByteArrayToFile( aMsg->asString(), tempFileName, //###
+                                     false, false, false ) ) {
+    qDeleteAll( atmList );
+    atmList.clear();
+    return CriticalError;
+  }
   inFile->close();
 
   KProcess shProc;
@@ -1720,14 +1725,19 @@
   ActionScheduler *handler = MessageProperty::filterHandler( aMsg->getMsgSerNum() );
   KTemporaryFile *inFile = new KTemporaryFile;
   inFile->setAutoRemove(false);
-  inFile->open();
+  if ( !inFile->open() ) {
+    handler->actionMessage( ErrorButGoOn );
+    return;
+  }
 
   QList<KTemporaryFile*> atmList;
   atmList.append( inFile );
 
   QString commandLine = substituteCommandLineArgsFor( aMsg, atmList );
-  if ( commandLine.isEmpty() )
+  if ( commandLine.isEmpty() ) {
     handler->actionMessage( ErrorButGoOn );
+    return;
+  }
 
   // The parentheses force the creation of a subshell
   // in which the user-specified command is executed.
@@ -1740,8 +1750,13 @@
 
   // write message to file
   QString tempFileName = inFile->fileName();
-  KPIMUtils::kByteArrayToFile( aMsg->asString(), tempFileName, //###
-      false, false, false );
+  if ( !KPIMUtils::kByteArrayToFile( aMsg->asString(), tempFileName, //###
+      false, false, false ) ) {
+    handler->actionMessage( CriticalError );
+    qDeleteAll( atmList );
+    atmList.clear();
+    return;
+  }
 
   inFile->close();
   qDeleteAll( atmList );
openSUSE Build Service is sponsored by