[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    [Bug 54810] kword destroys data when space to write is empty
From:       David Faure <faure () kde ! org>
Date:       2004-03-17 16:19:53
Message-ID: 20040317161953.16086.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=54810      




------- Additional Comments From faure kde org  2004-03-17 17:19 -------
CVS commit by faure: 

Error checking while saving, e.g. for disk full case.
CCMAIL: 54810 bugs kde org


  M +3 -1      kfilterdev.cpp   1.39.2.1
  M +12 -6     kzip.cpp   1.44.2.1


--- kdelibs/kio/kio/kfilterdev.cpp  #1.39:1.39.2.1
 @ -364,6 +364,8  @ Q_LONG KFilterDev::writeBlock( const cha
                 // Write compressed data to underlying device
                 int size = filter->device()->writeBlock( d->buffer.data(), towrite \
                );
-                if ( size != towrite )
+                if ( size != towrite ) {
                     kdWarning(7005) << "KFilterDev::writeBlock. Could only write " \
<< size << " out of " << towrite << " bytes" << endl; +                    return 0; \
// indicate an error (happens on disk full) +                }
                 //else
                     //kdDebug(7005) << " KFilterDev::writeBlock wrote " << size << " \
bytes" << endl;

--- kdelibs/kio/kio/kzip.cpp  #1.44:1.44.2.1
 @ -649,5 +649,6  @ bool KZip::closeArchive()
     for ( ; it.current() ; ++it )
     {   //set crc and compressed size in each local file header
-        device()->at( it.current()->headerStart() + 14 );
+        if ( !device()->at( it.current()->headerStart() + 14 ) )
+            return false;
         //kdDebug(7040) << "closearchive setcrcandcsize: filename: "
         //    << it.current()->path()
 @ -672,5 +673,6  @ bool KZip::closeArchive()
         buffer[11] = char(myusize >> 24);
 
-        device()->writeBlock( buffer, 12 );
+        if ( device()->writeBlock( buffer, 12 ) != 12 )
+            return false;
     }
     device()->at( atbackup );
 @ -758,5 +760,6  @ bool KZip::closeArchive()
 
         crc = crc32(crc, (Bytef *)buffer, bufferSize );
-        device()->writeBlock( buffer, bufferSize );
+        if ( device()->writeBlock( buffer, bufferSize ) != bufferSize )
+            return false;
         delete[] buffer;
     }
 @ -804,5 +807,6  @ bool KZip::closeArchive()
     buffer[ 21 ] = 0;
 
-    device()->writeBlock( buffer, 22);
+    if ( device()->writeBlock( buffer, 22 ) != 22 )
+        return false;
 
     //kdDebug(7040) << "kzip.cpp reached." << endl;
 @ -861,5 +865,8  @ bool KZip::prepareWriting_impl(const QSt
 
     // set right offset in zip.
-    device()->at( d->m_offset );
+    if ( !device()->at( d->m_offset ) ) {
+        kdWarning(7040) << "prepareWriting_impl: cannot seek in ZIP file. Disk \
full?" << endl; +        return false;
+    }
 
     // delete entries in the filelist with the same filename as the one we want
 @ -1129,5 +1136,4  @ bool KZip::writeData_impl(const char * c
     Q_LONG written = d->m_currentDev->writeBlock( c, i );
     //kdDebug(7040) << "KZip::writeData wrote " << i << " bytes." << endl;
-    Q_ASSERT( written == (Q_LONG)i );
     return written == (Q_LONG)i;
 }
____________________________________
koffice mailing list
koffice@mail.kde.org
To unsubscribe please visit:
https://mail.kde.org/mailman/listinfo/koffice


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic