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

« back to all changes in this revision

Viewing changes to lib/kformula/matrixelement.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:
840
840
    for(uint i=0;i<cols;i++)
841
841
        matrix+="c ";
842
842
 
843
 
    matrix+="}";
 
843
    matrix+="} ";
844
844
 
845
845
    for (uint r = 0; r < rows; r++) {
846
846
        for (uint c = 0; c < cols; c++) {
850
850
        if(r < rows-1 ) matrix+=" \\\\ ";
851
851
    }
852
852
 
853
 
    matrix+="\\end{array}";
 
853
    matrix+=" \\end{array}";
854
854
 
855
855
    return matrix;
856
856
}
880
880
}
881
881
 
882
882
 
883
 
void MatrixElement::writeMathML( QDomDocument doc, QDomNode parent )
 
883
void MatrixElement::writeMathML( QDomDocument& doc, QDomNode parent, bool oasisFormat )
884
884
{
885
 
    QDomElement de = doc.createElement( "mtable" );
 
885
    QDomElement de = doc.createElement( oasisFormat ? "math:mtable" : "mtable" );
886
886
    QDomElement row;
887
887
    QDomElement cell;
888
888
 
891
891
 
892
892
    for ( uint r = 0; r < rows; r++ )
893
893
    {
894
 
        row = doc.createElement( "mtr" );
 
894
        row = doc.createElement( oasisFormat ? "math:mtr" : "mtr" );
895
895
        de.appendChild( row );
896
896
        for ( uint c = 0; c < cols; c++ )
897
897
        {
898
 
            cell = doc.createElement( "mtd" );
 
898
            cell = doc.createElement( oasisFormat ? "math:mtd" : "mtd" );
899
899
            row.appendChild( cell );
900
 
            getElement(r,c)->writeMathML( doc, cell );
 
900
            getElement(r,c)->writeMathML( doc, cell, oasisFormat );
901
901
        }
902
902
    }
903
903
 
962
962
    /// Return the position of tab i.
963
963
    int tabPos( uint i );
964
964
 
965
 
    virtual void writeMathML( QDomDocument doc, QDomNode parent );
 
965
    virtual void writeMathML( QDomDocument& doc, QDomNode parent, bool oasisFormat = false );
966
966
 
967
967
private:
968
968
 
1225
1225
}
1226
1226
 
1227
1227
 
1228
 
void MultilineSequenceElement::writeMathML( QDomDocument doc,
1229
 
                                            QDomNode parent )
 
1228
void MultilineSequenceElement::writeMathML( QDomDocument& doc,
 
1229
                                            QDomNode parent, bool oasisFormat )
1230
1230
{
1231
1231
    // parent is required to be a <mtr> tag
1232
1232
 
1233
1233
    QDomElement tmp = doc.createElement( "TMP" );
1234
1234
 
1235
 
    inherited::writeMathML( doc, tmp );
 
1235
    inherited::writeMathML( doc, tmp, oasisFormat );
1236
1236
 
1237
1237
    /* Now we re-parse the Dom tree, because of the TabMarkers
1238
1238
     * that have no direct representation in MathML but mark the
1239
1239
     * end of a <mtd> tag.
1240
1240
     */
1241
1241
 
1242
 
    QDomElement mtd = doc.createElement( "mtd" );
 
1242
    QDomElement mtd = doc.createElement( oasisFormat ? "math:mtd" : "mtd" );
1243
1243
 
1244
1244
    // The mrow, if it exists.
1245
1245
    QDomNode n = tmp.firstChild().firstChild();
1247
1247
        // the illegal TabMarkers are children of the mrow, child of tmp.
1248
1248
        if ( n.isElement() && n.toElement().tagName() == "TAB" ) {
1249
1249
            parent.appendChild( mtd );
1250
 
            mtd = doc.createElement( "mtd" );
 
1250
            mtd = doc.createElement( oasisFormat ? "math:mtd" : "mtd" );
1251
1251
        }
1252
1252
        else {
1253
1253
            mtd.appendChild( n.cloneNode() ); // cloneNode needed?
1703
1703
    }
1704
1704
}
1705
1705
 
1706
 
void MultilineElement::writeMathML( QDomDocument doc, QDomNode parent )
 
1706
void MultilineElement::writeMathML( QDomDocument& doc, QDomNode parent, bool oasisFormat )
1707
1707
{
1708
 
    QDomElement de = doc.createElement( "mtable" );
 
1708
    QDomElement de = doc.createElement( oasisFormat ? "math:mtable" : "mtable" );
1709
1709
    QDomElement row; QDomElement cell;
1710
1710
 
1711
1711
    for ( uint i = 0; i < content.count(); ++i ) {
1712
 
        row = doc.createElement( "mtr" );
 
1712
        row = doc.createElement( oasisFormat ? "math:mtr" : "mtr" );
1713
1713
        de.appendChild( row );
1714
1714
        //cell = doc.createElement( "mtd" );
1715
1715
        //row.appendChild( cell );
1716
1716
 
1717
1717
        //content.at( i )->writeMathML( doc, cell );
1718
 
        content.at( i )->writeMathML( doc, row );
 
1718
        content.at( i )->writeMathML( doc, row, oasisFormat );
1719
1719
    }
1720
1720
 
1721
1721
    parent.appendChild( de );