~ubuntu-branches/ubuntu/breezy/koffice/breezy-security

« back to all changes in this revision

Viewing changes to lib/store/koTarStore.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-10-11 14:49:50 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051011144950-lwpngbifzp8nk0ds
Tags: 1:1.4.1-0ubuntu7
* SECURITY UPDATE: fix heap based buffer overflow in the RTF importer of KWord
* Opening specially crafted RTF files in KWord can cause
  execution of abitrary code.
* Add kubuntu_01_rtfimport_heap_overflow.diff
* References:
  CAN-2005-2971
  CESA-2005-005
  http://www.koffice.org/security/advisory-20051011-1.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
*/
19
19
 
20
20
#include "koTarStore.h"
 
21
 
 
22
#include <qbuffer.h>
 
23
 
21
24
#include <ktar.h>
22
25
#include <kdebug.h>
23
 
#include <qbuffer.h>
 
26
#include <kurl.h>
 
27
#include <kdeversion.h>
 
28
#include <kio/netaccess.h>
24
29
 
25
30
KoTarStore::KoTarStore( const QString & _filename, Mode _mode, const QCString & appIdentification )
26
31
{
30
35
    m_pTar = new KTar( _filename, "application/x-gzip" );
31
36
 
32
37
    m_bGood = init( _mode ); // open the targz file and init some vars
33
 
 
 
38
    kdDebug()<<"appIdentification :"<<appIdentification<<endl;
34
39
    if ( m_bGood && _mode == Write )
35
40
        m_pTar->setOrigFileName( completeMagic( appIdentification ) );
36
41
}
45
50
        m_pTar->setOrigFileName( completeMagic( appIdentification ) );
46
51
}
47
52
 
 
53
KoTarStore::KoTarStore( QWidget* window, const KURL& _url, const QString & _filename, Mode _mode, const QCString & appIdentification )
 
54
{
 
55
    kdDebug(s_area) << "KoTarStore Constructor url= " << _url.prettyURL()
 
56
                    << " filename = " << _filename
 
57
                    << " mode = " << int(_mode) << endl;
 
58
 
 
59
    m_url = _url;
 
60
    m_window = window;
 
61
 
 
62
    if ( _mode == KoStore::Read )
 
63
    {
 
64
        m_fileMode = KoStoreBase::RemoteRead;
 
65
        m_localFileName = _filename;
 
66
 
 
67
    }
 
68
    else
 
69
    {
 
70
        m_fileMode = KoStoreBase::RemoteWrite;
 
71
        m_localFileName = "/tmp/kozip"; // ### FIXME with KTempFile
 
72
    }
 
73
 
 
74
    m_pTar = new KTar( m_localFileName, "application/x-gzip" );
 
75
 
 
76
    m_bGood = init( _mode ); // open the targz file and init some vars
 
77
 
 
78
    if ( m_bGood && _mode == Write )
 
79
        m_pTar->setOrigFileName( completeMagic( appIdentification ) );
 
80
}
 
81
 
48
82
KoTarStore::~KoTarStore()
49
83
{
50
84
    m_pTar->close();
51
85
    delete m_pTar;
 
86
 
 
87
    // Now we have still some job to do for remote files.
 
88
    if ( m_fileMode == KoStoreBase::RemoteRead )
 
89
    {
 
90
        KIO::NetAccess::removeTempFile( m_localFileName );
 
91
    }
 
92
    else if ( m_fileMode == KoStoreBase::RemoteWrite )
 
93
    {
 
94
        KIO::NetAccess::upload( m_localFileName, m_url, m_window );
 
95
        // ### FIXME: delete temp file
 
96
    }
52
97
}
53
98
 
54
99
QCString KoTarStore::completeMagic( const QCString& appMimetype )
55
100
{
 
101
    kdDebug()<<"QCString KoTarStore::completeMagic( const QCString& appMimetype )********************\n";
56
102
    QCString res( "KOffice " );
57
103
    res += appMimetype;
58
104
    res += '\004'; // Two magic bytes to make the identification
59
105
    res += '\006'; // more reliable (DF)
 
106
    kdDebug()<<"sssssssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n";
 
107
    kdDebug()<<" return :!!!!!!!!!!!!!!! :"<<res<<endl;
60
108
    return res;
61
109
}
62
110
 
152
200
        return true;
153
201
}
154
202
 
155
 
bool KoTarStore::fileExists( const QString& absPath )
 
203
bool KoTarStore::fileExists( const QString& absPath ) const
156
204
{
157
205
    return m_pTar->directory()->entry( absPath ) != 0;
158
206
}