summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-07-18 22:44:33 +0900
committerAndras Timar <andras.timar@collabora.com>2017-09-18 17:50:30 +0200
commit253fe62c5b736bfd46106d510356e0809a44b02a (patch)
treebba8f8d1a4b008ba0b7af4758b875c72b1425a17 /sax
parentfb7de575d2a308e9656bc83828045263dad87f9f (diff)
sax: Check if it starts with 5 bytes of "<?xml"
Reviewed-on: https://gerrit.libreoffice.org/40139 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit b64e564492220b34c14f069e8e1f42675bd9abe6) ofz: string has to be at least 5 chars long Reviewed-on: https://gerrit.libreoffice.org/42379 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> this should presumably be 5, rather than 4 Change-Id: Iec5b748b188c7b1bf61e8137faf4b3f2d480d7f1 98c50a59c03fc886d50362b9c5dd8c84f60e0b62 20c6a6fb34485f42c2a828618e8918d8a441860a Reviewed-on: https://gerrit.libreoffice.org/42395 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr> (cherry picked from commit 44815f1439bb36e9fb5f0181c541fc4d0c9422f1)
Diffstat (limited to 'sax')
-rw-r--r--sax/source/expatwrap/xml2utf.cxx8
1 files changed, 3 insertions, 5 deletions
diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index 361e02fc99b0..017a3b1c96e9 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -126,7 +126,7 @@ XMLFile2UTFConverter::~XMLFile2UTFConverter()
void XMLFile2UTFConverter::removeEncoding( Sequence<sal_Int8> &seq )
{
const sal_Int8 *pSource = seq.getArray();
- if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 4) )
+ if (seq.getLength() >= 5 && !strncmp(reinterpret_cast<const char *>(pSource), "<?xml", 5))
{
// scan for encoding
@@ -161,7 +161,6 @@ void XMLFile2UTFConverter::removeEncoding( Sequence<sal_Int8> &seq )
&( seq.getArray()[nStop+1]) ,
seq.getLength() - nStop -1);
seq.realloc( seq.getLength() - ( nStop+1 - nFound ) );
-// str = String( (char * ) seq.getArray() , seq.getLen() );
}
}
}
@@ -178,7 +177,7 @@ bool XMLFile2UTFConverter::isEncodingRecognizable( const Sequence< sal_Int8 > &s
return false;
}
- if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 4 ) ) {
+ if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 5 ) ) {
// scan if the <?xml tag finishes within this buffer
bCheckIfFirstClosingBracketExsists = true;
}
@@ -223,8 +222,7 @@ bool XMLFile2UTFConverter::scanForEncoding( Sequence< sal_Int8 > &seq )
}
// first level : detect possible file formats
- if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 4 ) ) {
-
+ if (seq.getLength() >= 5 && !strncmp(reinterpret_cast<const char *>(pSource), "<?xml", 5)) {
// scan for encoding
OString str( reinterpret_cast<const char *>(pSource), seq.getLength() );