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

« back to all changes in this revision

Viewing changes to kpresenter/kprdrag.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:
1
1
// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
2
2
/* This file is part of the KDE project
3
 
   Copyright (C) 2001, Laurent Montel <lmontel@mandrakesoft.com>
 
3
   Copyright (C) 2001,2004 Laurent Montel <montel@kde.org>
4
4
 
5
5
   This library is free software; you can redistribute it and/or
6
6
   modify it under the terms of the GNU Library General Public
21
21
#include "kprdrag.h"
22
22
#include "kprdrag.moc"
23
23
#include <kdebug.h>
 
24
#include <kotextobject.h>
24
25
 
25
26
KPrTextDrag::KPrTextDrag( QWidget *dragSource, const char *name )
26
27
    : QTextDrag( dragSource, name )
29
30
 
30
31
QByteArray KPrTextDrag::encodedData( const char *mime ) const
31
32
{
32
 
    if ( strcmp( selectionMimeType(), mime ) == 0)
 
33
    if ( ( strcmp( selectionMimeType(), mime ) == 0 ) || QString( mime ).startsWith( KoTextObject::acceptSelectionMimeType()) )
33
34
        return kpresenter;
34
 
    else if( strcmp( "application/x-kpresenter-textobjectnumber", mime ) == 0)
35
 
    {
36
 
        QByteArray a;
37
 
        QCString s (  QString::number(m_textObjectNumber).local8Bit() );
38
 
        a.resize( s.length() + 1 ); // trailing zero
39
 
        memcpy( a.data(), s.data(), s.length() + 1 );
40
 
        return a;
41
 
    }
42
35
    else
43
36
        return QTextDrag::encodedData(mime);
44
37
}
45
38
 
46
39
bool KPrTextDrag::canDecode( QMimeSource* e )
47
40
{
48
 
    if ( e->provides( selectionMimeType() ) )
 
41
    if ( KoTextObject::providesOasis( e ) )
49
42
        return true;
50
43
    return QTextDrag::canDecode(e);
51
44
}
63
56
 
64
57
const char * KPrTextDrag::selectionMimeType()
65
58
{
 
59
    //return "application/vnd.oasis.opendocument.presentation";
66
60
    return "application/x-kpresenter-textselection";
67
61
}
68
 
 
69
 
void KPrTextDrag::setTextObjectNumber( int number )
70
 
{
71
 
    m_textObjectNumber = number;
72
 
}
73
 
 
74
 
int KPrTextDrag::decodeTextObjectNumber( QMimeSource *e )
75
 
{
76
 
    QByteArray a =  e->encodedData("application/x-kpresenter-textobjectnumber");
77
 
    if(!a.isEmpty())
78
 
        return QCString(a, a.count()+1).toInt();
79
 
    else
80
 
        return -1;
81
 
}