Kaydet (Commit) 9de20d1e authored tarafından Caolán McNamara's avatar Caolán McNamara

add tests for CVE-2008-1097, etc.

Change-Id: Iad6948fdf6eb60f86d764783b72a4fe7f5642e40
üst f31ac240
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,filter_pcx_test))
$(eval $(call gb_CppunitTest_use_external,filter_pcx_test,boost_headers))
$(eval $(call gb_CppunitTest_add_exception_objects,filter_pcx_test, \
filter/qa/cppunit/filters-pcx-test \
))
$(eval $(call gb_CppunitTest_use_libraries,filter_pcx_test, \
ipx \
sal \
test \
tl \
unotest \
vcl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_api,filter_pcx_test,\
udkapi \
offapi \
))
$(eval $(call gb_CppunitTest_use_ure,filter_pcx_test))
$(eval $(call gb_CppunitTest_use_components,filter_pcx_test,\
configmgr/source/configmgr \
))
$(eval $(call gb_CppunitTest_use_configuration,filter_pcx_test))
# vim: set noet sw=4 ts=4:
...@@ -83,10 +83,11 @@ $(eval $(call gb_Module_add_check_targets,filter,\ ...@@ -83,10 +83,11 @@ $(eval $(call gb_Module_add_check_targets,filter,\
ifneq ($(DISABLE_CVE_TESTS),TRUE) ifneq ($(DISABLE_CVE_TESTS),TRUE)
$(eval $(call gb_Module_add_check_targets,filter,\ $(eval $(call gb_Module_add_check_targets,filter,\
CppunitTest_filter_pcx_test \
CppunitTest_filter_pict_test \ CppunitTest_filter_pict_test \
CppunitTest_filter_ras_test \ CppunitTest_filter_ras_test \
CppunitTest_filter_tga_test \
CppunitTest_filter_tiff_test \ CppunitTest_filter_tiff_test \
CppunitTest_filter_tga_test \
)) ))
endif endif
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/FilterConfigItem.hxx>
#include <tools/stream.hxx>
#include <vcl/graph.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
extern "C"
{
SAL_DLLPUBLIC_EXPORT bool SAL_CALL
GraphicImport(SvStream & rStream, Graphic & rGraphic,
FilterConfigItem*);
}
using namespace ::com::sun::star;
/* Implementation of Filters test */
class RasFilterTest
: public test::FiltersTest
, public test::BootstrapFixture
{
public:
RasFilterTest() : BootstrapFixture(true, false) {}
virtual bool load(const OUString &,
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int) SAL_OVERRIDE;
/**
* Ensure CVEs remain unbroken
*/
void testCVEs();
CPPUNIT_TEST_SUITE(RasFilterTest);
CPPUNIT_TEST(testCVEs);
CPPUNIT_TEST_SUITE_END();
};
bool RasFilterTest::load(const OUString &,
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int)
{
SvFileStream aFileStream(rURL, STREAM_READ);
Graphic aGraphic;
return GraphicImport(aFileStream, aGraphic, NULL);
}
void RasFilterTest::testCVEs()
{
testDir(OUString(),
getURLFromSrc("/filter/qa/cppunit/data/pcx/"),
OUString());
}
CPPUNIT_TEST_SUITE_REGISTRATION(RasFilterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -160,10 +160,7 @@ sal_Bool PCXReader::ReadPCX(Graphic & rGraphic) ...@@ -160,10 +160,7 @@ sal_Bool PCXReader::ReadPCX(Graphic & rGraphic)
void PCXReader::ImplReadHeader() void PCXReader::ImplReadHeader()
{ {
sal_uInt8 nbyte; sal_uInt8 nbyte(0);
sal_uInt16 nushort;
sal_uInt16 nMinX,nMinY,nMaxX,nMaxY;
m_rPCX.ReadUChar( nbyte ).ReadUChar( nVersion ).ReadUChar( nEncoding ); m_rPCX.ReadUChar( nbyte ).ReadUChar( nVersion ).ReadUChar( nEncoding );
if ( nbyte!=0x0a || (nVersion != 0 && nVersion != 2 && nVersion != 3 && nVersion != 5) || nEncoding > 1 ) if ( nbyte!=0x0a || (nVersion != 0 && nVersion != 2 && nVersion != 3 && nVersion != 5) || nEncoding > 1 )
{ {
...@@ -171,7 +168,9 @@ void PCXReader::ImplReadHeader() ...@@ -171,7 +168,9 @@ void PCXReader::ImplReadHeader()
return; return;
} }
nbyte = 0;
m_rPCX.ReadUChar( nbyte ); nBitsPerPlanePix = (sal_uLong)nbyte; m_rPCX.ReadUChar( nbyte ); nBitsPerPlanePix = (sal_uLong)nbyte;
sal_uInt16 nMinX(0),nMinY(0),nMaxX(0),nMaxY(0);
m_rPCX.ReadUInt16( nMinX ).ReadUInt16( nMinY ).ReadUInt16( nMaxX ).ReadUInt16( nMaxY ); m_rPCX.ReadUInt16( nMinX ).ReadUInt16( nMinY ).ReadUInt16( nMaxX ).ReadUInt16( nMaxY );
if ((nMinX > nMaxX) || (nMinY > nMaxY)) if ((nMinX > nMaxX) || (nMinY > nMaxY))
...@@ -191,7 +190,9 @@ void PCXReader::ImplReadHeader() ...@@ -191,7 +190,9 @@ void PCXReader::ImplReadHeader()
ImplReadPalette( 16 ); ImplReadPalette( 16 );
m_rPCX.SeekRel( 1 ); m_rPCX.SeekRel( 1 );
nbyte = 0;
m_rPCX.ReadUChar( nbyte ); nPlanes = (sal_uLong)nbyte; m_rPCX.ReadUChar( nbyte ); nPlanes = (sal_uLong)nbyte;
sal_uInt16 nushort(0);
m_rPCX.ReadUInt16( nushort ); nBytesPerPlaneLin = (sal_uLong)nushort; m_rPCX.ReadUInt16( nushort ); nBytesPerPlaneLin = (sal_uLong)nushort;
m_rPCX.ReadUInt16( nPaletteInfo ); m_rPCX.ReadUInt16( nPaletteInfo );
......
...@@ -219,18 +219,16 @@ sal_uLong TIFFReader::DataTypeSize() ...@@ -219,18 +219,16 @@ sal_uLong TIFFReader::DataTypeSize()
return nSize; return nSize;
} }
sal_uLong TIFFReader::ReadIntData() sal_uLong TIFFReader::ReadIntData()
{ {
double nDOUBLE; double nDOUBLE(0.0);
float nFLOAT; float nFLOAT(0);
sal_uInt32 nUINT32a, nUINT32b; sal_uInt32 nUINT32a(0), nUINT32b(0);
sal_Int32 nINT32; sal_Int32 nINT32(0);
sal_uInt16 nUINT16; sal_uInt16 nUINT16(0);
sal_Int16 nINT16; sal_Int16 nINT16(0);
sal_uInt8 nBYTE; sal_uInt8 nBYTE(0);
char nCHAR; char nCHAR(0);
switch( nDataType ) switch( nDataType )
{ {
...@@ -282,8 +280,6 @@ sal_uLong TIFFReader::ReadIntData() ...@@ -282,8 +280,6 @@ sal_uLong TIFFReader::ReadIntData()
return nUINT32a; return nUINT32a;
} }
double TIFFReader::ReadDoubleData() double TIFFReader::ReadDoubleData()
{ {
sal_uInt32 nulong; sal_uInt32 nulong;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment