summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-09-17 17:51:43 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-09-17 21:38:24 +0200
commit1ebf34c67142d1a36923ad6511301fb4b7458edd (patch)
tree072732e865b1c10e2390a6d5aedf4955e4d91e44 /sax
parent1cd8f0fa93077c4c3431a6c6a9d582c1cd535a04 (diff)
protect against short file
Change-Id: I20c6a6fb34485f42c2a828618e8918d8a441860a Reviewed-on: https://gerrit.libreoffice.org/42389 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sax')
-rw-r--r--sax/source/expatwrap/xml2utf.cxx3
1 files changed, 1 insertions, 2 deletions
diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx
index fde25ce8482b..58ee36c1c829 100644
--- a/sax/source/expatwrap/xml2utf.cxx
+++ b/sax/source/expatwrap/xml2utf.cxx
@@ -221,8 +221,7 @@ bool XMLFile2UTFConverter::scanForEncoding( Sequence< sal_Int8 > &seq )
}
// first level : detect possible file formats
- if( ! strncmp( reinterpret_cast<const char *>(pSource), "<?xml", 5 ) ) {
-
+ if (seq.getLength() >= 5 && !strncmp(reinterpret_cast<const char *>(pSource), "<?xml", 5)) {
// scan for encoding
OString str( reinterpret_cast<const char *>(pSource), seq.getLength() );