From 04bd876d51d11506bf78b4497433c8186494ebd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 18 Feb 2011 09:17:22 +0000 Subject: [PATCH] add document load tests for CVEs that have affected calc --- sc/prj/build.lst | 2 +- sc/qa/unit/CVE/CVE-2007-5745-1.wb2 | Bin 0 -> 45006 bytes sc/qa/unit/CVE/CVE-2007-5745-2.wb2 | Bin 0 -> 45006 bytes sc/qa/unit/CVE/CVE-2007-5747-1.wb2 | Bin 0 -> 5409 bytes sc/qa/unit/makefile.mk | 5 ++ sc/qa/unit/ucalc.cxx | 75 +++++++++++++++++++++++++++-- 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 sc/qa/unit/CVE/CVE-2007-5745-1.wb2 create mode 100644 sc/qa/unit/CVE/CVE-2007-5745-2.wb2 create mode 100644 sc/qa/unit/CVE/CVE-2007-5747-1.wb2 diff --git a/sc/prj/build.lst b/sc/prj/build.lst index 1a641a67f461..95d5827c3e33 100755 --- a/sc/prj/build.lst +++ b/sc/prj/build.lst @@ -1,4 +1,4 @@ -sc sc : filter l10n vbahelper oovbaapi svx uui stoc BOOST:boost formula MDDS:mdds oox NULL +sc sc : filter l10n vbahelper oovbaapi svx uui stoc BOOST:boost formula MDDS:mdds oox unoxml NULL sc sc usr1 - all sc_mkout NULL sc sc\inc nmake - all sc_inc NULL sc sc\prj get - all sc_prj NULL diff --git a/sc/qa/unit/CVE/CVE-2007-5745-1.wb2 b/sc/qa/unit/CVE/CVE-2007-5745-1.wb2 new file mode 100644 index 0000000000000000000000000000000000000000..0ba60b26cda736b1d099ed7ac7c6f26968421e3a GIT binary patch literal 45006 zcmeIxu?+wq37>3Mim}0tzUg zfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7> z3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36A zpnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim} y0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzVjpx^7>3Mim}0tzUg zfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7> z3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36A zpnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim} y0tzUgfC36Apnw7jD4>7>3Mim}0tzUgfC36Apnw7jD4>7>3Mim}0tzVjpx^-jFq;+t literal 0 HcmV?d00001 diff --git a/sc/qa/unit/CVE/CVE-2007-5747-1.wb2 b/sc/qa/unit/CVE/CVE-2007-5747-1.wb2 new file mode 100644 index 0000000000000000000000000000000000000000..ca91826b9be900a89c28927a00b72bbcf2e91686 GIT binary patch literal 5409 zcmeIx%L#xm5CqUM6{ICK)u*a_^kxOZTi7MXFw9FzO6}{W&i&4jobPzdAcP=<$Aczl ef+kQv0R #include +#include +#include #include #include +#include #include #include "scdll.hxx" @@ -76,9 +79,14 @@ #include #include +#include +#include + #include #include +#include + #include #include @@ -216,6 +224,8 @@ public: virtual void setUp(); virtual void tearDown(); + bool testLoad(const rtl::OUString &rFilter, const rtl::OUString &rURL); + void testCollator(); void testSUM(); void testNamedRange(); @@ -232,6 +242,11 @@ public: void testGraphicsInGroup(); + /** + * Ensure CVEs remain unbroken + */ + void testCVEs(); + CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testCollator); CPPUNIT_TEST(testSUM); @@ -242,12 +257,14 @@ public: CPPUNIT_TEST(testSheetCopy); CPPUNIT_TEST(testGraphicsInGroup); CPPUNIT_TEST(testFunctionLists); + CPPUNIT_TEST(testCVEs); CPPUNIT_TEST_SUITE_END(); private: uno::Reference< uno::XComponentContext > m_xContext; ScDocument *m_pDoc; - ScDocShellRef m_pDocShell; + ScDocShellRef m_xDocShRef; + ::rtl::OUString m_aPWDURL; }; Test::Test() @@ -263,20 +280,40 @@ Test::Test() //of retaining references to the root ServiceFactory as its passed around comphelper::setProcessServiceFactory(xSM); + // initialise UCB-Broker + uno::Sequence aUcbInitSequence(2); + aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local")); + aUcbInitSequence[1] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office")); + bool bInitUcb = ucbhelper::ContentBroker::initialize(xSM, aUcbInitSequence); + CPPUNIT_ASSERT_MESSAGE("Should be able to initialize UCB", bInitUcb); + + uno::Reference xUcb = + ucbhelper::ContentBroker::get()->getContentProviderManagerInterface(); + uno::Reference xFileProvider(xSM->createInstance( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.FileContentProvider"))), uno::UNO_QUERY); + xUcb->registerContentProvider(xFileProvider, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file")), sal_True); + InitVCL(xSM); ScDLL::Init(); + + oslProcessError err = osl_getProcessWorkingDir(&m_aPWDURL.pData); + CPPUNIT_ASSERT_MESSAGE("no PWD!", err == osl_Process_E_None); } void Test::setUp() { - m_pDocShell = new ScDocShell; - m_pDoc = m_pDocShell->GetDocument(); + m_xDocShRef = new ScDocShell( + SFXMODEL_STANDARD | + SFXMODEL_DISABLE_EMBEDDED_SCRIPTS | + SFXMODEL_DISABLE_DOCUMENT_RECOVERY); + + m_pDoc = m_xDocShRef->GetDocument(); } void Test::tearDown() { - m_pDocShell.Clear(); + m_xDocShRef.Clear(); } Test::~Test() @@ -371,6 +408,36 @@ void Test::testCSV() } } +bool Test::testLoad(const rtl::OUString &rFilter, const rtl::OUString &rURL) +{ + SfxFilter aFilter( + rFilter, + rtl::OUString(), 0, 0, rtl::OUString(), 0, rtl::OUString(), + rtl::OUString(), rtl::OUString() ); + + ScDocShellRef xDocShRef = new ScDocShell; + SfxMedium aSrcMed(rURL, STREAM_STD_READ, true); + aSrcMed.SetFilter(&aFilter); + return xDocShRef->DoLoad(&aSrcMed); +} + +void Test::testCVEs() +{ + bool bResult; + + bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Quattro Pro 6.0")), + m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2007-5745-1.wb2"))); + CPPUNIT_ASSERT_MESSAGE("CVE-2007-5745 regression", bResult == true); + + bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Quattro Pro 6.0")), + m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2007-5745-2.wb2"))); + CPPUNIT_ASSERT_MESSAGE("CVE-2007-5745 regression", bResult == true); + + bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Quattro Pro 6.0")), + m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2007-5747-1.wb2"))); + CPPUNIT_ASSERT_MESSAGE("CVE-2007-5747 regression", bResult == false); +} + template void checkMatrixElements(const ScMatrix& rMat) {