summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-22 15:39:35 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-02-23 11:20:44 +0100
commite1f5044b43dbe13e0c5a8383ec3f84b4c2c44ddd (patch)
tree902d5b00eb6177feeef9bfbcafc1fdc537269d29 /hwpfilter
parent5931638fdabb033c2f957c90ae27d075477b1261 (diff)
we should be testing more in the hwpfuzzer
Change-Id: I742efee39496d098677fa251727494bb741f627d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130357 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/hwpreader.cxx54
-rw-r--r--hwpfilter/source/hwpreader.hxx2
2 files changed, 30 insertions, 26 deletions
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index d402e4250e92..923d81f32cc8 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -130,39 +130,17 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportHWP(SvStream &rStream)
stream->addData(aData, static_cast<int>(nRead));
}
- HWPFile hwpfile;
- if (hwpfile.ReadHwpFile(std::move(stream)))
- return false;
+ rtl::Reference<HwpReader> hwpreader(new HwpReader);
+ return hwpreader->importHStream(std::move(stream));
}
catch (...)
{
- return false;
}
- return true;
+ return false;
}
-sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor)
+bool HwpReader::importHStream(std::unique_ptr<HStream> stream)
{
- utl::MediaDescriptor aDescriptor(rDescriptor);
- aDescriptor.addInputStream();
-
- Reference< XInputStream > xInputStream(
- aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY_THROW);
-
- std::unique_ptr<HStream> stream(new HStream);
- Sequence < sal_Int8 > aBuffer;
- sal_Int32 nRead, nTotal = 0;
- while( true )
- {
- nRead = xInputStream->readBytes(aBuffer, 32768);
- if( nRead == 0 )
- break;
- stream->addData( reinterpret_cast<const byte *>(aBuffer.getConstArray()), nRead );
- nTotal += nRead;
- }
-
- if( nTotal == 0 ) return false;
-
if (hwpfile.ReadHwpFile(std::move(stream)))
return false;
@@ -205,6 +183,30 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor)
return true;
}
+sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor)
+{
+ utl::MediaDescriptor aDescriptor(rDescriptor);
+ aDescriptor.addInputStream();
+
+ Reference< XInputStream > xInputStream(
+ aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY_THROW);
+
+ std::unique_ptr<HStream> stream(new HStream);
+ Sequence < sal_Int8 > aBuffer;
+ sal_Int32 nRead, nTotal = 0;
+ while( true )
+ {
+ nRead = xInputStream->readBytes(aBuffer, 32768);
+ if( nRead == 0 )
+ break;
+ stream->addData( reinterpret_cast<const byte *>(aBuffer.getConstArray()), nRead );
+ nTotal += nRead;
+ }
+
+ if( nTotal == 0 ) return false;
+
+ return importHStream(std::move(stream));
+}
/**
* make office:body
diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx
index 91021a326186..309f454e6ffe 100644
--- a/hwpfilter/source/hwpreader.hxx
+++ b/hwpfilter/source/hwpreader.hxx
@@ -88,6 +88,8 @@ public:
{
m_rxDocumentHandler = xHandler;
}
+
+ bool importHStream(std::unique_ptr<HStream> stream);
private:
Reference< XDocumentHandler > m_rxDocumentHandler;
rtl::Reference<AttributeListImpl> mxList;