summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-06 15:39:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-06 18:30:27 +0100
commit434d852762eafe7230299ea6110096b9ac8bb98d (patch)
tree10f552ebbde49683a5c829020cd85c178e1237bf
parentc207e2c7a3a49bc46488056d0d106517781c3ef4 (diff)
ofz#45276 uncaught exception
Change-Id: I5863d6474aa47f24b24a15481c8329a5e587a8d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131078 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/filter/svm/SvmConverter.cxx18
-rw-r--r--vcl/source/filter/svm/SvmConverter.hxx2
-rw-r--r--vcl/workben/fftester.cxx28
-rw-r--r--vcl/workben/svmfuzzer.cxx11
4 files changed, 37 insertions, 22 deletions
diff --git a/vcl/source/filter/svm/SvmConverter.cxx b/vcl/source/filter/svm/SvmConverter.cxx
index 004abcd4d751..36fc1d43f7db 100644
--- a/vcl/source/filter/svm/SvmConverter.cxx
+++ b/vcl/source/filter/svm/SvmConverter.cxx
@@ -33,6 +33,7 @@
#include "SvmConverter.hxx"
+#include <boost/rational.hpp>
#include <algorithm>
#include <memory>
#include <stack>
@@ -1268,4 +1269,21 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rIStm.SetEndian( nOldFormat );
}
+bool TestImportSVM(SvStream& rStream)
+{
+ GDIMetaFile aGDIMetaFile;
+ SvmReader aReader(rStream);
+ aReader.Read(aGDIMetaFile);
+ ScopedVclPtrInstance<VirtualDevice> aVDev;
+ try
+ {
+ aGDIMetaFile.Play(*aVDev);
+ }
+ catch (const boost::bad_rational&)
+ {
+ return false;
+ }
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/svm/SvmConverter.hxx b/vcl/source/filter/svm/SvmConverter.hxx
index 459f327d409c..23185dc04b4b 100644
--- a/vcl/source/filter/svm/SvmConverter.hxx
+++ b/vcl/source/filter/svm/SvmConverter.hxx
@@ -85,6 +85,8 @@ private:
SVMConverter& operator=( const SVMConverter& ) = delete;
};
+extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportSVM(SvStream& rStream);
+
#endif // INCLUDED_VCL_INC_SVMCONVERTER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index 7938f0011b38..4950341462a8 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -182,15 +182,6 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
SvFileStream aFileStream(out, StreamMode::READ);
ret = static_cast<int>(ReadDIB(aTarget, aFileStream, true));
}
- else if (strcmp(argv[2], "svm") == 0)
- {
- GDIMetaFile aGDIMetaFile;
- SvFileStream aFileStream(out, StreamMode::READ);
- SvmReader aReader(aFileStream);
- aReader.Read(aGDIMetaFile);
- ScopedVclPtrInstance<VirtualDevice> aVDev;
- aGDIMetaFile.Play(*aVDev);
- }
else if (strcmp(argv[2], "pcd") == 0)
{
Graphic aGraphic;
@@ -263,6 +254,13 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
SvFileStream aFileStream(out, StreamMode::READ);
ret = static_cast<int>(ImportWebpGraphic(aFileStream, aGraphic));
}
+ else if (strcmp(argv[2], "sft") == 0)
+ {
+ SvFileStream aFileStream(out, StreamMode::READ);
+ std::vector<sal_uInt8> aData(aFileStream.remainingSize());
+ aFileStream.ReadBytes(aData.data(), aData.size());
+ ret = TestFontSubset(aData.data(), aData.size());
+ }
#ifndef DISABLE_DYNLOADING
else if ((strcmp(argv[2], "doc") == 0) || (strcmp(argv[2], "ww8") == 0))
{
@@ -524,14 +522,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
SvFileStream aFileStream(out, StreamMode::READ);
ret = static_cast<int>((*pfnImport)(aFileStream));
}
- else if (strcmp(argv[2], "sft") == 0)
+ else if (strcmp(argv[2], "svm") == 0)
{
+ static FFilterCall pfnImport(nullptr);
+ if (!pfnImport)
+ {
+ pfnImport = load(u"libvcllo.so", "TestImportSVM");
+ }
SvFileStream aFileStream(out, StreamMode::READ);
- std::vector<sal_uInt8> aData(aFileStream.remainingSize());
- aFileStream.ReadBytes(aData.data(), aData.size());
- ret = TestFontSubset(aData.data(), aData.size());
+ ret = static_cast<int>((*pfnImport)(aFileStream));
}
-
#endif
}
catch (...)
diff --git a/vcl/workben/svmfuzzer.cxx b/vcl/workben/svmfuzzer.cxx
index 06188ece3004..53757e3199c7 100644
--- a/vcl/workben/svmfuzzer.cxx
+++ b/vcl/workben/svmfuzzer.cxx
@@ -8,14 +8,13 @@
*/
#include <tools/stream.hxx>
-#include <vcl/gdimtf.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/filter/SvmReader.hxx>
#include "commonfuzzer.hxx"
#include <config_features.h>
#include <osl/detail/component-mapping.h>
+extern "C" bool TestImportSVM(SvStream &rStream);
+
extern "C" {
void * com_sun_star_i18n_LocaleDataImpl_get_implementation( void *, void * );
void * com_sun_star_i18n_BreakIterator_Unicode_get_implementation( void *, void * );
@@ -77,11 +76,7 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);
- GDIMetaFile aGDIMetaFile;
- SvmReader aReader(aStream);
- aReader.Read(aGDIMetaFile);
- ScopedVclPtrInstance<VirtualDevice> aVDev;
- aGDIMetaFile.Play(*aVDev);
+ (void)TestImportSVM(aStream);
return 0;
}